Merge pull request #113 from TheBlueMatt/main
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define LIKELY(v) __builtin_expect(!!(v), 1)
13 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
14
15 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
16 #define MALLOC(a, _) malloc(a)
17 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
18 #define CHECK_ACCESS(p)
19 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 static jmethodID ordinal_meth = NULL;
24 static jmethodID slicedef_meth = NULL;
25 static jclass slicedef_cls = NULL;
26 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
27         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
28         CHECK(ordinal_meth != NULL);
29         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
30         CHECK(slicedef_meth != NULL);
31         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
32         CHECK(slicedef_cls != NULL);
33 }
34
35 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
36         return *((bool*)ptr);
37 }
38 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
39         return *((long*)ptr);
40 }
41 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
42         FREE((void*)ptr);
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
45         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
46         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
47         return ret_arr;
48 }
49 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
50         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
51         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
52         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
53         return ret_arr;
54 }
55 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
56         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
57         vec->datalen = (*env)->GetArrayLength(env, bytes);
58         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
59         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
60         return (uint64_t)vec;
61 }
62 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
63         LDKTransaction *txdata = (LDKTransaction*)ptr;
64         LDKu8slice slice;
65         slice.data = txdata->data;
66         slice.datalen = txdata->datalen;
67         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
68 }
69 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
70         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
71         txdata->datalen = (*env)->GetArrayLength(env, bytes);
72         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
73         txdata->data_is_owned = false;
74         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
75         return (uint64_t)txdata;
76 }
77 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
78         LDKTransaction *tx = (LDKTransaction*)ptr;
79         tx->data_is_owned = true;
80         Transaction_free(*tx);
81         FREE((void*)ptr);
82 }
83 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
84         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
87         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
88         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
89         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
90         return (uint64_t)vec->datalen;
91 }
92 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
93         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
96         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
97         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
98         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
99         vec->data = NULL;
100         vec->datalen = 0;
101         return (uint64_t)vec;
102 }
103
104 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
105 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
106 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
107 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
108
109 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
110 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
111 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
112
113 typedef jlongArray int64_tArray;
114 typedef jbyteArray int8_tArray;
115
116 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
117         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
118         char* conv_buf = MALLOC(len + 1, "str conv buf");
119         memcpy(conv_buf, chars, len);
120         conv_buf[len] = 0;
121         jstring ret = (*env)->NewStringUTF(env, conv_buf);
122         FREE(conv_buf);
123         return ret;
124 }
125 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
126         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
127         char* newchars = MALLOC(str_len + 1, "String chars");
128         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
129         memcpy(newchars, jchars, str_len);
130         newchars[str_len] = 0;
131         (*env)->ReleaseStringUTFChars(env, str, jchars);
132         LDKStr res = {
133                 .chars = newchars,
134                 .len = str_len,
135                 .chars_is_owned = true
136         };
137         return res;
138 }
139
140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
141         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
142 }
143 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
144         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
145 }
146 #include "version.c"
147 static jclass arr_of_B_clz = NULL;
148 static jclass arr_of_J_clz = NULL;
149 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
150         arr_of_B_clz = (*env)->FindClass(env, "[B");
151         CHECK(arr_of_B_clz != NULL);
152         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
153         arr_of_J_clz = (*env)->FindClass(env, "[J");
154         CHECK(arr_of_J_clz != NULL);
155         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
156 }
157 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
158 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
159         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
160         if (UNLIKELY((*env)->ExceptionCheck(env))) {
161                 (*env)->ExceptionDescribe(env);
162                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
163         }
164         switch (ord) {
165                 case 0: return LDKAccessError_UnknownChain;
166                 case 1: return LDKAccessError_UnknownTx;
167         }
168         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
169         abort(); // Unreachable, but will let the compiler know we don't return here
170 }
171 static jclass AccessError_class = NULL;
172 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
173 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
174 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
175         AccessError_class = (*env)->NewGlobalRef(env, clz);
176         CHECK(AccessError_class != NULL);
177         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
178         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
179         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
180         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
181 }
182 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
183         switch (val) {
184                 case LDKAccessError_UnknownChain:
185                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
186                 case LDKAccessError_UnknownTx:
187                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
188                 default: abort();
189         }
190 }
191
192 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
193         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
194         if (UNLIKELY((*env)->ExceptionCheck(env))) {
195                 (*env)->ExceptionDescribe(env);
196                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
197         }
198         switch (ord) {
199                 case 0: return LDKCOption_NoneZ_Some;
200                 case 1: return LDKCOption_NoneZ_None;
201         }
202         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
203         abort(); // Unreachable, but will let the compiler know we don't return here
204 }
205 static jclass COption_NoneZ_class = NULL;
206 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
207 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
208 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
209         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
210         CHECK(COption_NoneZ_class != NULL);
211         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
212         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
213         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
214         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
215 }
216 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
217         switch (val) {
218                 case LDKCOption_NoneZ_Some:
219                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
220                 case LDKCOption_NoneZ_None:
221                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
222                 default: abort();
223         }
224 }
225
226 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
227         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
228         if (UNLIKELY((*env)->ExceptionCheck(env))) {
229                 (*env)->ExceptionDescribe(env);
230                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust threw an exception.");
231         }
232         switch (ord) {
233                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
234                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
235         }
236         (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust returned an invalid value.");
237         abort(); // Unreachable, but will let the compiler know we don't return here
238 }
239 static jclass ChannelMonitorUpdateErr_class = NULL;
240 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
241 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
242 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
243         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
244         CHECK(ChannelMonitorUpdateErr_class != NULL);
245         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
246         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
247         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
248         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
249 }
250 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
251         switch (val) {
252                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
253                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
254                 case LDKChannelMonitorUpdateErr_PermanentFailure:
255                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
256                 default: abort();
257         }
258 }
259
260 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
261         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
262         if (UNLIKELY((*env)->ExceptionCheck(env))) {
263                 (*env)->ExceptionDescribe(env);
264                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
265         }
266         switch (ord) {
267                 case 0: return LDKConfirmationTarget_Background;
268                 case 1: return LDKConfirmationTarget_Normal;
269                 case 2: return LDKConfirmationTarget_HighPriority;
270         }
271         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
272         abort(); // Unreachable, but will let the compiler know we don't return here
273 }
274 static jclass ConfirmationTarget_class = NULL;
275 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
276 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
277 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
278 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
279         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
280         CHECK(ConfirmationTarget_class != NULL);
281         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
282         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
283         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
284         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
285         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
286         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
287 }
288 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
289         switch (val) {
290                 case LDKConfirmationTarget_Background:
291                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
292                 case LDKConfirmationTarget_Normal:
293                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
294                 case LDKConfirmationTarget_HighPriority:
295                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
296                 default: abort();
297         }
298 }
299
300 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
301         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
302         if (UNLIKELY((*env)->ExceptionCheck(env))) {
303                 (*env)->ExceptionDescribe(env);
304                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
305         }
306         switch (ord) {
307                 case 0: return LDKCreationError_DescriptionTooLong;
308                 case 1: return LDKCreationError_RouteTooLong;
309                 case 2: return LDKCreationError_TimestampOutOfBounds;
310                 case 3: return LDKCreationError_InvalidAmount;
311                 case 4: return LDKCreationError_MissingRouteHints;
312         }
313         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
314         abort(); // Unreachable, but will let the compiler know we don't return here
315 }
316 static jclass CreationError_class = NULL;
317 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
318 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
319 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
320 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
321 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
322 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
323         CreationError_class = (*env)->NewGlobalRef(env, clz);
324         CHECK(CreationError_class != NULL);
325         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
326         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
327         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
328         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
329         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
330         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
331         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
333         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
334         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
335 }
336 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
337         switch (val) {
338                 case LDKCreationError_DescriptionTooLong:
339                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
340                 case LDKCreationError_RouteTooLong:
341                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
342                 case LDKCreationError_TimestampOutOfBounds:
343                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
344                 case LDKCreationError_InvalidAmount:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
346                 case LDKCreationError_MissingRouteHints:
347                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
348                 default: abort();
349         }
350 }
351
352 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
353         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
354         if (UNLIKELY((*env)->ExceptionCheck(env))) {
355                 (*env)->ExceptionDescribe(env);
356                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
357         }
358         switch (ord) {
359                 case 0: return LDKCurrency_Bitcoin;
360                 case 1: return LDKCurrency_BitcoinTestnet;
361                 case 2: return LDKCurrency_Regtest;
362                 case 3: return LDKCurrency_Simnet;
363                 case 4: return LDKCurrency_Signet;
364         }
365         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
366         abort(); // Unreachable, but will let the compiler know we don't return here
367 }
368 static jclass Currency_class = NULL;
369 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
370 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
371 static jfieldID Currency_LDKCurrency_Regtest = NULL;
372 static jfieldID Currency_LDKCurrency_Simnet = NULL;
373 static jfieldID Currency_LDKCurrency_Signet = NULL;
374 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
375         Currency_class = (*env)->NewGlobalRef(env, clz);
376         CHECK(Currency_class != NULL);
377         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
378         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
379         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
380         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
381         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
382         CHECK(Currency_LDKCurrency_Regtest != NULL);
383         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
384         CHECK(Currency_LDKCurrency_Simnet != NULL);
385         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
386         CHECK(Currency_LDKCurrency_Signet != NULL);
387 }
388 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
389         switch (val) {
390                 case LDKCurrency_Bitcoin:
391                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
392                 case LDKCurrency_BitcoinTestnet:
393                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
394                 case LDKCurrency_Regtest:
395                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
396                 case LDKCurrency_Simnet:
397                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
398                 case LDKCurrency_Signet:
399                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
400                 default: abort();
401         }
402 }
403
404 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
405         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
407                 (*env)->ExceptionDescribe(env);
408                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
409         }
410         switch (ord) {
411                 case 0: return LDKIOError_NotFound;
412                 case 1: return LDKIOError_PermissionDenied;
413                 case 2: return LDKIOError_ConnectionRefused;
414                 case 3: return LDKIOError_ConnectionReset;
415                 case 4: return LDKIOError_ConnectionAborted;
416                 case 5: return LDKIOError_NotConnected;
417                 case 6: return LDKIOError_AddrInUse;
418                 case 7: return LDKIOError_AddrNotAvailable;
419                 case 8: return LDKIOError_BrokenPipe;
420                 case 9: return LDKIOError_AlreadyExists;
421                 case 10: return LDKIOError_WouldBlock;
422                 case 11: return LDKIOError_InvalidInput;
423                 case 12: return LDKIOError_InvalidData;
424                 case 13: return LDKIOError_TimedOut;
425                 case 14: return LDKIOError_WriteZero;
426                 case 15: return LDKIOError_Interrupted;
427                 case 16: return LDKIOError_Other;
428                 case 17: return LDKIOError_UnexpectedEof;
429         }
430         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
431         abort(); // Unreachable, but will let the compiler know we don't return here
432 }
433 static jclass IOError_class = NULL;
434 static jfieldID IOError_LDKIOError_NotFound = NULL;
435 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
436 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
437 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
438 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
439 static jfieldID IOError_LDKIOError_NotConnected = NULL;
440 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
441 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
442 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
443 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
444 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
445 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
446 static jfieldID IOError_LDKIOError_InvalidData = NULL;
447 static jfieldID IOError_LDKIOError_TimedOut = NULL;
448 static jfieldID IOError_LDKIOError_WriteZero = NULL;
449 static jfieldID IOError_LDKIOError_Interrupted = NULL;
450 static jfieldID IOError_LDKIOError_Other = NULL;
451 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
452 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
453         IOError_class = (*env)->NewGlobalRef(env, clz);
454         CHECK(IOError_class != NULL);
455         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
456         CHECK(IOError_LDKIOError_NotFound != NULL);
457         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
458         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
459         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
460         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
461         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
462         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
463         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
464         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
465         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
466         CHECK(IOError_LDKIOError_NotConnected != NULL);
467         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
468         CHECK(IOError_LDKIOError_AddrInUse != NULL);
469         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
470         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
471         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
472         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
473         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
474         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
475         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
476         CHECK(IOError_LDKIOError_WouldBlock != NULL);
477         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
478         CHECK(IOError_LDKIOError_InvalidInput != NULL);
479         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
480         CHECK(IOError_LDKIOError_InvalidData != NULL);
481         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
482         CHECK(IOError_LDKIOError_TimedOut != NULL);
483         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
484         CHECK(IOError_LDKIOError_WriteZero != NULL);
485         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
486         CHECK(IOError_LDKIOError_Interrupted != NULL);
487         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
488         CHECK(IOError_LDKIOError_Other != NULL);
489         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
490         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
491 }
492 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
493         switch (val) {
494                 case LDKIOError_NotFound:
495                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
496                 case LDKIOError_PermissionDenied:
497                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
498                 case LDKIOError_ConnectionRefused:
499                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
500                 case LDKIOError_ConnectionReset:
501                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
502                 case LDKIOError_ConnectionAborted:
503                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
504                 case LDKIOError_NotConnected:
505                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
506                 case LDKIOError_AddrInUse:
507                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
508                 case LDKIOError_AddrNotAvailable:
509                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
510                 case LDKIOError_BrokenPipe:
511                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
512                 case LDKIOError_AlreadyExists:
513                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
514                 case LDKIOError_WouldBlock:
515                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
516                 case LDKIOError_InvalidInput:
517                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
518                 case LDKIOError_InvalidData:
519                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
520                 case LDKIOError_TimedOut:
521                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
522                 case LDKIOError_WriteZero:
523                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
524                 case LDKIOError_Interrupted:
525                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
526                 case LDKIOError_Other:
527                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
528                 case LDKIOError_UnexpectedEof:
529                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
530                 default: abort();
531         }
532 }
533
534 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
535         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
536         if (UNLIKELY((*env)->ExceptionCheck(env))) {
537                 (*env)->ExceptionDescribe(env);
538                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
539         }
540         switch (ord) {
541                 case 0: return LDKLevel_Gossip;
542                 case 1: return LDKLevel_Trace;
543                 case 2: return LDKLevel_Debug;
544                 case 3: return LDKLevel_Info;
545                 case 4: return LDKLevel_Warn;
546                 case 5: return LDKLevel_Error;
547         }
548         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
549         abort(); // Unreachable, but will let the compiler know we don't return here
550 }
551 static jclass Level_class = NULL;
552 static jfieldID Level_LDKLevel_Gossip = NULL;
553 static jfieldID Level_LDKLevel_Trace = NULL;
554 static jfieldID Level_LDKLevel_Debug = NULL;
555 static jfieldID Level_LDKLevel_Info = NULL;
556 static jfieldID Level_LDKLevel_Warn = NULL;
557 static jfieldID Level_LDKLevel_Error = NULL;
558 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
559         Level_class = (*env)->NewGlobalRef(env, clz);
560         CHECK(Level_class != NULL);
561         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
562         CHECK(Level_LDKLevel_Gossip != NULL);
563         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
564         CHECK(Level_LDKLevel_Trace != NULL);
565         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
566         CHECK(Level_LDKLevel_Debug != NULL);
567         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
568         CHECK(Level_LDKLevel_Info != NULL);
569         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
570         CHECK(Level_LDKLevel_Warn != NULL);
571         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
572         CHECK(Level_LDKLevel_Error != NULL);
573 }
574 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
575         switch (val) {
576                 case LDKLevel_Gossip:
577                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
578                 case LDKLevel_Trace:
579                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
580                 case LDKLevel_Debug:
581                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
582                 case LDKLevel_Info:
583                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
584                 case LDKLevel_Warn:
585                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
586                 case LDKLevel_Error:
587                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
588                 default: abort();
589         }
590 }
591
592 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
593         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
595                 (*env)->ExceptionDescribe(env);
596                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
597         }
598         switch (ord) {
599                 case 0: return LDKNetwork_Bitcoin;
600                 case 1: return LDKNetwork_Testnet;
601                 case 2: return LDKNetwork_Regtest;
602                 case 3: return LDKNetwork_Signet;
603         }
604         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
605         abort(); // Unreachable, but will let the compiler know we don't return here
606 }
607 static jclass Network_class = NULL;
608 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
609 static jfieldID Network_LDKNetwork_Testnet = NULL;
610 static jfieldID Network_LDKNetwork_Regtest = NULL;
611 static jfieldID Network_LDKNetwork_Signet = NULL;
612 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
613         Network_class = (*env)->NewGlobalRef(env, clz);
614         CHECK(Network_class != NULL);
615         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
616         CHECK(Network_LDKNetwork_Bitcoin != NULL);
617         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
618         CHECK(Network_LDKNetwork_Testnet != NULL);
619         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
620         CHECK(Network_LDKNetwork_Regtest != NULL);
621         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
622         CHECK(Network_LDKNetwork_Signet != NULL);
623 }
624 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
625         switch (val) {
626                 case LDKNetwork_Bitcoin:
627                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
628                 case LDKNetwork_Testnet:
629                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
630                 case LDKNetwork_Regtest:
631                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
632                 case LDKNetwork_Signet:
633                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
634                 default: abort();
635         }
636 }
637
638 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
639         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
640         if (UNLIKELY((*env)->ExceptionCheck(env))) {
641                 (*env)->ExceptionDescribe(env);
642                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
643         }
644         switch (ord) {
645                 case 0: return LDKRecipient_Node;
646                 case 1: return LDKRecipient_PhantomNode;
647         }
648         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
649         abort(); // Unreachable, but will let the compiler know we don't return here
650 }
651 static jclass Recipient_class = NULL;
652 static jfieldID Recipient_LDKRecipient_Node = NULL;
653 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
654 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
655         Recipient_class = (*env)->NewGlobalRef(env, clz);
656         CHECK(Recipient_class != NULL);
657         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
658         CHECK(Recipient_LDKRecipient_Node != NULL);
659         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
660         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
661 }
662 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
663         switch (val) {
664                 case LDKRecipient_Node:
665                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
666                 case LDKRecipient_PhantomNode:
667                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
668                 default: abort();
669         }
670 }
671
672 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
673         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
674         if (UNLIKELY((*env)->ExceptionCheck(env))) {
675                 (*env)->ExceptionDescribe(env);
676                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
677         }
678         switch (ord) {
679                 case 0: return LDKSecp256k1Error_IncorrectSignature;
680                 case 1: return LDKSecp256k1Error_InvalidMessage;
681                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
682                 case 3: return LDKSecp256k1Error_InvalidSignature;
683                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
684                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
685                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
686                 case 7: return LDKSecp256k1Error_InvalidTweak;
687                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
688                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
689                 case 10: return LDKSecp256k1Error_InvalidParityValue;
690         }
691         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
692         abort(); // Unreachable, but will let the compiler know we don't return here
693 }
694 static jclass Secp256k1Error_class = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
700 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
701 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
702 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
703 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
704 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
705 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
706 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
707         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
708         CHECK(Secp256k1Error_class != NULL);
709         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
717         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
719         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
721         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
722         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
723         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
724         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
725         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
726         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
727         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
728         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
729         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
730         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
731 }
732 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
733         switch (val) {
734                 case LDKSecp256k1Error_IncorrectSignature:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
736                 case LDKSecp256k1Error_InvalidMessage:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
738                 case LDKSecp256k1Error_InvalidPublicKey:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
740                 case LDKSecp256k1Error_InvalidSignature:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
742                 case LDKSecp256k1Error_InvalidSecretKey:
743                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
744                 case LDKSecp256k1Error_InvalidSharedSecret:
745                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
746                 case LDKSecp256k1Error_InvalidRecoveryId:
747                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
748                 case LDKSecp256k1Error_InvalidTweak:
749                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
750                 case LDKSecp256k1Error_NotEnoughMemory:
751                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
752                 case LDKSecp256k1Error_InvalidPublicKeySum:
753                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
754                 case LDKSecp256k1Error_InvalidParityValue:
755                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
756                 default: abort();
757         }
758 }
759
760 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
761         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
762         if (UNLIKELY((*env)->ExceptionCheck(env))) {
763                 (*env)->ExceptionDescribe(env);
764                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
765         }
766         switch (ord) {
767                 case 0: return LDKSemanticError_NoPaymentHash;
768                 case 1: return LDKSemanticError_MultiplePaymentHashes;
769                 case 2: return LDKSemanticError_NoDescription;
770                 case 3: return LDKSemanticError_MultipleDescriptions;
771                 case 4: return LDKSemanticError_NoPaymentSecret;
772                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
773                 case 6: return LDKSemanticError_InvalidFeatures;
774                 case 7: return LDKSemanticError_InvalidRecoveryId;
775                 case 8: return LDKSemanticError_InvalidSignature;
776                 case 9: return LDKSemanticError_ImpreciseAmount;
777         }
778         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
779         abort(); // Unreachable, but will let the compiler know we don't return here
780 }
781 static jclass SemanticError_class = NULL;
782 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
783 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
784 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
785 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
786 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
787 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
788 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
789 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
790 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
791 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
792 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
793         SemanticError_class = (*env)->NewGlobalRef(env, clz);
794         CHECK(SemanticError_class != NULL);
795         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
797         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
799         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
801         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
802         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
803         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
804         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
805         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
806         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
807         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
808         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
809         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
810         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
811         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
812         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
813         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
814         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
815 }
816 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
817         switch (val) {
818                 case LDKSemanticError_NoPaymentHash:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
820                 case LDKSemanticError_MultiplePaymentHashes:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
822                 case LDKSemanticError_NoDescription:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
824                 case LDKSemanticError_MultipleDescriptions:
825                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
826                 case LDKSemanticError_NoPaymentSecret:
827                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
828                 case LDKSemanticError_MultiplePaymentSecrets:
829                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
830                 case LDKSemanticError_InvalidFeatures:
831                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
832                 case LDKSemanticError_InvalidRecoveryId:
833                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
834                 case LDKSemanticError_InvalidSignature:
835                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
836                 case LDKSemanticError_ImpreciseAmount:
837                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
838                 default: abort();
839         }
840 }
841
842 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
843         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
844         if (UNLIKELY((*env)->ExceptionCheck(env))) {
845                 (*env)->ExceptionDescribe(env);
846                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
847         }
848         switch (ord) {
849                 case 0: return LDKSiPrefix_Milli;
850                 case 1: return LDKSiPrefix_Micro;
851                 case 2: return LDKSiPrefix_Nano;
852                 case 3: return LDKSiPrefix_Pico;
853         }
854         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
855         abort(); // Unreachable, but will let the compiler know we don't return here
856 }
857 static jclass SiPrefix_class = NULL;
858 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
859 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
860 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
861 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
862 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
863         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
864         CHECK(SiPrefix_class != NULL);
865         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
866         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
867         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
868         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
869         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
870         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
871         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
872         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
873 }
874 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
875         switch (val) {
876                 case LDKSiPrefix_Milli:
877                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
878                 case LDKSiPrefix_Micro:
879                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
880                 case LDKSiPrefix_Nano:
881                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
882                 case LDKSiPrefix_Pico:
883                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
884                 default: abort();
885         }
886 }
887
888 static jclass LDKBech32Error_MissingSeparator_class = NULL;
889 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
890 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
891 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
892 static jclass LDKBech32Error_InvalidLength_class = NULL;
893 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
894 static jclass LDKBech32Error_InvalidChar_class = NULL;
895 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
896 static jclass LDKBech32Error_InvalidData_class = NULL;
897 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
898 static jclass LDKBech32Error_InvalidPadding_class = NULL;
899 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
900 static jclass LDKBech32Error_MixedCase_class = NULL;
901 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
903         LDKBech32Error_MissingSeparator_class =
904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
905         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
906         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
907         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
908         LDKBech32Error_InvalidChecksum_class =
909                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
910         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
911         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
912         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
913         LDKBech32Error_InvalidLength_class =
914                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
915         CHECK(LDKBech32Error_InvalidLength_class != NULL);
916         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
917         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
918         LDKBech32Error_InvalidChar_class =
919                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
920         CHECK(LDKBech32Error_InvalidChar_class != NULL);
921         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
922         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
923         LDKBech32Error_InvalidData_class =
924                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
925         CHECK(LDKBech32Error_InvalidData_class != NULL);
926         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
927         CHECK(LDKBech32Error_InvalidData_meth != NULL);
928         LDKBech32Error_InvalidPadding_class =
929                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
930         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
931         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
932         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
933         LDKBech32Error_MixedCase_class =
934                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
935         CHECK(LDKBech32Error_MixedCase_class != NULL);
936         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
937         CHECK(LDKBech32Error_MixedCase_meth != NULL);
938 }
939 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
940         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
941         switch(obj->tag) {
942                 case LDKBech32Error_MissingSeparator: {
943                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
944                 }
945                 case LDKBech32Error_InvalidChecksum: {
946                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
947                 }
948                 case LDKBech32Error_InvalidLength: {
949                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
950                 }
951                 case LDKBech32Error_InvalidChar: {
952                         int32_t invalid_char_conv = obj->invalid_char;
953                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
954                 }
955                 case LDKBech32Error_InvalidData: {
956                         int8_t invalid_data_conv = obj->invalid_data;
957                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
958                 }
959                 case LDKBech32Error_InvalidPadding: {
960                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
961                 }
962                 case LDKBech32Error_MixedCase: {
963                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
964                 }
965                 default: abort();
966         }
967 }
968 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
969         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
970         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
971         return ret;
972 }
973 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) {
974         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
975         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
976         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
977         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
978         CVec_u8Z_free(ret_var);
979         return ret_arr;
980 }
981
982 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) {
983         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
984         int64_t ret_conv = TxOut_get_value(thing_conv);
985         return ret_conv;
986 }
987
988 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
989 CHECK(owner->result_ok);
990         return *owner->contents.result;
991 }
992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
993         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
994         CResult_NoneNoneZ_get_ok(owner_conv);
995 }
996
997 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
998 CHECK(!owner->result_ok);
999         return *owner->contents.err;
1000 }
1001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1002         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1003         CResult_NoneNoneZ_get_err(owner_conv);
1004 }
1005
1006 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1007 CHECK(owner->result_ok);
1008         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
1009 }
1010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1011         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1012         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1013         int64_t ret_ref = 0;
1014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1017         ret_ref = (uintptr_t)ret_var.inner;
1018         if (ret_var.is_owned) {
1019                 ret_ref |= 1;
1020         }
1021         return ret_ref;
1022 }
1023
1024 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1025 CHECK(!owner->result_ok);
1026         return DecodeError_clone(&*owner->contents.err);
1027 }
1028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1029         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1030         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1031         int64_t ret_ref = 0;
1032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1035         ret_ref = (uintptr_t)ret_var.inner;
1036         if (ret_var.is_owned) {
1037                 ret_ref |= 1;
1038         }
1039         return ret_ref;
1040 }
1041
1042 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1043 CHECK(owner->result_ok);
1044         return *owner->contents.result;
1045 }
1046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1047         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1048         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1050         return ret_arr;
1051 }
1052
1053 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1054 CHECK(!owner->result_ok);
1055         return *owner->contents.err;
1056 }
1057 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1058         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1059         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1060         return ret_conv;
1061 }
1062
1063 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1064 CHECK(owner->result_ok);
1065         return *owner->contents.result;
1066 }
1067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1068         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1069         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1070         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1071         return ret_arr;
1072 }
1073
1074 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1075 CHECK(!owner->result_ok);
1076         return *owner->contents.err;
1077 }
1078 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1079         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1080         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1081         return ret_conv;
1082 }
1083
1084 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1085 CHECK(owner->result_ok);
1086         return TxCreationKeys_clone(&*owner->contents.result);
1087 }
1088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1089         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1090         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1091         int64_t ret_ref = 0;
1092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1095         ret_ref = (uintptr_t)ret_var.inner;
1096         if (ret_var.is_owned) {
1097                 ret_ref |= 1;
1098         }
1099         return ret_ref;
1100 }
1101
1102 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1103 CHECK(!owner->result_ok);
1104         return DecodeError_clone(&*owner->contents.err);
1105 }
1106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1107         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1108         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1109         int64_t ret_ref = 0;
1110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1113         ret_ref = (uintptr_t)ret_var.inner;
1114         if (ret_var.is_owned) {
1115                 ret_ref |= 1;
1116         }
1117         return ret_ref;
1118 }
1119
1120 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1121 CHECK(owner->result_ok);
1122         return ChannelPublicKeys_clone(&*owner->contents.result);
1123 }
1124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1125         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1126         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1127         int64_t ret_ref = 0;
1128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1131         ret_ref = (uintptr_t)ret_var.inner;
1132         if (ret_var.is_owned) {
1133                 ret_ref |= 1;
1134         }
1135         return ret_ref;
1136 }
1137
1138 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1139 CHECK(!owner->result_ok);
1140         return DecodeError_clone(&*owner->contents.err);
1141 }
1142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1143         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1144         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1145         int64_t ret_ref = 0;
1146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1149         ret_ref = (uintptr_t)ret_var.inner;
1150         if (ret_var.is_owned) {
1151                 ret_ref |= 1;
1152         }
1153         return ret_ref;
1154 }
1155
1156 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1157 CHECK(owner->result_ok);
1158         return TxCreationKeys_clone(&*owner->contents.result);
1159 }
1160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1161         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1162         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1163         int64_t ret_ref = 0;
1164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1167         ret_ref = (uintptr_t)ret_var.inner;
1168         if (ret_var.is_owned) {
1169                 ret_ref |= 1;
1170         }
1171         return ret_ref;
1172 }
1173
1174 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1175 CHECK(!owner->result_ok);
1176         return *owner->contents.err;
1177 }
1178 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1179         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1180         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1181         return ret_conv;
1182 }
1183
1184 static jclass LDKCOption_u32Z_Some_class = NULL;
1185 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1186 static jclass LDKCOption_u32Z_None_class = NULL;
1187 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1189         LDKCOption_u32Z_Some_class =
1190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1191         CHECK(LDKCOption_u32Z_Some_class != NULL);
1192         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1193         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1194         LDKCOption_u32Z_None_class =
1195                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1196         CHECK(LDKCOption_u32Z_None_class != NULL);
1197         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1198         CHECK(LDKCOption_u32Z_None_meth != NULL);
1199 }
1200 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1201         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1202         switch(obj->tag) {
1203                 case LDKCOption_u32Z_Some: {
1204                         int32_t some_conv = obj->some;
1205                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1206                 }
1207                 case LDKCOption_u32Z_None: {
1208                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1209                 }
1210                 default: abort();
1211         }
1212 }
1213 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1214 CHECK(owner->result_ok);
1215         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1216 }
1217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1218         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1219         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1220         int64_t ret_ref = 0;
1221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1224         ret_ref = (uintptr_t)ret_var.inner;
1225         if (ret_var.is_owned) {
1226                 ret_ref |= 1;
1227         }
1228         return ret_ref;
1229 }
1230
1231 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1232 CHECK(!owner->result_ok);
1233         return DecodeError_clone(&*owner->contents.err);
1234 }
1235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1236         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1237         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1238         int64_t ret_ref = 0;
1239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1242         ret_ref = (uintptr_t)ret_var.inner;
1243         if (ret_var.is_owned) {
1244                 ret_ref |= 1;
1245         }
1246         return ret_ref;
1247 }
1248
1249 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1250 CHECK(owner->result_ok);
1251         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1252 }
1253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1254         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1255         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1256         int64_t ret_ref = 0;
1257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1260         ret_ref = (uintptr_t)ret_var.inner;
1261         if (ret_var.is_owned) {
1262                 ret_ref |= 1;
1263         }
1264         return ret_ref;
1265 }
1266
1267 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1268 CHECK(!owner->result_ok);
1269         return DecodeError_clone(&*owner->contents.err);
1270 }
1271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1272         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1273         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1274         int64_t ret_ref = 0;
1275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1278         ret_ref = (uintptr_t)ret_var.inner;
1279         if (ret_var.is_owned) {
1280                 ret_ref |= 1;
1281         }
1282         return ret_ref;
1283 }
1284
1285 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1286 CHECK(owner->result_ok);
1287         return ChannelTransactionParameters_clone(&*owner->contents.result);
1288 }
1289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1290         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1291         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1292         int64_t ret_ref = 0;
1293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1296         ret_ref = (uintptr_t)ret_var.inner;
1297         if (ret_var.is_owned) {
1298                 ret_ref |= 1;
1299         }
1300         return ret_ref;
1301 }
1302
1303 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1304 CHECK(!owner->result_ok);
1305         return DecodeError_clone(&*owner->contents.err);
1306 }
1307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1308         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1309         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1310         int64_t ret_ref = 0;
1311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1314         ret_ref = (uintptr_t)ret_var.inner;
1315         if (ret_var.is_owned) {
1316                 ret_ref |= 1;
1317         }
1318         return ret_ref;
1319 }
1320
1321 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1322 CHECK(owner->result_ok);
1323         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1324 }
1325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1326         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1327         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1328         int64_t ret_ref = 0;
1329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1332         ret_ref = (uintptr_t)ret_var.inner;
1333         if (ret_var.is_owned) {
1334                 ret_ref |= 1;
1335         }
1336         return ret_ref;
1337 }
1338
1339 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1340 CHECK(!owner->result_ok);
1341         return DecodeError_clone(&*owner->contents.err);
1342 }
1343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1344         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1345         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1346         int64_t ret_ref = 0;
1347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1350         ret_ref = (uintptr_t)ret_var.inner;
1351         if (ret_var.is_owned) {
1352                 ret_ref |= 1;
1353         }
1354         return ret_ref;
1355 }
1356
1357 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1358 CHECK(owner->result_ok);
1359         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1360 }
1361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1362         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1363         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1364         int64_t ret_ref = 0;
1365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1368         ret_ref = (uintptr_t)ret_var.inner;
1369         if (ret_var.is_owned) {
1370                 ret_ref |= 1;
1371         }
1372         return ret_ref;
1373 }
1374
1375 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1376 CHECK(!owner->result_ok);
1377         return DecodeError_clone(&*owner->contents.err);
1378 }
1379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1380         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1381         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1382         int64_t ret_ref = 0;
1383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1386         ret_ref = (uintptr_t)ret_var.inner;
1387         if (ret_var.is_owned) {
1388                 ret_ref |= 1;
1389         }
1390         return ret_ref;
1391 }
1392
1393 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1394 CHECK(owner->result_ok);
1395         return &*owner->contents.result;
1396 }
1397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1398         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1399         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1400         int64_t ret_ref = 0;
1401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1404         ret_ref = (uintptr_t)ret_var.inner & ~1;
1405         return ret_ref;
1406 }
1407
1408 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1409 CHECK(!owner->result_ok);
1410         return *owner->contents.err;
1411 }
1412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1413         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1414         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1415 }
1416
1417 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1418 CHECK(owner->result_ok);
1419         return CommitmentTransaction_clone(&*owner->contents.result);
1420 }
1421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1422         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1423         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1424         int64_t ret_ref = 0;
1425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1428         ret_ref = (uintptr_t)ret_var.inner;
1429         if (ret_var.is_owned) {
1430                 ret_ref |= 1;
1431         }
1432         return ret_ref;
1433 }
1434
1435 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1436 CHECK(!owner->result_ok);
1437         return DecodeError_clone(&*owner->contents.err);
1438 }
1439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1440         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1441         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1442         int64_t ret_ref = 0;
1443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1446         ret_ref = (uintptr_t)ret_var.inner;
1447         if (ret_var.is_owned) {
1448                 ret_ref |= 1;
1449         }
1450         return ret_ref;
1451 }
1452
1453 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1454 CHECK(owner->result_ok);
1455         return &*owner->contents.result;
1456 }
1457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1458         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1459         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1460         int64_t ret_ref = 0;
1461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1464         ret_ref = (uintptr_t)ret_var.inner & ~1;
1465         return ret_ref;
1466 }
1467
1468 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1469 CHECK(!owner->result_ok);
1470         return *owner->contents.err;
1471 }
1472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1473         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1474         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1475 }
1476
1477 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1478 CHECK(owner->result_ok);
1479         return *owner->contents.result;
1480 }
1481 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1482         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1483         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1484         jobjectArray ret_arr = NULL;
1485         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1486         ;
1487         for (size_t i = 0; i < ret_var.datalen; i++) {
1488                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1489                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1490                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1491         }
1492         
1493         return ret_arr;
1494 }
1495
1496 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1497 CHECK(!owner->result_ok);
1498         return *owner->contents.err;
1499 }
1500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1501         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1502         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1503 }
1504
1505 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1506 CHECK(owner->result_ok);
1507         return ShutdownScript_clone(&*owner->contents.result);
1508 }
1509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1510         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1511         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1512         int64_t ret_ref = 0;
1513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1516         ret_ref = (uintptr_t)ret_var.inner;
1517         if (ret_var.is_owned) {
1518                 ret_ref |= 1;
1519         }
1520         return ret_ref;
1521 }
1522
1523 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1524 CHECK(!owner->result_ok);
1525         return DecodeError_clone(&*owner->contents.err);
1526 }
1527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1528         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1529         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1530         int64_t ret_ref = 0;
1531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1534         ret_ref = (uintptr_t)ret_var.inner;
1535         if (ret_var.is_owned) {
1536                 ret_ref |= 1;
1537         }
1538         return ret_ref;
1539 }
1540
1541 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1542 CHECK(owner->result_ok);
1543         return ShutdownScript_clone(&*owner->contents.result);
1544 }
1545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1546         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1547         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1548         int64_t ret_ref = 0;
1549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1552         ret_ref = (uintptr_t)ret_var.inner;
1553         if (ret_var.is_owned) {
1554                 ret_ref |= 1;
1555         }
1556         return ret_ref;
1557 }
1558
1559 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1560 CHECK(!owner->result_ok);
1561         return InvalidShutdownScript_clone(&*owner->contents.err);
1562 }
1563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1564         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1565         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1566         int64_t ret_ref = 0;
1567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1570         ret_ref = (uintptr_t)ret_var.inner;
1571         if (ret_var.is_owned) {
1572                 ret_ref |= 1;
1573         }
1574         return ret_ref;
1575 }
1576
1577 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1578 CHECK(owner->result_ok);
1579         return *owner->contents.result;
1580 }
1581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1582         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1583         CResult_NoneErrorZ_get_ok(owner_conv);
1584 }
1585
1586 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1587 CHECK(!owner->result_ok);
1588         return *owner->contents.err;
1589 }
1590 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1591         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1592         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1593         return ret_conv;
1594 }
1595
1596 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1597 CHECK(owner->result_ok);
1598         return RouteHop_clone(&*owner->contents.result);
1599 }
1600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1601         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1602         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1603         int64_t ret_ref = 0;
1604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1607         ret_ref = (uintptr_t)ret_var.inner;
1608         if (ret_var.is_owned) {
1609                 ret_ref |= 1;
1610         }
1611         return ret_ref;
1612 }
1613
1614 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1615 CHECK(!owner->result_ok);
1616         return DecodeError_clone(&*owner->contents.err);
1617 }
1618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1619         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1620         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1621         int64_t ret_ref = 0;
1622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1625         ret_ref = (uintptr_t)ret_var.inner;
1626         if (ret_var.is_owned) {
1627                 ret_ref |= 1;
1628         }
1629         return ret_ref;
1630 }
1631
1632 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1633         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1634         for (size_t i = 0; i < ret.datalen; i++) {
1635                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1636         }
1637         return ret;
1638 }
1639 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1640         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1641         for (size_t i = 0; i < ret.datalen; i++) {
1642                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1643         }
1644         return ret;
1645 }
1646 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1647 CHECK(owner->result_ok);
1648         return Route_clone(&*owner->contents.result);
1649 }
1650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1651         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1652         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1653         int64_t ret_ref = 0;
1654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1657         ret_ref = (uintptr_t)ret_var.inner;
1658         if (ret_var.is_owned) {
1659                 ret_ref |= 1;
1660         }
1661         return ret_ref;
1662 }
1663
1664 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1665 CHECK(!owner->result_ok);
1666         return DecodeError_clone(&*owner->contents.err);
1667 }
1668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1669         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1670         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1671         int64_t ret_ref = 0;
1672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1675         ret_ref = (uintptr_t)ret_var.inner;
1676         if (ret_var.is_owned) {
1677                 ret_ref |= 1;
1678         }
1679         return ret_ref;
1680 }
1681
1682 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1683 CHECK(owner->result_ok);
1684         return RouteParameters_clone(&*owner->contents.result);
1685 }
1686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1687         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1688         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1689         int64_t ret_ref = 0;
1690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1693         ret_ref = (uintptr_t)ret_var.inner;
1694         if (ret_var.is_owned) {
1695                 ret_ref |= 1;
1696         }
1697         return ret_ref;
1698 }
1699
1700 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1701 CHECK(!owner->result_ok);
1702         return DecodeError_clone(&*owner->contents.err);
1703 }
1704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1705         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1706         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1707         int64_t ret_ref = 0;
1708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1711         ret_ref = (uintptr_t)ret_var.inner;
1712         if (ret_var.is_owned) {
1713                 ret_ref |= 1;
1714         }
1715         return ret_ref;
1716 }
1717
1718 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1719         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1720         for (size_t i = 0; i < ret.datalen; i++) {
1721                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1722         }
1723         return ret;
1724 }
1725 static jclass LDKCOption_u64Z_Some_class = NULL;
1726 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1727 static jclass LDKCOption_u64Z_None_class = NULL;
1728 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1730         LDKCOption_u64Z_Some_class =
1731                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1732         CHECK(LDKCOption_u64Z_Some_class != NULL);
1733         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1734         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1735         LDKCOption_u64Z_None_class =
1736                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1737         CHECK(LDKCOption_u64Z_None_class != NULL);
1738         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1739         CHECK(LDKCOption_u64Z_None_meth != NULL);
1740 }
1741 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1742         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1743         switch(obj->tag) {
1744                 case LDKCOption_u64Z_Some: {
1745                         int64_t some_conv = obj->some;
1746                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1747                 }
1748                 case LDKCOption_u64Z_None: {
1749                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1750                 }
1751                 default: abort();
1752         }
1753 }
1754 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1755         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1756         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1757         return ret;
1758 }
1759 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1760 CHECK(owner->result_ok);
1761         return PaymentParameters_clone(&*owner->contents.result);
1762 }
1763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1764         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1765         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1766         int64_t ret_ref = 0;
1767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1770         ret_ref = (uintptr_t)ret_var.inner;
1771         if (ret_var.is_owned) {
1772                 ret_ref |= 1;
1773         }
1774         return ret_ref;
1775 }
1776
1777 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1778 CHECK(!owner->result_ok);
1779         return DecodeError_clone(&*owner->contents.err);
1780 }
1781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1782         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1783         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1784         int64_t ret_ref = 0;
1785         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1786         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1788         ret_ref = (uintptr_t)ret_var.inner;
1789         if (ret_var.is_owned) {
1790                 ret_ref |= 1;
1791         }
1792         return ret_ref;
1793 }
1794
1795 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1796         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1797         for (size_t i = 0; i < ret.datalen; i++) {
1798                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1799         }
1800         return ret;
1801 }
1802 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1803 CHECK(owner->result_ok);
1804         return RouteHint_clone(&*owner->contents.result);
1805 }
1806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1807         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1808         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1809         int64_t ret_ref = 0;
1810         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1811         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1813         ret_ref = (uintptr_t)ret_var.inner;
1814         if (ret_var.is_owned) {
1815                 ret_ref |= 1;
1816         }
1817         return ret_ref;
1818 }
1819
1820 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1821 CHECK(!owner->result_ok);
1822         return DecodeError_clone(&*owner->contents.err);
1823 }
1824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1825         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1826         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1827         int64_t ret_ref = 0;
1828         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1829         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1831         ret_ref = (uintptr_t)ret_var.inner;
1832         if (ret_var.is_owned) {
1833                 ret_ref |= 1;
1834         }
1835         return ret_ref;
1836 }
1837
1838 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1839 CHECK(owner->result_ok);
1840         return RouteHintHop_clone(&*owner->contents.result);
1841 }
1842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1843         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1844         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1845         int64_t ret_ref = 0;
1846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1849         ret_ref = (uintptr_t)ret_var.inner;
1850         if (ret_var.is_owned) {
1851                 ret_ref |= 1;
1852         }
1853         return ret_ref;
1854 }
1855
1856 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1857 CHECK(!owner->result_ok);
1858         return DecodeError_clone(&*owner->contents.err);
1859 }
1860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1861         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1862         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1863         int64_t ret_ref = 0;
1864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1867         ret_ref = (uintptr_t)ret_var.inner;
1868         if (ret_var.is_owned) {
1869                 ret_ref |= 1;
1870         }
1871         return ret_ref;
1872 }
1873
1874 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1875         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1876         for (size_t i = 0; i < ret.datalen; i++) {
1877                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1878         }
1879         return ret;
1880 }
1881 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1882 CHECK(owner->result_ok);
1883         return Route_clone(&*owner->contents.result);
1884 }
1885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1886         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1887         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1888         int64_t ret_ref = 0;
1889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1892         ret_ref = (uintptr_t)ret_var.inner;
1893         if (ret_var.is_owned) {
1894                 ret_ref |= 1;
1895         }
1896         return ret_ref;
1897 }
1898
1899 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1900 CHECK(!owner->result_ok);
1901         return LightningError_clone(&*owner->contents.err);
1902 }
1903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1904         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1905         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1906         int64_t ret_ref = 0;
1907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1910         ret_ref = (uintptr_t)ret_var.inner;
1911         if (ret_var.is_owned) {
1912                 ret_ref |= 1;
1913         }
1914         return ret_ref;
1915 }
1916
1917 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1918 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1919 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1920 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1922         LDKPaymentPurpose_InvoicePayment_class =
1923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
1924         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1925         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
1926         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1927         LDKPaymentPurpose_SpontaneousPayment_class =
1928                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
1929         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1930         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1931         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1932 }
1933 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1934         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1935         switch(obj->tag) {
1936                 case LDKPaymentPurpose_InvoicePayment: {
1937                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1938                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1939                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1940                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1941                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
1942                 }
1943                 case LDKPaymentPurpose_SpontaneousPayment: {
1944                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1945                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1946                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1947                 }
1948                 default: abort();
1949         }
1950 }
1951 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1952 CHECK(owner->result_ok);
1953         return PaymentPurpose_clone(&*owner->contents.result);
1954 }
1955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1956         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1957         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1958         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1959         int64_t ret_ref = (uintptr_t)ret_copy;
1960         return ret_ref;
1961 }
1962
1963 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1964 CHECK(!owner->result_ok);
1965         return DecodeError_clone(&*owner->contents.err);
1966 }
1967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1968         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1969         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1970         int64_t ret_ref = 0;
1971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1974         ret_ref = (uintptr_t)ret_var.inner;
1975         if (ret_var.is_owned) {
1976                 ret_ref |= 1;
1977         }
1978         return ret_ref;
1979 }
1980
1981 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1982 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1983 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1984 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1985 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1986 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1987 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1988 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1989 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
1990 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
1991 static jclass LDKClosureReason_ProcessingError_class = NULL;
1992 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1993 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1994 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1995 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1996 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1998         LDKClosureReason_CounterpartyForceClosed_class =
1999                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2000         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2001         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2002         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2003         LDKClosureReason_HolderForceClosed_class =
2004                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2005         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2006         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2007         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2008         LDKClosureReason_CooperativeClosure_class =
2009                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2010         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2011         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2012         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2013         LDKClosureReason_CommitmentTxConfirmed_class =
2014                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2015         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2016         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2017         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2018         LDKClosureReason_FundingTimedOut_class =
2019                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2020         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2021         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2022         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2023         LDKClosureReason_ProcessingError_class =
2024                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2025         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2026         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2027         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2028         LDKClosureReason_DisconnectedPeer_class =
2029                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2030         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2031         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2032         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2033         LDKClosureReason_OutdatedChannelManager_class =
2034                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2035         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2036         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2037         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2038 }
2039 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2040         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2041         switch(obj->tag) {
2042                 case LDKClosureReason_CounterpartyForceClosed: {
2043                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2044                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2045                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2046                 }
2047                 case LDKClosureReason_HolderForceClosed: {
2048                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2049                 }
2050                 case LDKClosureReason_CooperativeClosure: {
2051                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2052                 }
2053                 case LDKClosureReason_CommitmentTxConfirmed: {
2054                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2055                 }
2056                 case LDKClosureReason_FundingTimedOut: {
2057                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2058                 }
2059                 case LDKClosureReason_ProcessingError: {
2060                         LDKStr err_str = obj->processing_error.err;
2061                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2062                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2063                 }
2064                 case LDKClosureReason_DisconnectedPeer: {
2065                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2066                 }
2067                 case LDKClosureReason_OutdatedChannelManager: {
2068                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2069                 }
2070                 default: abort();
2071         }
2072 }
2073 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2074 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2075 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2076 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2078         LDKCOption_ClosureReasonZ_Some_class =
2079                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2080         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2081         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2082         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2083         LDKCOption_ClosureReasonZ_None_class =
2084                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2085         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2086         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2087         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2088 }
2089 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2090         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2091         switch(obj->tag) {
2092                 case LDKCOption_ClosureReasonZ_Some: {
2093                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2094                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2095                 }
2096                 case LDKCOption_ClosureReasonZ_None: {
2097                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2098                 }
2099                 default: abort();
2100         }
2101 }
2102 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2103 CHECK(owner->result_ok);
2104         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2105 }
2106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2107         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2108         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2109         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2110         int64_t ret_ref = (uintptr_t)ret_copy;
2111         return ret_ref;
2112 }
2113
2114 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2115 CHECK(!owner->result_ok);
2116         return DecodeError_clone(&*owner->contents.err);
2117 }
2118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2119         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2120         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2121         int64_t ret_ref = 0;
2122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2125         ret_ref = (uintptr_t)ret_var.inner;
2126         if (ret_var.is_owned) {
2127                 ret_ref |= 1;
2128         }
2129         return ret_ref;
2130 }
2131
2132 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
2133 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
2134 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
2135 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
2136 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
2137 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
2138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
2139         LDKHTLCDestination_NextHopChannel_class =
2140                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
2141         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
2142         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
2143         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
2144         LDKHTLCDestination_UnknownNextHop_class =
2145                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
2146         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
2147         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
2148         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
2149         LDKHTLCDestination_FailedPayment_class =
2150                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
2151         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
2152         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
2153         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
2154 }
2155 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2156         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
2157         switch(obj->tag) {
2158                 case LDKHTLCDestination_NextHopChannel: {
2159                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2160                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
2161                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2162                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
2163                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
2164                 }
2165                 case LDKHTLCDestination_UnknownNextHop: {
2166                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
2167                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
2168                 }
2169                 case LDKHTLCDestination_FailedPayment: {
2170                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2171                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
2172                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
2173                 }
2174                 default: abort();
2175         }
2176 }
2177 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
2178 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
2179 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
2180 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
2181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
2182         LDKCOption_HTLCDestinationZ_Some_class =
2183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
2184         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
2185         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
2186         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
2187         LDKCOption_HTLCDestinationZ_None_class =
2188                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
2189         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
2190         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
2191         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
2192 }
2193 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2194         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)(ptr & ~1);
2195         switch(obj->tag) {
2196                 case LDKCOption_HTLCDestinationZ_Some: {
2197                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2198                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
2199                 }
2200                 case LDKCOption_HTLCDestinationZ_None: {
2201                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
2202                 }
2203                 default: abort();
2204         }
2205 }
2206 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2207 CHECK(owner->result_ok);
2208         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
2209 }
2210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2211         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
2212         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
2213         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
2214         int64_t ret_ref = (uintptr_t)ret_copy;
2215         return ret_ref;
2216 }
2217
2218 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2219 CHECK(!owner->result_ok);
2220         return DecodeError_clone(&*owner->contents.err);
2221 }
2222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2223         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
2224         LDKDecodeError ret_var = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
2225         int64_t ret_ref = 0;
2226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2229         ret_ref = (uintptr_t)ret_var.inner;
2230         if (ret_var.is_owned) {
2231                 ret_ref |= 1;
2232         }
2233         return ret_ref;
2234 }
2235
2236 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2237 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2238 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2239 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2240 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2241 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2243         LDKNetworkUpdate_ChannelUpdateMessage_class =
2244                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2245         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2246         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2247         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2248         LDKNetworkUpdate_ChannelFailure_class =
2249                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2250         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2251         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2252         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2253         LDKNetworkUpdate_NodeFailure_class =
2254                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2255         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2256         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2257         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2258 }
2259 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2260         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2261         switch(obj->tag) {
2262                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2263                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2264                         int64_t msg_ref = 0;
2265                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2266                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2267                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2268                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2269                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2270                 }
2271                 case LDKNetworkUpdate_ChannelFailure: {
2272                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2273                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2274                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2275                 }
2276                 case LDKNetworkUpdate_NodeFailure: {
2277                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2278                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2279                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2280                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2281                 }
2282                 default: abort();
2283         }
2284 }
2285 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2286 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2287 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2288 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2290         LDKCOption_NetworkUpdateZ_Some_class =
2291                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2292         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2293         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2294         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2295         LDKCOption_NetworkUpdateZ_None_class =
2296                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2297         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2298         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2299         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2300 }
2301 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2302         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2303         switch(obj->tag) {
2304                 case LDKCOption_NetworkUpdateZ_Some: {
2305                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2306                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2307                 }
2308                 case LDKCOption_NetworkUpdateZ_None: {
2309                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2310                 }
2311                 default: abort();
2312         }
2313 }
2314 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2315 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2316 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2317 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2318 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2319 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2321         LDKSpendableOutputDescriptor_StaticOutput_class =
2322                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2323         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2324         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2325         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2326         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2327                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2328         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2329         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2330         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2331         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2333         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2334         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2335         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2336 }
2337 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2338         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2339         switch(obj->tag) {
2340                 case LDKSpendableOutputDescriptor_StaticOutput: {
2341                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2342                         int64_t outpoint_ref = 0;
2343                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2344                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2345                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2346                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2347                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2348                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2349                 }
2350                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2351                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2352                         int64_t delayed_payment_output_ref = 0;
2353                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2354                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2355                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2356                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2357                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2358                 }
2359                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2360                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2361                         int64_t static_payment_output_ref = 0;
2362                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2363                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2364                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2365                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2366                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2367                 }
2368                 default: abort();
2369         }
2370 }
2371 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2372         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2373         for (size_t i = 0; i < ret.datalen; i++) {
2374                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2375         }
2376         return ret;
2377 }
2378 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2379 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2380 static jclass LDKEvent_PaymentReceived_class = NULL;
2381 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2382 static jclass LDKEvent_PaymentClaimed_class = NULL;
2383 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
2384 static jclass LDKEvent_PaymentSent_class = NULL;
2385 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2386 static jclass LDKEvent_PaymentFailed_class = NULL;
2387 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2388 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2389 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2390 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2391 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2392 static jclass LDKEvent_ProbeSuccessful_class = NULL;
2393 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
2394 static jclass LDKEvent_ProbeFailed_class = NULL;
2395 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
2396 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2397 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2398 static jclass LDKEvent_SpendableOutputs_class = NULL;
2399 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2400 static jclass LDKEvent_PaymentForwarded_class = NULL;
2401 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2402 static jclass LDKEvent_ChannelClosed_class = NULL;
2403 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2404 static jclass LDKEvent_DiscardFunding_class = NULL;
2405 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2406 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2407 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2408 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
2409 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
2410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2411         LDKEvent_FundingGenerationReady_class =
2412                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2413         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2414         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
2415         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2416         LDKEvent_PaymentReceived_class =
2417                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2418         CHECK(LDKEvent_PaymentReceived_class != NULL);
2419         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2420         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2421         LDKEvent_PaymentClaimed_class =
2422                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
2423         CHECK(LDKEvent_PaymentClaimed_class != NULL);
2424         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
2425         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
2426         LDKEvent_PaymentSent_class =
2427                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2428         CHECK(LDKEvent_PaymentSent_class != NULL);
2429         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2430         CHECK(LDKEvent_PaymentSent_meth != NULL);
2431         LDKEvent_PaymentFailed_class =
2432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2433         CHECK(LDKEvent_PaymentFailed_class != NULL);
2434         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2435         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2436         LDKEvent_PaymentPathSuccessful_class =
2437                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2438         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2439         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2440         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2441         LDKEvent_PaymentPathFailed_class =
2442                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2443         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2444         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2445         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2446         LDKEvent_ProbeSuccessful_class =
2447                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
2448         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
2449         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
2450         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
2451         LDKEvent_ProbeFailed_class =
2452                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
2453         CHECK(LDKEvent_ProbeFailed_class != NULL);
2454         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
2455         CHECK(LDKEvent_ProbeFailed_meth != NULL);
2456         LDKEvent_PendingHTLCsForwardable_class =
2457                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2458         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2459         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2460         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2461         LDKEvent_SpendableOutputs_class =
2462                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2463         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2464         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2465         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2466         LDKEvent_PaymentForwarded_class =
2467                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2468         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2469         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
2470         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2471         LDKEvent_ChannelClosed_class =
2472                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2473         CHECK(LDKEvent_ChannelClosed_class != NULL);
2474         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2475         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2476         LDKEvent_DiscardFunding_class =
2477                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2478         CHECK(LDKEvent_DiscardFunding_class != NULL);
2479         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2480         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2481         LDKEvent_OpenChannelRequest_class =
2482                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2483         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2484         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2485         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2486         LDKEvent_HTLCHandlingFailed_class =
2487                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
2488         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
2489         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
2490         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
2491 }
2492 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2493         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2494         switch(obj->tag) {
2495                 case LDKEvent_FundingGenerationReady: {
2496                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2497                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2498                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2499                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
2500                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
2501                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2502                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2503                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2504                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
2505                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, counterparty_node_id_arr, channel_value_satoshis_conv, output_script_arr, user_channel_id_conv);
2506                 }
2507                 case LDKEvent_PaymentReceived: {
2508                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2509                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2510                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
2511                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2512                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2513                 }
2514                 case LDKEvent_PaymentClaimed: {
2515                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2516                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
2517                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
2518                         int64_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
2519                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2520                 }
2521                 case LDKEvent_PaymentSent: {
2522                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2523                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2524                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2525                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2526                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2527                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2528                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2529                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2530                 }
2531                 case LDKEvent_PaymentFailed: {
2532                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2533                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2534                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2535                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2536                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2537                 }
2538                 case LDKEvent_PaymentPathSuccessful: {
2539                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2540                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2541                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2542                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2543                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2544                         int64_tArray path_arr = NULL;
2545                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2546                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2547                         for (size_t k = 0; k < path_var.datalen; k++) {
2548                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2549                                 int64_t path_conv_10_ref = 0;
2550                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2551                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2552                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2553                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2554                                 path_arr_ptr[k] = path_conv_10_ref;
2555                         }
2556                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2557                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2558                 }
2559                 case LDKEvent_PaymentPathFailed: {
2560                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2561                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_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_path_failed.payment_hash.data);
2564                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
2565                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2566                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
2567                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2568                         int64_tArray path_arr = NULL;
2569                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2570                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2571                         for (size_t k = 0; k < path_var.datalen; k++) {
2572                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2573                                 int64_t path_conv_10_ref = 0;
2574                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2575                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2576                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2577                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2578                                 path_arr_ptr[k] = path_conv_10_ref;
2579                         }
2580                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2581                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2582                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2583                         int64_t retry_ref = 0;
2584                         if ((uintptr_t)retry_var.inner > 4096) {
2585                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2586                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2587                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2588                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2589                         }
2590                         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);
2591                 }
2592                 case LDKEvent_ProbeSuccessful: {
2593                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2594                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
2595                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2596                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
2597                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
2598                         int64_tArray path_arr = NULL;
2599                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2600                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2601                         for (size_t k = 0; k < path_var.datalen; k++) {
2602                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2603                                 int64_t path_conv_10_ref = 0;
2604                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2605                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2606                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2607                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2608                                 path_arr_ptr[k] = path_conv_10_ref;
2609                         }
2610                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2611                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2612                 }
2613                 case LDKEvent_ProbeFailed: {
2614                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2615                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
2616                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2617                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
2618                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
2619                         int64_tArray path_arr = NULL;
2620                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2621                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2622                         for (size_t k = 0; k < path_var.datalen; k++) {
2623                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2624                                 int64_t path_conv_10_ref = 0;
2625                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2626                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2627                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2628                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2629                                 path_arr_ptr[k] = path_conv_10_ref;
2630                         }
2631                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2632                         int64_t short_channel_id_ref = ((uintptr_t)&obj->probe_failed.short_channel_id) | 1;
2633                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
2634                 }
2635                 case LDKEvent_PendingHTLCsForwardable: {
2636                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
2637                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
2638                 }
2639                 case LDKEvent_SpendableOutputs: {
2640                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2641                         int64_tArray outputs_arr = NULL;
2642                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2643                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2644                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2645                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2646                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2647                         }
2648                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2649                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2650                 }
2651                 case LDKEvent_PaymentForwarded: {
2652                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2653                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
2654                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
2655                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
2656                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2657                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
2658                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, prev_channel_id_arr, next_channel_id_arr, fee_earned_msat_ref, claim_from_onchain_tx_conv);
2659                 }
2660                 case LDKEvent_ChannelClosed: {
2661                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2662                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2663                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
2664                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2665                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
2666                 }
2667                 case LDKEvent_DiscardFunding: {
2668                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2669                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2670                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2671                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2672                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2673                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2674                 }
2675                 case LDKEvent_OpenChannelRequest: {
2676                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2677                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2678                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2679                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2680                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2681                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2682                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2683                         int64_t channel_type_ref = 0;
2684                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2685                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2686                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2687                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2688                         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);
2689                 }
2690                 case LDKEvent_HTLCHandlingFailed: {
2691                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2692                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
2693                         int64_t failed_next_destination_ref = ((uintptr_t)&obj->htlc_handling_failed.failed_next_destination) | 1;
2694                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
2695                 }
2696                 default: abort();
2697         }
2698 }
2699 static jclass LDKCOption_EventZ_Some_class = NULL;
2700 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2701 static jclass LDKCOption_EventZ_None_class = NULL;
2702 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2704         LDKCOption_EventZ_Some_class =
2705                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2706         CHECK(LDKCOption_EventZ_Some_class != NULL);
2707         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2708         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2709         LDKCOption_EventZ_None_class =
2710                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2711         CHECK(LDKCOption_EventZ_None_class != NULL);
2712         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2713         CHECK(LDKCOption_EventZ_None_meth != NULL);
2714 }
2715 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2716         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2717         switch(obj->tag) {
2718                 case LDKCOption_EventZ_Some: {
2719                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2720                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2721                 }
2722                 case LDKCOption_EventZ_None: {
2723                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2724                 }
2725                 default: abort();
2726         }
2727 }
2728 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2729 CHECK(owner->result_ok);
2730         return COption_EventZ_clone(&*owner->contents.result);
2731 }
2732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2733         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2734         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2735         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2736         int64_t ret_ref = (uintptr_t)ret_copy;
2737         return ret_ref;
2738 }
2739
2740 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2741 CHECK(!owner->result_ok);
2742         return DecodeError_clone(&*owner->contents.err);
2743 }
2744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2745         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2746         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2747         int64_t ret_ref = 0;
2748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2751         ret_ref = (uintptr_t)ret_var.inner;
2752         if (ret_var.is_owned) {
2753                 ret_ref |= 1;
2754         }
2755         return ret_ref;
2756 }
2757
2758 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2759 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2760 static jclass LDKErrorAction_IgnoreError_class = NULL;
2761 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2762 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2763 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2764 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2765 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2766 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2767 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2768 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2769 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2771         LDKErrorAction_DisconnectPeer_class =
2772                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2773         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2774         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2775         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2776         LDKErrorAction_IgnoreError_class =
2777                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2778         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2779         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2780         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2781         LDKErrorAction_IgnoreAndLog_class =
2782                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2783         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2784         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2785         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2786         LDKErrorAction_IgnoreDuplicateGossip_class =
2787                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2788         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2789         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2790         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2791         LDKErrorAction_SendErrorMessage_class =
2792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2793         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2794         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2795         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2796         LDKErrorAction_SendWarningMessage_class =
2797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2798         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2799         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2800         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2801 }
2802 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2803         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2804         switch(obj->tag) {
2805                 case LDKErrorAction_DisconnectPeer: {
2806                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2807                         int64_t msg_ref = 0;
2808                         if ((uintptr_t)msg_var.inner > 4096) {
2809                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2810                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2811                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2812                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2813                         }
2814                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2815                 }
2816                 case LDKErrorAction_IgnoreError: {
2817                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2818                 }
2819                 case LDKErrorAction_IgnoreAndLog: {
2820                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2821                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2822                 }
2823                 case LDKErrorAction_IgnoreDuplicateGossip: {
2824                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2825                 }
2826                 case LDKErrorAction_SendErrorMessage: {
2827                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2828                         int64_t msg_ref = 0;
2829                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2830                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2831                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2832                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2833                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2834                 }
2835                 case LDKErrorAction_SendWarningMessage: {
2836                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2837                         int64_t msg_ref = 0;
2838                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2839                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2840                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2841                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2842                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2843                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2844                 }
2845                 default: abort();
2846         }
2847 }
2848 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2849 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2850 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2851 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2852 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2853 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2854 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2855 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2856 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
2857 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
2858 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2859 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2860 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2861 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2862 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2863 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2864 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2865 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2866 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2867 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2868 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2869 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2870 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2871 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2872 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2873 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2874 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2875 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2876 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2877 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2878 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2879 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2880 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2881 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2882 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2883 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2884 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2885 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2886 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2887 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2889         LDKMessageSendEvent_SendAcceptChannel_class =
2890                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2891         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2892         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2893         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2894         LDKMessageSendEvent_SendOpenChannel_class =
2895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2896         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2897         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2898         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2899         LDKMessageSendEvent_SendFundingCreated_class =
2900                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2901         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2902         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2903         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2904         LDKMessageSendEvent_SendFundingSigned_class =
2905                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2906         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2907         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2908         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2909         LDKMessageSendEvent_SendChannelReady_class =
2910                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
2911         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
2912         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
2913         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
2914         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2915                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2916         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2917         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2918         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2919         LDKMessageSendEvent_UpdateHTLCs_class =
2920                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2921         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2922         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2923         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2924         LDKMessageSendEvent_SendRevokeAndACK_class =
2925                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2926         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2927         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2928         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2929         LDKMessageSendEvent_SendClosingSigned_class =
2930                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2931         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2932         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2933         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2934         LDKMessageSendEvent_SendShutdown_class =
2935                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2936         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2937         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2938         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2939         LDKMessageSendEvent_SendChannelReestablish_class =
2940                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2941         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2942         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2943         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2944         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2945                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2946         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2947         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2948         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2949         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2950                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2951         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2952         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2953         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2954         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2955                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2956         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2957         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2958         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2959         LDKMessageSendEvent_SendChannelUpdate_class =
2960                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2961         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2962         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2963         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2964         LDKMessageSendEvent_HandleError_class =
2965                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2966         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2967         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2968         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2969         LDKMessageSendEvent_SendChannelRangeQuery_class =
2970                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2971         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2972         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2973         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2974         LDKMessageSendEvent_SendShortIdsQuery_class =
2975                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2976         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2977         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2978         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2979         LDKMessageSendEvent_SendReplyChannelRange_class =
2980                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2981         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2982         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2983         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2984         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2985                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2986         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2987         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2988         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2989 }
2990 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2991         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2992         switch(obj->tag) {
2993                 case LDKMessageSendEvent_SendAcceptChannel: {
2994                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2995                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2996                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2997                         int64_t msg_ref = 0;
2998                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2999                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3000                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3001                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3002                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
3003                 }
3004                 case LDKMessageSendEvent_SendOpenChannel: {
3005                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3006                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
3007                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
3008                         int64_t msg_ref = 0;
3009                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3010                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3011                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3012                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3013                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
3014                 }
3015                 case LDKMessageSendEvent_SendFundingCreated: {
3016                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3017                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
3018                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
3019                         int64_t msg_ref = 0;
3020                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3021                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3022                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3023                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3024                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
3025                 }
3026                 case LDKMessageSendEvent_SendFundingSigned: {
3027                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3028                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
3029                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
3030                         int64_t msg_ref = 0;
3031                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3032                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3033                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3034                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3035                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
3036                 }
3037                 case LDKMessageSendEvent_SendChannelReady: {
3038                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3039                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
3040                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
3041                         int64_t msg_ref = 0;
3042                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3043                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3044                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3045                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3046                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
3047                 }
3048                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
3049                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3050                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
3051                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3052                         int64_t msg_ref = 0;
3053                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3054                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3055                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3056                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3057                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3058                 }
3059                 case LDKMessageSendEvent_UpdateHTLCs: {
3060                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3061                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3062                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3063                         int64_t updates_ref = 0;
3064                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3065                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3066                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3067                         updates_ref = (uintptr_t)updates_var.inner & ~1;
3068                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3069                 }
3070                 case LDKMessageSendEvent_SendRevokeAndACK: {
3071                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3072                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3073                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3074                         int64_t msg_ref = 0;
3075                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3076                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3077                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3078                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3079                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3080                 }
3081                 case LDKMessageSendEvent_SendClosingSigned: {
3082                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3083                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3084                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3085                         int64_t msg_ref = 0;
3086                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3087                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3088                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3089                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3090                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3091                 }
3092                 case LDKMessageSendEvent_SendShutdown: {
3093                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3094                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3095                         LDKShutdown msg_var = obj->send_shutdown.msg;
3096                         int64_t msg_ref = 0;
3097                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3098                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3099                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3100                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3101                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3102                 }
3103                 case LDKMessageSendEvent_SendChannelReestablish: {
3104                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3105                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3106                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3107                         int64_t msg_ref = 0;
3108                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3109                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3110                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3111                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3112                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3113                 }
3114                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3115                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3116                         int64_t msg_ref = 0;
3117                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3118                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3119                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3120                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3121                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3122                         int64_t update_msg_ref = 0;
3123                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3124                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3125                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3126                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
3127                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3128                 }
3129                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
3130                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
3131                         int64_t msg_ref = 0;
3132                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3133                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3134                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3135                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3136                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
3137                 }
3138                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3139                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3140                         int64_t msg_ref = 0;
3141                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3142                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3143                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3144                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3145                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3146                 }
3147                 case LDKMessageSendEvent_SendChannelUpdate: {
3148                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3149                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3150                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3151                         int64_t msg_ref = 0;
3152                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3153                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3154                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3155                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3156                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3157                 }
3158                 case LDKMessageSendEvent_HandleError: {
3159                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3160                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3161                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
3162                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3163                 }
3164                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3165                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3166                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3167                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3168                         int64_t msg_ref = 0;
3169                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3170                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3171                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3172                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3173                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3174                 }
3175                 case LDKMessageSendEvent_SendShortIdsQuery: {
3176                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3177                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3178                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3179                         int64_t msg_ref = 0;
3180                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3181                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3182                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3183                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3184                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3185                 }
3186                 case LDKMessageSendEvent_SendReplyChannelRange: {
3187                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3188                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3189                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3190                         int64_t msg_ref = 0;
3191                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3192                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3193                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3194                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3195                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3196                 }
3197                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3198                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3199                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3200                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3201                         int64_t msg_ref = 0;
3202                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3203                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3204                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3205                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3206                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3207                 }
3208                 default: abort();
3209         }
3210 }
3211 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3212         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3213         for (size_t i = 0; i < ret.datalen; i++) {
3214                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3215         }
3216         return ret;
3217 }
3218 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3219 CHECK(owner->result_ok);
3220         return TxOut_clone(&*owner->contents.result);
3221 }
3222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3223         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3224         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3225         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3226         return (int64_t)ret_ref;
3227 }
3228
3229 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3230 CHECK(!owner->result_ok);
3231         return AccessError_clone(&*owner->contents.err);
3232 }
3233 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3234         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3235         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3236         return ret_conv;
3237 }
3238
3239 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3240         return owner->a;
3241 }
3242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3243         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3244         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3245         return ret_conv;
3246 }
3247
3248 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3249         return owner->b;
3250 }
3251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3252         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3253         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3254         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3255         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3256         return ret_arr;
3257 }
3258
3259 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3260         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3261         for (size_t i = 0; i < ret.datalen; i++) {
3262                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3263         }
3264         return ret;
3265 }
3266 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3267         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3268         for (size_t i = 0; i < ret.datalen; i++) {
3269                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3270         }
3271         return ret;
3272 }
3273 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3274 CHECK(owner->result_ok);
3275         return *owner->contents.result;
3276 }
3277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3278         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3279         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3280 }
3281
3282 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3283 CHECK(!owner->result_ok);
3284         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3285 }
3286 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3287         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3288         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3289         return ret_conv;
3290 }
3291
3292 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3293 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3294 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3295 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3296 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
3297 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
3298 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3299 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3301         LDKMonitorEvent_HTLCEvent_class =
3302                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3303         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3304         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3305         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3306         LDKMonitorEvent_CommitmentTxConfirmed_class =
3307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3308         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3309         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3310         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3311         LDKMonitorEvent_UpdateCompleted_class =
3312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
3313         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
3314         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
3315         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
3316         LDKMonitorEvent_UpdateFailed_class =
3317                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3318         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3319         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3320         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3321 }
3322 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3323         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
3324         switch(obj->tag) {
3325                 case LDKMonitorEvent_HTLCEvent: {
3326                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3327                         int64_t htlc_event_ref = 0;
3328                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3329                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3330                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3331                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
3332                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3333                 }
3334                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3335                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3336                         int64_t commitment_tx_confirmed_ref = 0;
3337                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3338                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3339                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3340                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
3341                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3342                 }
3343                 case LDKMonitorEvent_UpdateCompleted: {
3344                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
3345                         int64_t funding_txo_ref = 0;
3346                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3347                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3348                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3349                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
3350                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
3351                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
3352                 }
3353                 case LDKMonitorEvent_UpdateFailed: {
3354                         LDKOutPoint update_failed_var = obj->update_failed;
3355                         int64_t update_failed_ref = 0;
3356                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3357                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3358                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3359                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
3360                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3361                 }
3362                 default: abort();
3363         }
3364 }
3365 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3366         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3367         for (size_t i = 0; i < ret.datalen; i++) {
3368                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3369         }
3370         return ret;
3371 }
3372 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3373         return OutPoint_clone(&owner->a);
3374 }
3375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3376         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
3377         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
3378         int64_t ret_ref = 0;
3379         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3380         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3382         ret_ref = (uintptr_t)ret_var.inner;
3383         if (ret_var.is_owned) {
3384                 ret_ref |= 1;
3385         }
3386         return ret_ref;
3387 }
3388
3389 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3390         return CVec_MonitorEventZ_clone(&owner->b);
3391 }
3392 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3393         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
3394         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
3395         int64_tArray ret_arr = NULL;
3396         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3397         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3398         for (size_t o = 0; o < ret_var.datalen; o++) {
3399                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3400                 *ret_conv_14_copy = ret_var.data[o];
3401                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
3402                 ret_arr_ptr[o] = ret_conv_14_ref;
3403         }
3404         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3405         FREE(ret_var.data);
3406         return ret_arr;
3407 }
3408
3409 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3410         return owner->c;
3411 }
3412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3413         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
3414         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
3416         return ret_arr;
3417 }
3418
3419 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3420         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3421         for (size_t i = 0; i < ret.datalen; i++) {
3422                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3423         }
3424         return ret;
3425 }
3426 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
3427 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
3428 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
3429 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
3430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
3431         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
3432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
3433         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
3434         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
3435         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
3436         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
3437                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
3438         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
3439         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
3440         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
3441 }
3442 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3443         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3444         switch(obj->tag) {
3445                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
3446                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3447                         *some_conv = obj->some;
3448                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3449                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
3450                 }
3451                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
3452                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
3453                 }
3454                 default: abort();
3455         }
3456 }
3457 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3458 CHECK(owner->result_ok);
3459         return FixedPenaltyScorer_clone(&*owner->contents.result);
3460 }
3461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3462         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3463         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3464         int64_t ret_ref = 0;
3465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3468         ret_ref = (uintptr_t)ret_var.inner;
3469         if (ret_var.is_owned) {
3470                 ret_ref |= 1;
3471         }
3472         return ret_ref;
3473 }
3474
3475 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3476 CHECK(!owner->result_ok);
3477         return DecodeError_clone(&*owner->contents.err);
3478 }
3479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3480         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3481         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3482         int64_t ret_ref = 0;
3483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3486         ret_ref = (uintptr_t)ret_var.inner;
3487         if (ret_var.is_owned) {
3488                 ret_ref |= 1;
3489         }
3490         return ret_ref;
3491 }
3492
3493 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3494         return owner->a;
3495 }
3496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3497         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3498         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3499         return ret_conv;
3500 }
3501
3502 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3503         return owner->b;
3504 }
3505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3506         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3507         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3508         return ret_conv;
3509 }
3510
3511 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
3512 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
3513 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
3514 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
3515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
3516         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
3517                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
3518         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
3519         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
3520         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
3521         LDKCOption_C2Tuple_u64u64ZZ_None_class =
3522                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
3523         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
3524         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
3525         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
3526 }
3527 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3528         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
3529         switch(obj->tag) {
3530                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
3531                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3532                         *some_conv = obj->some;
3533                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3534                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, ((int64_t)some_conv));
3535                 }
3536                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
3537                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
3538                 }
3539                 default: abort();
3540         }
3541 }
3542 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3543         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3544         for (size_t i = 0; i < ret.datalen; i++) {
3545                 ret.data[i] = NodeId_clone(&orig->data[i]);
3546         }
3547         return ret;
3548 }
3549 typedef struct LDKLogger_JCalls {
3550         atomic_size_t refcnt;
3551         JavaVM *vm;
3552         jweak o;
3553         jmethodID log_meth;
3554 } LDKLogger_JCalls;
3555 static void LDKLogger_JCalls_free(void* this_arg) {
3556         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3557         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3558                 JNIEnv *env;
3559                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3560                 if (get_jenv_res == JNI_EDETACHED) {
3561                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3562                 } else {
3563                         DO_ASSERT(get_jenv_res == JNI_OK);
3564                 }
3565                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3566                 if (get_jenv_res == JNI_EDETACHED) {
3567                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3568                 }
3569                 FREE(j_calls);
3570         }
3571 }
3572 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3573         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3574         JNIEnv *env;
3575         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3576         if (get_jenv_res == JNI_EDETACHED) {
3577                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3578         } else {
3579                 DO_ASSERT(get_jenv_res == JNI_OK);
3580         }
3581         LDKRecord record_var = *record;
3582         int64_t record_ref = 0;
3583         record_var = Record_clone(&record_var);
3584         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3585         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3586         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3587         record_ref = (uintptr_t)record_var.inner;
3588         if (record_var.is_owned) {
3589                 record_ref |= 1;
3590         }
3591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3592         CHECK(obj != NULL);
3593         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
3594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3595                 (*env)->ExceptionDescribe(env);
3596                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
3597         }
3598         if (get_jenv_res == JNI_EDETACHED) {
3599                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3600         }
3601 }
3602 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3603         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3604         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3605 }
3606 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3607         jclass c = (*env)->GetObjectClass(env, o);
3608         CHECK(c != NULL);
3609         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3610         atomic_init(&calls->refcnt, 1);
3611         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3612         calls->o = (*env)->NewWeakGlobalRef(env, o);
3613         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
3614         CHECK(calls->log_meth != NULL);
3615
3616         LDKLogger ret = {
3617                 .this_arg = (void*) calls,
3618                 .log = log_LDKLogger_jcall,
3619                 .free = LDKLogger_JCalls_free,
3620         };
3621         return ret;
3622 }
3623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3624         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3625         *res_ptr = LDKLogger_init(env, clz, o);
3626         return (uint64_t)res_ptr;
3627 }
3628 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3629 CHECK(owner->result_ok);
3630         return &*owner->contents.result;
3631 }
3632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3633         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3634         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3635         int64_t ret_ref = 0;
3636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3639         ret_ref = (uintptr_t)ret_var.inner & ~1;
3640         return ret_ref;
3641 }
3642
3643 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3644 CHECK(!owner->result_ok);
3645         return DecodeError_clone(&*owner->contents.err);
3646 }
3647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3648         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3649         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3650         int64_t ret_ref = 0;
3651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3654         ret_ref = (uintptr_t)ret_var.inner;
3655         if (ret_var.is_owned) {
3656                 ret_ref |= 1;
3657         }
3658         return ret_ref;
3659 }
3660
3661 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3662 CHECK(owner->result_ok);
3663         return InitFeatures_clone(&*owner->contents.result);
3664 }
3665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3666         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3667         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3668         int64_t ret_ref = 0;
3669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3672         ret_ref = (uintptr_t)ret_var.inner;
3673         if (ret_var.is_owned) {
3674                 ret_ref |= 1;
3675         }
3676         return ret_ref;
3677 }
3678
3679 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3680 CHECK(!owner->result_ok);
3681         return DecodeError_clone(&*owner->contents.err);
3682 }
3683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3684         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3685         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3686         int64_t ret_ref = 0;
3687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3690         ret_ref = (uintptr_t)ret_var.inner;
3691         if (ret_var.is_owned) {
3692                 ret_ref |= 1;
3693         }
3694         return ret_ref;
3695 }
3696
3697 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3698 CHECK(owner->result_ok);
3699         return ChannelFeatures_clone(&*owner->contents.result);
3700 }
3701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3702         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3703         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3704         int64_t ret_ref = 0;
3705         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3706         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3708         ret_ref = (uintptr_t)ret_var.inner;
3709         if (ret_var.is_owned) {
3710                 ret_ref |= 1;
3711         }
3712         return ret_ref;
3713 }
3714
3715 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3716 CHECK(!owner->result_ok);
3717         return DecodeError_clone(&*owner->contents.err);
3718 }
3719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3720         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3721         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3722         int64_t ret_ref = 0;
3723         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3724         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3726         ret_ref = (uintptr_t)ret_var.inner;
3727         if (ret_var.is_owned) {
3728                 ret_ref |= 1;
3729         }
3730         return ret_ref;
3731 }
3732
3733 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3734 CHECK(owner->result_ok);
3735         return NodeFeatures_clone(&*owner->contents.result);
3736 }
3737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3738         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3739         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3740         int64_t ret_ref = 0;
3741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3744         ret_ref = (uintptr_t)ret_var.inner;
3745         if (ret_var.is_owned) {
3746                 ret_ref |= 1;
3747         }
3748         return ret_ref;
3749 }
3750
3751 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3752 CHECK(!owner->result_ok);
3753         return DecodeError_clone(&*owner->contents.err);
3754 }
3755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3756         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3757         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3758         int64_t ret_ref = 0;
3759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3762         ret_ref = (uintptr_t)ret_var.inner;
3763         if (ret_var.is_owned) {
3764                 ret_ref |= 1;
3765         }
3766         return ret_ref;
3767 }
3768
3769 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3770 CHECK(owner->result_ok);
3771         return InvoiceFeatures_clone(&*owner->contents.result);
3772 }
3773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3774         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3775         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3776         int64_t ret_ref = 0;
3777         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3778         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3780         ret_ref = (uintptr_t)ret_var.inner;
3781         if (ret_var.is_owned) {
3782                 ret_ref |= 1;
3783         }
3784         return ret_ref;
3785 }
3786
3787 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3788 CHECK(!owner->result_ok);
3789         return DecodeError_clone(&*owner->contents.err);
3790 }
3791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3792         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3793         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3794         int64_t ret_ref = 0;
3795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3798         ret_ref = (uintptr_t)ret_var.inner;
3799         if (ret_var.is_owned) {
3800                 ret_ref |= 1;
3801         }
3802         return ret_ref;
3803 }
3804
3805 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3806 CHECK(owner->result_ok);
3807         return ChannelTypeFeatures_clone(&*owner->contents.result);
3808 }
3809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3810         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3811         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3812         int64_t ret_ref = 0;
3813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3816         ret_ref = (uintptr_t)ret_var.inner;
3817         if (ret_var.is_owned) {
3818                 ret_ref |= 1;
3819         }
3820         return ret_ref;
3821 }
3822
3823 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3824 CHECK(!owner->result_ok);
3825         return DecodeError_clone(&*owner->contents.err);
3826 }
3827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3828         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3829         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3830         int64_t ret_ref = 0;
3831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3834         ret_ref = (uintptr_t)ret_var.inner;
3835         if (ret_var.is_owned) {
3836                 ret_ref |= 1;
3837         }
3838         return ret_ref;
3839 }
3840
3841 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3842 CHECK(owner->result_ok);
3843         return NodeId_clone(&*owner->contents.result);
3844 }
3845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3846         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3847         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3848         int64_t ret_ref = 0;
3849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3852         ret_ref = (uintptr_t)ret_var.inner;
3853         if (ret_var.is_owned) {
3854                 ret_ref |= 1;
3855         }
3856         return ret_ref;
3857 }
3858
3859 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3860 CHECK(!owner->result_ok);
3861         return DecodeError_clone(&*owner->contents.err);
3862 }
3863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3864         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3865         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3866         int64_t ret_ref = 0;
3867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3870         ret_ref = (uintptr_t)ret_var.inner;
3871         if (ret_var.is_owned) {
3872                 ret_ref |= 1;
3873         }
3874         return ret_ref;
3875 }
3876
3877 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3878 CHECK(owner->result_ok);
3879         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3880 }
3881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3882         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3883         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3884         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3885         int64_t ret_ref = (uintptr_t)ret_copy;
3886         return ret_ref;
3887 }
3888
3889 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3890 CHECK(!owner->result_ok);
3891         return DecodeError_clone(&*owner->contents.err);
3892 }
3893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3894         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3895         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3896         int64_t ret_ref = 0;
3897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3900         ret_ref = (uintptr_t)ret_var.inner;
3901         if (ret_var.is_owned) {
3902                 ret_ref |= 1;
3903         }
3904         return ret_ref;
3905 }
3906
3907 typedef struct LDKAccess_JCalls {
3908         atomic_size_t refcnt;
3909         JavaVM *vm;
3910         jweak o;
3911         jmethodID get_utxo_meth;
3912 } LDKAccess_JCalls;
3913 static void LDKAccess_JCalls_free(void* this_arg) {
3914         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3915         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3916                 JNIEnv *env;
3917                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3918                 if (get_jenv_res == JNI_EDETACHED) {
3919                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3920                 } else {
3921                         DO_ASSERT(get_jenv_res == JNI_OK);
3922                 }
3923                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3924                 if (get_jenv_res == JNI_EDETACHED) {
3925                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3926                 }
3927                 FREE(j_calls);
3928         }
3929 }
3930 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3931         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3932         JNIEnv *env;
3933         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3934         if (get_jenv_res == JNI_EDETACHED) {
3935                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3936         } else {
3937                 DO_ASSERT(get_jenv_res == JNI_OK);
3938         }
3939         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
3940         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
3941         int64_t short_channel_id_conv = short_channel_id;
3942         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3943         CHECK(obj != NULL);
3944         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
3945         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3946                 (*env)->ExceptionDescribe(env);
3947                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
3948         }
3949         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3950         CHECK_ACCESS(ret_ptr);
3951         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3952         FREE((void*)ret);
3953         if (get_jenv_res == JNI_EDETACHED) {
3954                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3955         }
3956         return ret_conv;
3957 }
3958 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3959         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3960         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3961 }
3962 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
3963         jclass c = (*env)->GetObjectClass(env, o);
3964         CHECK(c != NULL);
3965         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3966         atomic_init(&calls->refcnt, 1);
3967         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3968         calls->o = (*env)->NewWeakGlobalRef(env, o);
3969         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
3970         CHECK(calls->get_utxo_meth != NULL);
3971
3972         LDKAccess ret = {
3973                 .this_arg = (void*) calls,
3974                 .get_utxo = get_utxo_LDKAccess_jcall,
3975                 .free = LDKAccess_JCalls_free,
3976         };
3977         return ret;
3978 }
3979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
3980         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3981         *res_ptr = LDKAccess_init(env, clz, o);
3982         return (uint64_t)res_ptr;
3983 }
3984 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) {
3985         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3986         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3987         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3988         unsigned char genesis_hash_arr[32];
3989         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
3990         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
3991         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3992         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3993         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3994         return (int64_t)ret_conv;
3995 }
3996
3997 static jclass LDKCOption_AccessZ_Some_class = NULL;
3998 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
3999 static jclass LDKCOption_AccessZ_None_class = NULL;
4000 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
4001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
4002         LDKCOption_AccessZ_Some_class =
4003                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
4004         CHECK(LDKCOption_AccessZ_Some_class != NULL);
4005         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
4006         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
4007         LDKCOption_AccessZ_None_class =
4008                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
4009         CHECK(LDKCOption_AccessZ_None_class != NULL);
4010         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
4011         CHECK(LDKCOption_AccessZ_None_meth != NULL);
4012 }
4013 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4014         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
4015         switch(obj->tag) {
4016                 case LDKCOption_AccessZ_Some: {
4017                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4018                         *some_ret = obj->some;
4019                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4020                         if ((*some_ret).free == LDKAccess_JCalls_free) {
4021                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4022                                 LDKAccess_JCalls_cloned(&(*some_ret));
4023                         }
4024                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
4025                 }
4026                 case LDKCOption_AccessZ_None: {
4027                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
4028                 }
4029                 default: abort();
4030         }
4031 }
4032 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4033 CHECK(owner->result_ok);
4034         return *owner->contents.result;
4035 }
4036 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4037         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
4038         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4039         return ret_conv;
4040 }
4041
4042 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4043 CHECK(!owner->result_ok);
4044         return LightningError_clone(&*owner->contents.err);
4045 }
4046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4047         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
4048         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4049         int64_t ret_ref = 0;
4050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4053         ret_ref = (uintptr_t)ret_var.inner;
4054         if (ret_var.is_owned) {
4055                 ret_ref |= 1;
4056         }
4057         return ret_ref;
4058 }
4059
4060 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4061         return ChannelAnnouncement_clone(&owner->a);
4062 }
4063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4064         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
4065         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4066         int64_t ret_ref = 0;
4067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4070         ret_ref = (uintptr_t)ret_var.inner;
4071         if (ret_var.is_owned) {
4072                 ret_ref |= 1;
4073         }
4074         return ret_ref;
4075 }
4076
4077 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4078         return ChannelUpdate_clone(&owner->b);
4079 }
4080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4081         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
4082         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4083         int64_t ret_ref = 0;
4084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4087         ret_ref = (uintptr_t)ret_var.inner;
4088         if (ret_var.is_owned) {
4089                 ret_ref |= 1;
4090         }
4091         return ret_ref;
4092 }
4093
4094 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4095         return ChannelUpdate_clone(&owner->c);
4096 }
4097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4098         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
4099         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4100         int64_t ret_ref = 0;
4101         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4102         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4104         ret_ref = (uintptr_t)ret_var.inner;
4105         if (ret_var.is_owned) {
4106                 ret_ref |= 1;
4107         }
4108         return ret_ref;
4109 }
4110
4111 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4112         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4113         for (size_t i = 0; i < ret.datalen; i++) {
4114                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4115         }
4116         return ret;
4117 }
4118 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4119         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4120         for (size_t i = 0; i < ret.datalen; i++) {
4121                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4122         }
4123         return ret;
4124 }
4125 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4126 CHECK(owner->result_ok);
4127         return *owner->contents.result;
4128 }
4129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4130         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
4131         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4132 }
4133
4134 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4135 CHECK(!owner->result_ok);
4136         return LightningError_clone(&*owner->contents.err);
4137 }
4138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4139         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
4140         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4141         int64_t ret_ref = 0;
4142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4145         ret_ref = (uintptr_t)ret_var.inner;
4146         if (ret_var.is_owned) {
4147                 ret_ref |= 1;
4148         }
4149         return ret_ref;
4150 }
4151
4152 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4153 CHECK(owner->result_ok);
4154         return ChannelUpdateInfo_clone(&*owner->contents.result);
4155 }
4156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4157         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
4158         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4159         int64_t ret_ref = 0;
4160         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4161         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4163         ret_ref = (uintptr_t)ret_var.inner;
4164         if (ret_var.is_owned) {
4165                 ret_ref |= 1;
4166         }
4167         return ret_ref;
4168 }
4169
4170 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4171 CHECK(!owner->result_ok);
4172         return DecodeError_clone(&*owner->contents.err);
4173 }
4174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4175         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
4176         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4177         int64_t ret_ref = 0;
4178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4181         ret_ref = (uintptr_t)ret_var.inner;
4182         if (ret_var.is_owned) {
4183                 ret_ref |= 1;
4184         }
4185         return ret_ref;
4186 }
4187
4188 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4189 CHECK(owner->result_ok);
4190         return ChannelInfo_clone(&*owner->contents.result);
4191 }
4192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4193         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4194         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4195         int64_t ret_ref = 0;
4196         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4197         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4199         ret_ref = (uintptr_t)ret_var.inner;
4200         if (ret_var.is_owned) {
4201                 ret_ref |= 1;
4202         }
4203         return ret_ref;
4204 }
4205
4206 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4207 CHECK(!owner->result_ok);
4208         return DecodeError_clone(&*owner->contents.err);
4209 }
4210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4211         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4212         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4213         int64_t ret_ref = 0;
4214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4217         ret_ref = (uintptr_t)ret_var.inner;
4218         if (ret_var.is_owned) {
4219                 ret_ref |= 1;
4220         }
4221         return ret_ref;
4222 }
4223
4224 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4225 CHECK(owner->result_ok);
4226         return RoutingFees_clone(&*owner->contents.result);
4227 }
4228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4229         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4230         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4231         int64_t ret_ref = 0;
4232         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4233         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4235         ret_ref = (uintptr_t)ret_var.inner;
4236         if (ret_var.is_owned) {
4237                 ret_ref |= 1;
4238         }
4239         return ret_ref;
4240 }
4241
4242 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4243 CHECK(!owner->result_ok);
4244         return DecodeError_clone(&*owner->contents.err);
4245 }
4246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4247         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4248         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4249         int64_t ret_ref = 0;
4250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4253         ret_ref = (uintptr_t)ret_var.inner;
4254         if (ret_var.is_owned) {
4255                 ret_ref |= 1;
4256         }
4257         return ret_ref;
4258 }
4259
4260 static jclass LDKNetAddress_IPv4_class = NULL;
4261 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4262 static jclass LDKNetAddress_IPv6_class = NULL;
4263 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4264 static jclass LDKNetAddress_OnionV2_class = NULL;
4265 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4266 static jclass LDKNetAddress_OnionV3_class = NULL;
4267 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4268 static jclass LDKNetAddress_Hostname_class = NULL;
4269 static jmethodID LDKNetAddress_Hostname_meth = NULL;
4270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4271         LDKNetAddress_IPv4_class =
4272                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4273         CHECK(LDKNetAddress_IPv4_class != NULL);
4274         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4275         CHECK(LDKNetAddress_IPv4_meth != NULL);
4276         LDKNetAddress_IPv6_class =
4277                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4278         CHECK(LDKNetAddress_IPv6_class != NULL);
4279         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4280         CHECK(LDKNetAddress_IPv6_meth != NULL);
4281         LDKNetAddress_OnionV2_class =
4282                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4283         CHECK(LDKNetAddress_OnionV2_class != NULL);
4284         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4285         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4286         LDKNetAddress_OnionV3_class =
4287                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4288         CHECK(LDKNetAddress_OnionV3_class != NULL);
4289         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4290         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4291         LDKNetAddress_Hostname_class =
4292                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
4293         CHECK(LDKNetAddress_Hostname_class != NULL);
4294         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
4295         CHECK(LDKNetAddress_Hostname_meth != NULL);
4296 }
4297 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4298         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4299         switch(obj->tag) {
4300                 case LDKNetAddress_IPv4: {
4301                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4302                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4303                         int16_t port_conv = obj->i_pv4.port;
4304                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4305                 }
4306                 case LDKNetAddress_IPv6: {
4307                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4308                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4309                         int16_t port_conv = obj->i_pv6.port;
4310                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4311                 }
4312                 case LDKNetAddress_OnionV2: {
4313                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4314                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4315                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4316                 }
4317                 case LDKNetAddress_OnionV3: {
4318                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4319                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4320                         int16_t checksum_conv = obj->onion_v3.checksum;
4321                         int8_t version_conv = obj->onion_v3.version;
4322                         int16_t port_conv = obj->onion_v3.port;
4323                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4324                 }
4325                 case LDKNetAddress_Hostname: {
4326                         LDKHostname hostname_var = obj->hostname.hostname;
4327                         int64_t hostname_ref = 0;
4328                         CHECK((((uintptr_t)hostname_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4329                         CHECK((((uintptr_t)&hostname_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4330                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4331                         hostname_ref = (uintptr_t)hostname_var.inner & ~1;
4332                         int16_t port_conv = obj->hostname.port;
4333                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
4334                 }
4335                 default: abort();
4336         }
4337 }
4338 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4339         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4340         for (size_t i = 0; i < ret.datalen; i++) {
4341                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4342         }
4343         return ret;
4344 }
4345 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4346 CHECK(owner->result_ok);
4347         return NodeAnnouncementInfo_clone(&*owner->contents.result);
4348 }
4349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4350         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4351         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4352         int64_t ret_ref = 0;
4353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4356         ret_ref = (uintptr_t)ret_var.inner;
4357         if (ret_var.is_owned) {
4358                 ret_ref |= 1;
4359         }
4360         return ret_ref;
4361 }
4362
4363 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4364 CHECK(!owner->result_ok);
4365         return DecodeError_clone(&*owner->contents.err);
4366 }
4367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4368         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4369         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4370         int64_t ret_ref = 0;
4371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4374         ret_ref = (uintptr_t)ret_var.inner;
4375         if (ret_var.is_owned) {
4376                 ret_ref |= 1;
4377         }
4378         return ret_ref;
4379 }
4380
4381 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4382 CHECK(owner->result_ok);
4383         return NodeAlias_clone(&*owner->contents.result);
4384 }
4385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4386         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4387         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4388         int64_t ret_ref = 0;
4389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4392         ret_ref = (uintptr_t)ret_var.inner;
4393         if (ret_var.is_owned) {
4394                 ret_ref |= 1;
4395         }
4396         return ret_ref;
4397 }
4398
4399 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4400 CHECK(!owner->result_ok);
4401         return DecodeError_clone(&*owner->contents.err);
4402 }
4403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4404         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4405         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4406         int64_t ret_ref = 0;
4407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4410         ret_ref = (uintptr_t)ret_var.inner;
4411         if (ret_var.is_owned) {
4412                 ret_ref |= 1;
4413         }
4414         return ret_ref;
4415 }
4416
4417 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4418 CHECK(owner->result_ok);
4419         return NodeInfo_clone(&*owner->contents.result);
4420 }
4421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4422         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4423         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4424         int64_t ret_ref = 0;
4425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4428         ret_ref = (uintptr_t)ret_var.inner;
4429         if (ret_var.is_owned) {
4430                 ret_ref |= 1;
4431         }
4432         return ret_ref;
4433 }
4434
4435 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4436 CHECK(!owner->result_ok);
4437         return DecodeError_clone(&*owner->contents.err);
4438 }
4439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4440         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4441         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4442         int64_t ret_ref = 0;
4443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4446         ret_ref = (uintptr_t)ret_var.inner;
4447         if (ret_var.is_owned) {
4448                 ret_ref |= 1;
4449         }
4450         return ret_ref;
4451 }
4452
4453 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4454 CHECK(owner->result_ok);
4455         return &*owner->contents.result;
4456 }
4457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4458         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4459         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4460         int64_t ret_ref = 0;
4461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4464         ret_ref = (uintptr_t)ret_var.inner & ~1;
4465         return ret_ref;
4466 }
4467
4468 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4469 CHECK(!owner->result_ok);
4470         return DecodeError_clone(&*owner->contents.err);
4471 }
4472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4473         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4474         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4475         int64_t ret_ref = 0;
4476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4479         ret_ref = (uintptr_t)ret_var.inner;
4480         if (ret_var.is_owned) {
4481                 ret_ref |= 1;
4482         }
4483         return ret_ref;
4484 }
4485
4486 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4487 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4488 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4489 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4491         LDKCOption_CVec_NetAddressZZ_Some_class =
4492                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4493         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4494         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4495         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4496         LDKCOption_CVec_NetAddressZZ_None_class =
4497                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4498         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4499         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4500         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4501 }
4502 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4503         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4504         switch(obj->tag) {
4505                 case LDKCOption_CVec_NetAddressZZ_Some: {
4506                         LDKCVec_NetAddressZ some_var = obj->some;
4507                         int64_tArray some_arr = NULL;
4508                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4509                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4510                         for (size_t m = 0; m < some_var.datalen; m++) {
4511                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
4512                                 some_arr_ptr[m] = some_conv_12_ref;
4513                         }
4514                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4515                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4516                 }
4517                 case LDKCOption_CVec_NetAddressZZ_None: {
4518                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4519                 }
4520                 default: abort();
4521         }
4522 }
4523 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4524 CHECK(owner->result_ok);
4525         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
4526 }
4527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4528         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4529         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4530         int64_t ret_ref = 0;
4531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4534         ret_ref = (uintptr_t)ret_var.inner;
4535         if (ret_var.is_owned) {
4536                 ret_ref |= 1;
4537         }
4538         return ret_ref;
4539 }
4540
4541 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4542 CHECK(!owner->result_ok);
4543         return DecodeError_clone(&*owner->contents.err);
4544 }
4545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4546         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4547         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4548         int64_t ret_ref = 0;
4549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4552         ret_ref = (uintptr_t)ret_var.inner;
4553         if (ret_var.is_owned) {
4554                 ret_ref |= 1;
4555         }
4556         return ret_ref;
4557 }
4558
4559 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4560 CHECK(owner->result_ok);
4561         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
4562 }
4563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4564         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4565         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4566         int64_t ret_ref = 0;
4567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4570         ret_ref = (uintptr_t)ret_var.inner;
4571         if (ret_var.is_owned) {
4572                 ret_ref |= 1;
4573         }
4574         return ret_ref;
4575 }
4576
4577 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4578 CHECK(!owner->result_ok);
4579         return DecodeError_clone(&*owner->contents.err);
4580 }
4581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4582         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4583         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4584         int64_t ret_ref = 0;
4585         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4586         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4588         ret_ref = (uintptr_t)ret_var.inner;
4589         if (ret_var.is_owned) {
4590                 ret_ref |= 1;
4591         }
4592         return ret_ref;
4593 }
4594
4595 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4596 CHECK(owner->result_ok);
4597         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4598 }
4599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4600         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4601         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4602         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4603         int64_t ret_ref = (uintptr_t)ret_copy;
4604         return ret_ref;
4605 }
4606
4607 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4608 CHECK(!owner->result_ok);
4609         return DecodeError_clone(&*owner->contents.err);
4610 }
4611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4612         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4613         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4614         int64_t ret_ref = 0;
4615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4618         ret_ref = (uintptr_t)ret_var.inner;
4619         if (ret_var.is_owned) {
4620                 ret_ref |= 1;
4621         }
4622         return ret_ref;
4623 }
4624
4625 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4626         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4627         for (size_t i = 0; i < ret.datalen; i++) {
4628                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4629         }
4630         return ret;
4631 }
4632 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4633         return owner->a;
4634 }
4635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4636         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4637         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4638         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4639         return ret_arr;
4640 }
4641
4642 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4643         return owner->b;
4644 }
4645 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4646         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4647         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4648         jobjectArray ret_arr = NULL;
4649         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4650         ;
4651         for (size_t i = 0; i < ret_var.datalen; i++) {
4652                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
4653                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
4654                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4655         }
4656         
4657         return ret_arr;
4658 }
4659
4660 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4661 CHECK(owner->result_ok);
4662         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
4663 }
4664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4665         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4666         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4667         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
4668         return ((int64_t)ret_conv);
4669 }
4670
4671 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4672 CHECK(!owner->result_ok);
4673         return *owner->contents.err;
4674 }
4675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4676         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4677         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
4678 }
4679
4680 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4681 CHECK(owner->result_ok);
4682         return *owner->contents.result;
4683 }
4684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4685         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4686         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
4688         return ret_arr;
4689 }
4690
4691 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4692 CHECK(!owner->result_ok);
4693         return *owner->contents.err;
4694 }
4695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4696         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4697         CResult_SignatureNoneZ_get_err(owner_conv);
4698 }
4699
4700 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4701         return owner->a;
4702 }
4703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4704         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4705         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4706         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
4707         return ret_arr;
4708 }
4709
4710 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4711         return owner->b;
4712 }
4713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4714         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4715         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4716         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
4717         return ret_arr;
4718 }
4719
4720 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4721 CHECK(owner->result_ok);
4722         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
4723 }
4724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4725         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4726         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
4727         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
4728         return ((int64_t)ret_conv);
4729 }
4730
4731 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4732 CHECK(!owner->result_ok);
4733         return *owner->contents.err;
4734 }
4735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4736         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4737         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
4738 }
4739
4740 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4741 CHECK(owner->result_ok);
4742         return *owner->contents.result;
4743 }
4744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4745         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4746         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4747         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
4748         return ret_arr;
4749 }
4750
4751 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4752 CHECK(!owner->result_ok);
4753         return *owner->contents.err;
4754 }
4755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4756         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4757         CResult_SecretKeyNoneZ_get_err(owner_conv);
4758 }
4759
4760 typedef struct LDKBaseSign_JCalls {
4761         atomic_size_t refcnt;
4762         JavaVM *vm;
4763         jweak o;
4764         jmethodID get_per_commitment_point_meth;
4765         jmethodID release_commitment_secret_meth;
4766         jmethodID validate_holder_commitment_meth;
4767         jmethodID channel_keys_id_meth;
4768         jmethodID sign_counterparty_commitment_meth;
4769         jmethodID validate_counterparty_revocation_meth;
4770         jmethodID sign_holder_commitment_and_htlcs_meth;
4771         jmethodID sign_justice_revoked_output_meth;
4772         jmethodID sign_justice_revoked_htlc_meth;
4773         jmethodID sign_counterparty_htlc_transaction_meth;
4774         jmethodID sign_closing_transaction_meth;
4775         jmethodID sign_channel_announcement_meth;
4776         jmethodID ready_channel_meth;
4777 } LDKBaseSign_JCalls;
4778 static void LDKBaseSign_JCalls_free(void* this_arg) {
4779         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4780         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4781                 JNIEnv *env;
4782                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4783                 if (get_jenv_res == JNI_EDETACHED) {
4784                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4785                 } else {
4786                         DO_ASSERT(get_jenv_res == JNI_OK);
4787                 }
4788                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4789                 if (get_jenv_res == JNI_EDETACHED) {
4790                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4791                 }
4792                 FREE(j_calls);
4793         }
4794 }
4795 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4796         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4797         JNIEnv *env;
4798         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4799         if (get_jenv_res == JNI_EDETACHED) {
4800                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4801         } else {
4802                 DO_ASSERT(get_jenv_res == JNI_OK);
4803         }
4804         int64_t idx_conv = idx;
4805         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4806         CHECK(obj != NULL);
4807         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
4808         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4809                 (*env)->ExceptionDescribe(env);
4810                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
4811         }
4812         LDKPublicKey ret_ref;
4813         CHECK((*env)->GetArrayLength(env, ret) == 33);
4814         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
4815         if (get_jenv_res == JNI_EDETACHED) {
4816                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4817         }
4818         return ret_ref;
4819 }
4820 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4821         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4822         JNIEnv *env;
4823         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4824         if (get_jenv_res == JNI_EDETACHED) {
4825                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4826         } else {
4827                 DO_ASSERT(get_jenv_res == JNI_OK);
4828         }
4829         int64_t idx_conv = idx;
4830         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4831         CHECK(obj != NULL);
4832         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
4833         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4834                 (*env)->ExceptionDescribe(env);
4835                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
4836         }
4837         LDKThirtyTwoBytes ret_ref;
4838         CHECK((*env)->GetArrayLength(env, ret) == 32);
4839         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4840         if (get_jenv_res == JNI_EDETACHED) {
4841                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4842         }
4843         return ret_ref;
4844 }
4845 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
4846         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4847         JNIEnv *env;
4848         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4849         if (get_jenv_res == JNI_EDETACHED) {
4850                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4851         } else {
4852                 DO_ASSERT(get_jenv_res == JNI_OK);
4853         }
4854         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
4855         int64_t holder_tx_ref = 0;
4856         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
4857         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4858         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4859         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
4860         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
4861         if (holder_tx_var.is_owned) {
4862                 holder_tx_ref |= 1;
4863         }
4864         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4865         jobjectArray preimages_arr = NULL;
4866         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4867         ;
4868         for (size_t i = 0; i < preimages_var.datalen; i++) {
4869                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4870                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4871                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4872         }
4873         
4874         FREE(preimages_var.data);
4875         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4876         CHECK(obj != NULL);
4877         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
4878         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4879                 (*env)->ExceptionDescribe(env);
4880                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
4881         }
4882         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4883         CHECK_ACCESS(ret_ptr);
4884         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4885         FREE((void*)ret);
4886         if (get_jenv_res == JNI_EDETACHED) {
4887                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4888         }
4889         return ret_conv;
4890 }
4891 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4892         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4893         JNIEnv *env;
4894         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4895         if (get_jenv_res == JNI_EDETACHED) {
4896                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4897         } else {
4898                 DO_ASSERT(get_jenv_res == JNI_OK);
4899         }
4900         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4901         CHECK(obj != NULL);
4902         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
4903         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4904                 (*env)->ExceptionDescribe(env);
4905                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
4906         }
4907         LDKThirtyTwoBytes ret_ref;
4908         CHECK((*env)->GetArrayLength(env, ret) == 32);
4909         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4910         if (get_jenv_res == JNI_EDETACHED) {
4911                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4912         }
4913         return ret_ref;
4914 }
4915 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4916         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4917         JNIEnv *env;
4918         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4919         if (get_jenv_res == JNI_EDETACHED) {
4920                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4921         } else {
4922                 DO_ASSERT(get_jenv_res == JNI_OK);
4923         }
4924         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4925         int64_t commitment_tx_ref = 0;
4926         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4927         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4928         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4929         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4930         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4931         if (commitment_tx_var.is_owned) {
4932                 commitment_tx_ref |= 1;
4933         }
4934         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4935         jobjectArray preimages_arr = NULL;
4936         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4937         ;
4938         for (size_t i = 0; i < preimages_var.datalen; i++) {
4939                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4940                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4941                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4942         }
4943         
4944         FREE(preimages_var.data);
4945         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4946         CHECK(obj != NULL);
4947         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
4948         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4949                 (*env)->ExceptionDescribe(env);
4950                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
4951         }
4952         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4953         CHECK_ACCESS(ret_ptr);
4954         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4955         FREE((void*)ret);
4956         if (get_jenv_res == JNI_EDETACHED) {
4957                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4958         }
4959         return ret_conv;
4960 }
4961 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4962         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4963         JNIEnv *env;
4964         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4965         if (get_jenv_res == JNI_EDETACHED) {
4966                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4967         } else {
4968                 DO_ASSERT(get_jenv_res == JNI_OK);
4969         }
4970         int64_t idx_conv = idx;
4971         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
4972         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
4973         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4974         CHECK(obj != NULL);
4975         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
4976         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4977                 (*env)->ExceptionDescribe(env);
4978                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
4979         }
4980         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4981         CHECK_ACCESS(ret_ptr);
4982         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4983         FREE((void*)ret);
4984         if (get_jenv_res == JNI_EDETACHED) {
4985                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4986         }
4987         return ret_conv;
4988 }
4989 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4990         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4991         JNIEnv *env;
4992         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4993         if (get_jenv_res == JNI_EDETACHED) {
4994                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4995         } else {
4996                 DO_ASSERT(get_jenv_res == JNI_OK);
4997         }
4998         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4999         int64_t commitment_tx_ref = 0;
5000         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
5001         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5002         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5003         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5004         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
5005         if (commitment_tx_var.is_owned) {
5006                 commitment_tx_ref |= 1;
5007         }
5008         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5009         CHECK(obj != NULL);
5010         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
5011         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5012                 (*env)->ExceptionDescribe(env);
5013                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
5014         }
5015         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5016         CHECK_ACCESS(ret_ptr);
5017         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5018         FREE((void*)ret);
5019         if (get_jenv_res == JNI_EDETACHED) {
5020                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5021         }
5022         return ret_conv;
5023 }
5024 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]) {
5025         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5026         JNIEnv *env;
5027         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5028         if (get_jenv_res == JNI_EDETACHED) {
5029                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5030         } else {
5031                 DO_ASSERT(get_jenv_res == JNI_OK);
5032         }
5033         LDKTransaction justice_tx_var = justice_tx;
5034         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5035         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5036         Transaction_free(justice_tx_var);
5037         int64_t input_conv = input;
5038         int64_t amount_conv = amount;
5039         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5040         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5041         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5042         CHECK(obj != NULL);
5043         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);
5044         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5045                 (*env)->ExceptionDescribe(env);
5046                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
5047         }
5048         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5049         CHECK_ACCESS(ret_ptr);
5050         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5051         FREE((void*)ret);
5052         if (get_jenv_res == JNI_EDETACHED) {
5053                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5054         }
5055         return ret_conv;
5056 }
5057 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) {
5058         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5059         JNIEnv *env;
5060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5061         if (get_jenv_res == JNI_EDETACHED) {
5062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5063         } else {
5064                 DO_ASSERT(get_jenv_res == JNI_OK);
5065         }
5066         LDKTransaction justice_tx_var = justice_tx;
5067         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5068         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5069         Transaction_free(justice_tx_var);
5070         int64_t input_conv = input;
5071         int64_t amount_conv = amount;
5072         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5073         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5074         LDKHTLCOutputInCommitment htlc_var = *htlc;
5075         int64_t htlc_ref = 0;
5076         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5077         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5078         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5079         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5080         htlc_ref = (uintptr_t)htlc_var.inner;
5081         if (htlc_var.is_owned) {
5082                 htlc_ref |= 1;
5083         }
5084         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5085         CHECK(obj != NULL);
5086         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);
5087         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5088                 (*env)->ExceptionDescribe(env);
5089                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
5090         }
5091         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5092         CHECK_ACCESS(ret_ptr);
5093         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5094         FREE((void*)ret);
5095         if (get_jenv_res == JNI_EDETACHED) {
5096                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5097         }
5098         return ret_conv;
5099 }
5100 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) {
5101         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5102         JNIEnv *env;
5103         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5104         if (get_jenv_res == JNI_EDETACHED) {
5105                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5106         } else {
5107                 DO_ASSERT(get_jenv_res == JNI_OK);
5108         }
5109         LDKTransaction htlc_tx_var = htlc_tx;
5110         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
5111         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
5112         Transaction_free(htlc_tx_var);
5113         int64_t input_conv = input;
5114         int64_t amount_conv = amount;
5115         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
5116         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
5117         LDKHTLCOutputInCommitment htlc_var = *htlc;
5118         int64_t htlc_ref = 0;
5119         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5120         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5121         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5122         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5123         htlc_ref = (uintptr_t)htlc_var.inner;
5124         if (htlc_var.is_owned) {
5125                 htlc_ref |= 1;
5126         }
5127         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5128         CHECK(obj != NULL);
5129         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);
5130         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5131                 (*env)->ExceptionDescribe(env);
5132                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
5133         }
5134         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5135         CHECK_ACCESS(ret_ptr);
5136         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5137         FREE((void*)ret);
5138         if (get_jenv_res == JNI_EDETACHED) {
5139                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5140         }
5141         return ret_conv;
5142 }
5143 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
5144         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5145         JNIEnv *env;
5146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5147         if (get_jenv_res == JNI_EDETACHED) {
5148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5149         } else {
5150                 DO_ASSERT(get_jenv_res == JNI_OK);
5151         }
5152         LDKClosingTransaction closing_tx_var = *closing_tx;
5153         int64_t closing_tx_ref = 0;
5154         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
5155         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5156         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5157         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
5158         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
5159         if (closing_tx_var.is_owned) {
5160                 closing_tx_ref |= 1;
5161         }
5162         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5163         CHECK(obj != NULL);
5164         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
5165         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5166                 (*env)->ExceptionDescribe(env);
5167                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
5168         }
5169         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5170         CHECK_ACCESS(ret_ptr);
5171         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5172         FREE((void*)ret);
5173         if (get_jenv_res == JNI_EDETACHED) {
5174                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5175         }
5176         return ret_conv;
5177 }
5178 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
5179         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5180         JNIEnv *env;
5181         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5182         if (get_jenv_res == JNI_EDETACHED) {
5183                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5184         } else {
5185                 DO_ASSERT(get_jenv_res == JNI_OK);
5186         }
5187         LDKUnsignedChannelAnnouncement msg_var = *msg;
5188         int64_t msg_ref = 0;
5189         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
5190         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5191         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5192         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
5193         msg_ref = (uintptr_t)msg_var.inner;
5194         if (msg_var.is_owned) {
5195                 msg_ref |= 1;
5196         }
5197         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5198         CHECK(obj != NULL);
5199         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
5200         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5201                 (*env)->ExceptionDescribe(env);
5202                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5203         }
5204         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5205         CHECK_ACCESS(ret_ptr);
5206         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5207         FREE((void*)ret);
5208         if (get_jenv_res == JNI_EDETACHED) {
5209                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5210         }
5211         return ret_conv;
5212 }
5213 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5214         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5215         JNIEnv *env;
5216         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5217         if (get_jenv_res == JNI_EDETACHED) {
5218                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5219         } else {
5220                 DO_ASSERT(get_jenv_res == JNI_OK);
5221         }
5222         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5223         int64_t channel_parameters_ref = 0;
5224         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5225         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5226         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5227         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5228         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
5229         if (channel_parameters_var.is_owned) {
5230                 channel_parameters_ref |= 1;
5231         }
5232         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5233         CHECK(obj != NULL);
5234         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
5235         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5236                 (*env)->ExceptionDescribe(env);
5237                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
5238         }
5239         if (get_jenv_res == JNI_EDETACHED) {
5240                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5241         }
5242 }
5243 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5244         jclass c = (*env)->GetObjectClass(env, o);
5245         CHECK(c != NULL);
5246         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5247         atomic_init(&calls->refcnt, 1);
5248         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5249         calls->o = (*env)->NewWeakGlobalRef(env, o);
5250         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5251         CHECK(calls->get_per_commitment_point_meth != NULL);
5252         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5253         CHECK(calls->release_commitment_secret_meth != NULL);
5254         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5255         CHECK(calls->validate_holder_commitment_meth != NULL);
5256         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5257         CHECK(calls->channel_keys_id_meth != NULL);
5258         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5259         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5260         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5261         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5262         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5263         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5264         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5265         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5266         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5267         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5268         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5269         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5270         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5271         CHECK(calls->sign_closing_transaction_meth != NULL);
5272         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5273         CHECK(calls->sign_channel_announcement_meth != NULL);
5274         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
5275         CHECK(calls->ready_channel_meth != NULL);
5276
5277         LDKChannelPublicKeys pubkeys_conv;
5278         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5279         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5280         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5281
5282         LDKBaseSign ret = {
5283                 .this_arg = (void*) calls,
5284                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5285                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5286                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5287                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5288                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5289                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5290                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5291                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5292                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5293                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5294                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5295                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5296                 .ready_channel = ready_channel_LDKBaseSign_jcall,
5297                 .free = LDKBaseSign_JCalls_free,
5298                 .pubkeys = pubkeys_conv,
5299                 .set_pubkeys = NULL,
5300         };
5301         return ret;
5302 }
5303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5304         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5305         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5306         return (uint64_t)res_ptr;
5307 }
5308 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) {
5309         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5310         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5311         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5312         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5313         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5314         return ret_arr;
5315 }
5316
5317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5318         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5319         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5320         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5321         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5322         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5323         return ret_arr;
5324 }
5325
5326 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) {
5327         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5328         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5329         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5330         LDKHolderCommitmentTransaction holder_tx_conv;
5331         holder_tx_conv.inner = (void*)(holder_tx & (~1));
5332         holder_tx_conv.is_owned = false;
5333         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5334         LDKCVec_PaymentPreimageZ preimages_constr;
5335         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5336         if (preimages_constr.datalen > 0)
5337                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5338         else
5339                 preimages_constr.data = NULL;
5340         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5341                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5342                 LDKThirtyTwoBytes preimages_conv_8_ref;
5343                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5344                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5345                 preimages_constr.data[i] = preimages_conv_8_ref;
5346         }
5347         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5348         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5349         return (int64_t)ret_conv;
5350 }
5351
5352 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5353         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5354         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5355         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5356         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5357         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5358         return ret_arr;
5359 }
5360
5361 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) {
5362         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5363         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5364         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5365         LDKCommitmentTransaction commitment_tx_conv;
5366         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5367         commitment_tx_conv.is_owned = false;
5368         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5369         LDKCVec_PaymentPreimageZ preimages_constr;
5370         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5371         if (preimages_constr.datalen > 0)
5372                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5373         else
5374                 preimages_constr.data = NULL;
5375         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5376                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5377                 LDKThirtyTwoBytes preimages_conv_8_ref;
5378                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5379                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5380                 preimages_constr.data[i] = preimages_conv_8_ref;
5381         }
5382         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5383         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5384         return (int64_t)ret_conv;
5385 }
5386
5387 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) {
5388         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5389         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5390         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5391         unsigned char secret_arr[32];
5392         CHECK((*env)->GetArrayLength(env, secret) == 32);
5393         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5394         unsigned char (*secret_ref)[32] = &secret_arr;
5395         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5396         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5397         return (int64_t)ret_conv;
5398 }
5399
5400 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) {
5401         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5402         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5403         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5404         LDKHolderCommitmentTransaction commitment_tx_conv;
5405         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5406         commitment_tx_conv.is_owned = false;
5407         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5408         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5409         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5410         return (int64_t)ret_conv;
5411 }
5412
5413 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) {
5414         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5415         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5416         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5417         LDKTransaction justice_tx_ref;
5418         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5419         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5420         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5421         justice_tx_ref.data_is_owned = true;
5422         unsigned char per_commitment_key_arr[32];
5423         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5424         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5425         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5426         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5427         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5428         return (int64_t)ret_conv;
5429 }
5430
5431 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) {
5432         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5433         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5434         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5435         LDKTransaction justice_tx_ref;
5436         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5437         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5438         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5439         justice_tx_ref.data_is_owned = true;
5440         unsigned char per_commitment_key_arr[32];
5441         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5442         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5443         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5444         LDKHTLCOutputInCommitment htlc_conv;
5445         htlc_conv.inner = (void*)(htlc & (~1));
5446         htlc_conv.is_owned = false;
5447         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5448         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5449         *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);
5450         return (int64_t)ret_conv;
5451 }
5452
5453 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) {
5454         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5455         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5456         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5457         LDKTransaction htlc_tx_ref;
5458         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5459         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5460         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5461         htlc_tx_ref.data_is_owned = true;
5462         LDKPublicKey per_commitment_point_ref;
5463         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5464         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5465         LDKHTLCOutputInCommitment htlc_conv;
5466         htlc_conv.inner = (void*)(htlc & (~1));
5467         htlc_conv.is_owned = false;
5468         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5469         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5470         *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);
5471         return (int64_t)ret_conv;
5472 }
5473
5474 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) {
5475         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5476         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5477         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5478         LDKClosingTransaction closing_tx_conv;
5479         closing_tx_conv.inner = (void*)(closing_tx & (~1));
5480         closing_tx_conv.is_owned = false;
5481         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5482         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5483         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5484         return (int64_t)ret_conv;
5485 }
5486
5487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5488         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5489         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5490         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5491         LDKUnsignedChannelAnnouncement msg_conv;
5492         msg_conv.inner = (void*)(msg & (~1));
5493         msg_conv.is_owned = false;
5494         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5495         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5496         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5497         return (int64_t)ret_conv;
5498 }
5499
5500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5501         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5502         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5503         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5504         LDKChannelTransactionParameters channel_parameters_conv;
5505         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
5506         channel_parameters_conv.is_owned = false;
5507         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5508         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5509 }
5510
5511 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5512         if (this_arg->set_pubkeys != NULL)
5513                 this_arg->set_pubkeys(this_arg);
5514         return this_arg->pubkeys;
5515 }
5516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5517         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5518         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5519         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5520         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5521         int64_t ret_ref = 0;
5522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5525         ret_ref = (uintptr_t)ret_var.inner;
5526         if (ret_var.is_owned) {
5527                 ret_ref |= 1;
5528         }
5529         return ret_ref;
5530 }
5531
5532 typedef struct LDKSign_JCalls {
5533         atomic_size_t refcnt;
5534         JavaVM *vm;
5535         jweak o;
5536         LDKBaseSign_JCalls* BaseSign;
5537         jmethodID write_meth;
5538 } LDKSign_JCalls;
5539 static void LDKSign_JCalls_free(void* this_arg) {
5540         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5541         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5542                 JNIEnv *env;
5543                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5544                 if (get_jenv_res == JNI_EDETACHED) {
5545                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5546                 } else {
5547                         DO_ASSERT(get_jenv_res == JNI_OK);
5548                 }
5549                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5550                 if (get_jenv_res == JNI_EDETACHED) {
5551                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5552                 }
5553                 FREE(j_calls);
5554         }
5555 }
5556 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5557         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5558         JNIEnv *env;
5559         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5560         if (get_jenv_res == JNI_EDETACHED) {
5561                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5562         } else {
5563                 DO_ASSERT(get_jenv_res == JNI_OK);
5564         }
5565         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5566         CHECK(obj != NULL);
5567         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5568         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5569                 (*env)->ExceptionDescribe(env);
5570                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5571         }
5572         LDKCVec_u8Z ret_ref;
5573         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5574         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5575         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5576         if (get_jenv_res == JNI_EDETACHED) {
5577                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5578         }
5579         return ret_ref;
5580 }
5581 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5582         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5583         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5584         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5585 }
5586 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5587         jclass c = (*env)->GetObjectClass(env, o);
5588         CHECK(c != NULL);
5589         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
5590         atomic_init(&calls->refcnt, 1);
5591         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5592         calls->o = (*env)->NewWeakGlobalRef(env, o);
5593         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5594         CHECK(calls->write_meth != NULL);
5595
5596         LDKChannelPublicKeys pubkeys_conv;
5597         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5598         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5599         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5600
5601         LDKSign ret = {
5602                 .this_arg = (void*) calls,
5603                 .write = write_LDKSign_jcall,
5604                 .cloned = LDKSign_JCalls_cloned,
5605                 .free = LDKSign_JCalls_free,
5606                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
5607         };
5608         calls->BaseSign = ret.BaseSign.this_arg;
5609         return ret;
5610 }
5611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5612         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
5613         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
5614         return (uint64_t)res_ptr;
5615 }
5616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
5617         LDKSign *inp = (LDKSign *)(arg & ~1);
5618         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
5619         DO_ASSERT((res_ptr & 1) == 0);
5620         return (int64_t)(res_ptr | 1);
5621 }
5622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5623         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5624         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5625         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
5626         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5627         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5628         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5629         CVec_u8Z_free(ret_var);
5630         return ret_arr;
5631 }
5632
5633 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5634 CHECK(owner->result_ok);
5635         return Sign_clone(&*owner->contents.result);
5636 }
5637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5638         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5639         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5640         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5641         return (int64_t)ret_ret;
5642 }
5643
5644 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5645 CHECK(!owner->result_ok);
5646         return DecodeError_clone(&*owner->contents.err);
5647 }
5648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5649         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5650         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5651         int64_t ret_ref = 0;
5652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5655         ret_ref = (uintptr_t)ret_var.inner;
5656         if (ret_var.is_owned) {
5657                 ret_ref |= 1;
5658         }
5659         return ret_ref;
5660 }
5661
5662 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5663 CHECK(owner->result_ok);
5664         return *owner->contents.result;
5665 }
5666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5667         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5668         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5669         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5670         return ret_arr;
5671 }
5672
5673 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5674 CHECK(!owner->result_ok);
5675         return *owner->contents.err;
5676 }
5677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5678         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5679         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5680 }
5681
5682 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5683         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5684         for (size_t i = 0; i < ret.datalen; i++) {
5685                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5686         }
5687         return ret;
5688 }
5689 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5690 CHECK(owner->result_ok);
5691         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5692 }
5693 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5694         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5695         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5696         jobjectArray ret_arr = NULL;
5697         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5698         ;
5699         for (size_t i = 0; i < ret_var.datalen; i++) {
5700                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
5701                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
5702                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
5703                 CVec_u8Z_free(ret_conv_8_var);
5704                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5705         }
5706         
5707         FREE(ret_var.data);
5708         return ret_arr;
5709 }
5710
5711 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5712 CHECK(!owner->result_ok);
5713         return *owner->contents.err;
5714 }
5715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5716         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5717         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5718 }
5719
5720 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5721 CHECK(owner->result_ok);
5722         return InMemorySigner_clone(&*owner->contents.result);
5723 }
5724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5725         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5726         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5727         int64_t ret_ref = 0;
5728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5731         ret_ref = (uintptr_t)ret_var.inner;
5732         if (ret_var.is_owned) {
5733                 ret_ref |= 1;
5734         }
5735         return ret_ref;
5736 }
5737
5738 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5739 CHECK(!owner->result_ok);
5740         return DecodeError_clone(&*owner->contents.err);
5741 }
5742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5743         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5744         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5745         int64_t ret_ref = 0;
5746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5749         ret_ref = (uintptr_t)ret_var.inner;
5750         if (ret_var.is_owned) {
5751                 ret_ref |= 1;
5752         }
5753         return ret_ref;
5754 }
5755
5756 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5757         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5758         for (size_t i = 0; i < ret.datalen; i++) {
5759                 ret.data[i] = TxOut_clone(&orig->data[i]);
5760         }
5761         return ret;
5762 }
5763 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5764 CHECK(owner->result_ok);
5765         return *owner->contents.result;
5766 }
5767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5768         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5769         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5770         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5771         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5772         return ret_arr;
5773 }
5774
5775 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5776 CHECK(!owner->result_ok);
5777         return *owner->contents.err;
5778 }
5779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5780         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5781         CResult_TransactionNoneZ_get_err(owner_conv);
5782 }
5783
5784 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5785         return ThirtyTwoBytes_clone(&owner->a);
5786 }
5787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5788         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5789         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
5791         return ret_arr;
5792 }
5793
5794 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5795         return ChannelMonitor_clone(&owner->b);
5796 }
5797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5798         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5799         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5800         int64_t ret_ref = 0;
5801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5804         ret_ref = (uintptr_t)ret_var.inner;
5805         if (ret_var.is_owned) {
5806                 ret_ref |= 1;
5807         }
5808         return ret_ref;
5809 }
5810
5811 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
5812         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
5813         for (size_t i = 0; i < ret.datalen; i++) {
5814                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
5815         }
5816         return ret;
5817 }
5818 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5819 CHECK(owner->result_ok);
5820         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
5821 }
5822 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5823         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5824         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
5825         int64_tArray ret_arr = NULL;
5826         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5827         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5828         for (size_t j = 0; j < ret_var.datalen; j++) {
5829                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5830                 *ret_conv_35_conv = ret_var.data[j];
5831                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
5832         }
5833         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5834         FREE(ret_var.data);
5835         return ret_arr;
5836 }
5837
5838 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5839 CHECK(!owner->result_ok);
5840         return *owner->contents.err;
5841 }
5842 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5843         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5844         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
5845         return ret_conv;
5846 }
5847
5848 static jclass LDKCOption_u16Z_Some_class = NULL;
5849 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
5850 static jclass LDKCOption_u16Z_None_class = NULL;
5851 static jmethodID LDKCOption_u16Z_None_meth = NULL;
5852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
5853         LDKCOption_u16Z_Some_class =
5854                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
5855         CHECK(LDKCOption_u16Z_Some_class != NULL);
5856         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
5857         CHECK(LDKCOption_u16Z_Some_meth != NULL);
5858         LDKCOption_u16Z_None_class =
5859                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
5860         CHECK(LDKCOption_u16Z_None_class != NULL);
5861         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
5862         CHECK(LDKCOption_u16Z_None_meth != NULL);
5863 }
5864 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5865         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5866         switch(obj->tag) {
5867                 case LDKCOption_u16Z_Some: {
5868                         int16_t some_conv = obj->some;
5869                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
5870                 }
5871                 case LDKCOption_u16Z_None: {
5872                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
5873                 }
5874                 default: abort();
5875         }
5876 }
5877 static jclass LDKAPIError_APIMisuseError_class = NULL;
5878 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
5879 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
5880 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
5881 static jclass LDKAPIError_RouteError_class = NULL;
5882 static jmethodID LDKAPIError_RouteError_meth = NULL;
5883 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
5884 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
5885 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
5886 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
5887 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
5888 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
5889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
5890         LDKAPIError_APIMisuseError_class =
5891                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
5892         CHECK(LDKAPIError_APIMisuseError_class != NULL);
5893         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
5894         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
5895         LDKAPIError_FeeRateTooHigh_class =
5896                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
5897         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
5898         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
5899         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
5900         LDKAPIError_RouteError_class =
5901                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
5902         CHECK(LDKAPIError_RouteError_class != NULL);
5903         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
5904         CHECK(LDKAPIError_RouteError_meth != NULL);
5905         LDKAPIError_ChannelUnavailable_class =
5906                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
5907         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
5908         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
5909         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
5910         LDKAPIError_MonitorUpdateFailed_class =
5911                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
5912         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
5913         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
5914         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
5915         LDKAPIError_IncompatibleShutdownScript_class =
5916                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
5917         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
5918         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
5919         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
5920 }
5921 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5922         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5923         switch(obj->tag) {
5924                 case LDKAPIError_APIMisuseError: {
5925                         LDKStr err_str = obj->api_misuse_error.err;
5926                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5927                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
5928                 }
5929                 case LDKAPIError_FeeRateTooHigh: {
5930                         LDKStr err_str = obj->fee_rate_too_high.err;
5931                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5932                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
5933                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
5934                 }
5935                 case LDKAPIError_RouteError: {
5936                         LDKStr err_str = obj->route_error.err;
5937                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5938                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
5939                 }
5940                 case LDKAPIError_ChannelUnavailable: {
5941                         LDKStr err_str = obj->channel_unavailable.err;
5942                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5943                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
5944                 }
5945                 case LDKAPIError_MonitorUpdateFailed: {
5946                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
5947                 }
5948                 case LDKAPIError_IncompatibleShutdownScript: {
5949                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5950                         int64_t script_ref = 0;
5951                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5952                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5953                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5954                         script_ref = (uintptr_t)script_var.inner & ~1;
5955                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
5956                 }
5957                 default: abort();
5958         }
5959 }
5960 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5961 CHECK(owner->result_ok);
5962         return *owner->contents.result;
5963 }
5964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5965         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5966         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5967 }
5968
5969 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5970 CHECK(!owner->result_ok);
5971         return APIError_clone(&*owner->contents.err);
5972 }
5973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5974         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5975         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5976         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5977         int64_t ret_ref = (uintptr_t)ret_copy;
5978         return ret_ref;
5979 }
5980
5981 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5982         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5983         for (size_t i = 0; i < ret.datalen; i++) {
5984                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5985         }
5986         return ret;
5987 }
5988 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5989         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5990         for (size_t i = 0; i < ret.datalen; i++) {
5991                 ret.data[i] = APIError_clone(&orig->data[i]);
5992         }
5993         return ret;
5994 }
5995 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5996 CHECK(owner->result_ok);
5997         return ThirtyTwoBytes_clone(&*owner->contents.result);
5998 }
5999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6000         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
6001         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6002         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6003         return ret_arr;
6004 }
6005
6006 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6007 CHECK(!owner->result_ok);
6008         return APIError_clone(&*owner->contents.err);
6009 }
6010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6011         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
6012         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6013         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6014         int64_t ret_ref = (uintptr_t)ret_copy;
6015         return ret_ref;
6016 }
6017
6018 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
6019 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
6020 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
6021 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
6022 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
6023 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
6024 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
6025 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
6026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
6027         LDKPaymentSendFailure_ParameterError_class =
6028                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
6029         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
6030         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
6031         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
6032         LDKPaymentSendFailure_PathParameterError_class =
6033                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
6034         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
6035         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
6036         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
6037         LDKPaymentSendFailure_AllFailedRetrySafe_class =
6038                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
6039         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
6040         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
6041         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
6042         LDKPaymentSendFailure_PartialFailure_class =
6043                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
6044         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
6045         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
6046         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
6047 }
6048 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6049         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6050         switch(obj->tag) {
6051                 case LDKPaymentSendFailure_ParameterError: {
6052                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
6053                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
6054                 }
6055                 case LDKPaymentSendFailure_PathParameterError: {
6056                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
6057                         int64_tArray path_parameter_error_arr = NULL;
6058                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
6059                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
6060                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
6061                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6062                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
6063                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
6064                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
6065                         }
6066                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
6067                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
6068                 }
6069                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
6070                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
6071                         int64_tArray all_failed_retry_safe_arr = NULL;
6072                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
6073                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
6074                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
6075                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
6076                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
6077                         }
6078                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
6079                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
6080                 }
6081                 case LDKPaymentSendFailure_PartialFailure: {
6082                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6083                         int64_tArray results_arr = NULL;
6084                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
6085                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
6086                         for (size_t w = 0; w < results_var.datalen; w++) {
6087                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6088                                 *results_conv_22_conv = results_var.data[w];
6089                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6090                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
6091                         }
6092                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
6093                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6094                         int64_t failed_paths_retry_ref = 0;
6095                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
6096                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6097                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6098                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6099                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
6100                         }
6101                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
6102                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
6103                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
6104                 }
6105                 default: abort();
6106         }
6107 }
6108 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6109 CHECK(owner->result_ok);
6110         return ThirtyTwoBytes_clone(&*owner->contents.result);
6111 }
6112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6113         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6114         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6115         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
6116         return ret_arr;
6117 }
6118
6119 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6120 CHECK(!owner->result_ok);
6121         return PaymentSendFailure_clone(&*owner->contents.err);
6122 }
6123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6124         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6125         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6126         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
6127         int64_t ret_ref = (uintptr_t)ret_copy;
6128         return ret_ref;
6129 }
6130
6131 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6132 CHECK(owner->result_ok);
6133         return *owner->contents.result;
6134 }
6135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6136         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6137         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6138 }
6139
6140 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6141 CHECK(!owner->result_ok);
6142         return PaymentSendFailure_clone(&*owner->contents.err);
6143 }
6144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6145         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6146         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6147         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6148         int64_t ret_ref = (uintptr_t)ret_copy;
6149         return ret_ref;
6150 }
6151
6152 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6153         return ThirtyTwoBytes_clone(&owner->a);
6154 }
6155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6156         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6157         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6158         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
6159         return ret_arr;
6160 }
6161
6162 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6163         return ThirtyTwoBytes_clone(&owner->b);
6164 }
6165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6166         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6167         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
6169         return ret_arr;
6170 }
6171
6172 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6173 CHECK(owner->result_ok);
6174         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6175 }
6176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6177         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6178         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6179         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6180         return ((int64_t)ret_conv);
6181 }
6182
6183 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6184 CHECK(!owner->result_ok);
6185         return PaymentSendFailure_clone(&*owner->contents.err);
6186 }
6187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6188         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6189         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6190         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6191         int64_t ret_ref = (uintptr_t)ret_copy;
6192         return ret_ref;
6193 }
6194
6195 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
6196         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
6197         for (size_t i = 0; i < ret.datalen; i++) {
6198                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
6199         }
6200         return ret;
6201 }
6202 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6203         return ThirtyTwoBytes_clone(&owner->a);
6204 }
6205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6206         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6207         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6208         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6209         return ret_arr;
6210 }
6211
6212 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6213         return ThirtyTwoBytes_clone(&owner->b);
6214 }
6215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6216         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6217         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6219         return ret_arr;
6220 }
6221
6222 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6223 CHECK(owner->result_ok);
6224         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6225 }
6226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6227         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6228         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6229         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6230         return ((int64_t)ret_conv);
6231 }
6232
6233 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6234 CHECK(!owner->result_ok);
6235         return *owner->contents.err;
6236 }
6237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6238         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6239         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6240 }
6241
6242 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6243 CHECK(owner->result_ok);
6244         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6245 }
6246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6247         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6248         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6249         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6250         return ((int64_t)ret_conv);
6251 }
6252
6253 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6254 CHECK(!owner->result_ok);
6255         return APIError_clone(&*owner->contents.err);
6256 }
6257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6258         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6259         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6260         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6261         int64_t ret_ref = (uintptr_t)ret_copy;
6262         return ret_ref;
6263 }
6264
6265 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6266 CHECK(owner->result_ok);
6267         return ThirtyTwoBytes_clone(&*owner->contents.result);
6268 }
6269 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6270         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6271         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6272         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6273         return ret_arr;
6274 }
6275
6276 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6277 CHECK(!owner->result_ok);
6278         return *owner->contents.err;
6279 }
6280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6281         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6282         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6283 }
6284
6285 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6286 CHECK(owner->result_ok);
6287         return ThirtyTwoBytes_clone(&*owner->contents.result);
6288 }
6289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6290         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6291         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6292         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6293         return ret_arr;
6294 }
6295
6296 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6297 CHECK(!owner->result_ok);
6298         return APIError_clone(&*owner->contents.err);
6299 }
6300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6301         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6302         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6303         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6304         int64_t ret_ref = (uintptr_t)ret_copy;
6305         return ret_ref;
6306 }
6307
6308 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6309 CHECK(owner->result_ok);
6310         return ThirtyTwoBytes_clone(&*owner->contents.result);
6311 }
6312 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6313         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6314         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6315         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6316         return ret_arr;
6317 }
6318
6319 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6320 CHECK(!owner->result_ok);
6321         return APIError_clone(&*owner->contents.err);
6322 }
6323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6324         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6325         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6326         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6327         int64_t ret_ref = (uintptr_t)ret_copy;
6328         return ret_ref;
6329 }
6330
6331 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6332 CHECK(owner->result_ok);
6333         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
6334 }
6335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6336         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6337         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6338         int64_t ret_ref = 0;
6339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6342         ret_ref = (uintptr_t)ret_var.inner;
6343         if (ret_var.is_owned) {
6344                 ret_ref |= 1;
6345         }
6346         return ret_ref;
6347 }
6348
6349 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6350 CHECK(!owner->result_ok);
6351         return DecodeError_clone(&*owner->contents.err);
6352 }
6353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6354         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6355         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6356         int64_t ret_ref = 0;
6357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6360         ret_ref = (uintptr_t)ret_var.inner;
6361         if (ret_var.is_owned) {
6362                 ret_ref |= 1;
6363         }
6364         return ret_ref;
6365 }
6366
6367 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6368 CHECK(owner->result_ok);
6369         return ChannelCounterparty_clone(&*owner->contents.result);
6370 }
6371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6372         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6373         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6374         int64_t ret_ref = 0;
6375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6378         ret_ref = (uintptr_t)ret_var.inner;
6379         if (ret_var.is_owned) {
6380                 ret_ref |= 1;
6381         }
6382         return ret_ref;
6383 }
6384
6385 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6386 CHECK(!owner->result_ok);
6387         return DecodeError_clone(&*owner->contents.err);
6388 }
6389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6390         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6391         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6392         int64_t ret_ref = 0;
6393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6396         ret_ref = (uintptr_t)ret_var.inner;
6397         if (ret_var.is_owned) {
6398                 ret_ref |= 1;
6399         }
6400         return ret_ref;
6401 }
6402
6403 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6404 CHECK(owner->result_ok);
6405         return ChannelDetails_clone(&*owner->contents.result);
6406 }
6407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6408         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6409         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6410         int64_t ret_ref = 0;
6411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6414         ret_ref = (uintptr_t)ret_var.inner;
6415         if (ret_var.is_owned) {
6416                 ret_ref |= 1;
6417         }
6418         return ret_ref;
6419 }
6420
6421 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6422 CHECK(!owner->result_ok);
6423         return DecodeError_clone(&*owner->contents.err);
6424 }
6425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6426         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6427         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6428         int64_t ret_ref = 0;
6429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6432         ret_ref = (uintptr_t)ret_var.inner;
6433         if (ret_var.is_owned) {
6434                 ret_ref |= 1;
6435         }
6436         return ret_ref;
6437 }
6438
6439 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6440 CHECK(owner->result_ok);
6441         return PhantomRouteHints_clone(&*owner->contents.result);
6442 }
6443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6444         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6445         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6446         int64_t ret_ref = 0;
6447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6450         ret_ref = (uintptr_t)ret_var.inner;
6451         if (ret_var.is_owned) {
6452                 ret_ref |= 1;
6453         }
6454         return ret_ref;
6455 }
6456
6457 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6458 CHECK(!owner->result_ok);
6459         return DecodeError_clone(&*owner->contents.err);
6460 }
6461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6462         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6463         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6464         int64_t ret_ref = 0;
6465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6468         ret_ref = (uintptr_t)ret_var.inner;
6469         if (ret_var.is_owned) {
6470                 ret_ref |= 1;
6471         }
6472         return ret_ref;
6473 }
6474
6475 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6476         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6477         for (size_t i = 0; i < ret.datalen; i++) {
6478                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6479         }
6480         return ret;
6481 }
6482 typedef struct LDKWatch_JCalls {
6483         atomic_size_t refcnt;
6484         JavaVM *vm;
6485         jweak o;
6486         jmethodID watch_channel_meth;
6487         jmethodID update_channel_meth;
6488         jmethodID release_pending_monitor_events_meth;
6489 } LDKWatch_JCalls;
6490 static void LDKWatch_JCalls_free(void* this_arg) {
6491         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6492         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6493                 JNIEnv *env;
6494                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6495                 if (get_jenv_res == JNI_EDETACHED) {
6496                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6497                 } else {
6498                         DO_ASSERT(get_jenv_res == JNI_OK);
6499                 }
6500                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6501                 if (get_jenv_res == JNI_EDETACHED) {
6502                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6503                 }
6504                 FREE(j_calls);
6505         }
6506 }
6507 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6508         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6509         JNIEnv *env;
6510         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6511         if (get_jenv_res == JNI_EDETACHED) {
6512                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6513         } else {
6514                 DO_ASSERT(get_jenv_res == JNI_OK);
6515         }
6516         LDKOutPoint funding_txo_var = funding_txo;
6517         int64_t funding_txo_ref = 0;
6518         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6519         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6520         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6521         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6522         if (funding_txo_var.is_owned) {
6523                 funding_txo_ref |= 1;
6524         }
6525         LDKChannelMonitor monitor_var = monitor;
6526         int64_t monitor_ref = 0;
6527         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6528         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6529         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6530         monitor_ref = (uintptr_t)monitor_var.inner;
6531         if (monitor_var.is_owned) {
6532                 monitor_ref |= 1;
6533         }
6534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6535         CHECK(obj != NULL);
6536         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
6537         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6538                 (*env)->ExceptionDescribe(env);
6539                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
6540         }
6541         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6542         CHECK_ACCESS(ret_ptr);
6543         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6544         FREE((void*)ret);
6545         if (get_jenv_res == JNI_EDETACHED) {
6546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6547         }
6548         return ret_conv;
6549 }
6550 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6551         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6552         JNIEnv *env;
6553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6554         if (get_jenv_res == JNI_EDETACHED) {
6555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6556         } else {
6557                 DO_ASSERT(get_jenv_res == JNI_OK);
6558         }
6559         LDKOutPoint funding_txo_var = funding_txo;
6560         int64_t funding_txo_ref = 0;
6561         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6562         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6563         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6564         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6565         if (funding_txo_var.is_owned) {
6566                 funding_txo_ref |= 1;
6567         }
6568         LDKChannelMonitorUpdate update_var = update;
6569         int64_t update_ref = 0;
6570         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6571         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6572         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6573         update_ref = (uintptr_t)update_var.inner;
6574         if (update_var.is_owned) {
6575                 update_ref |= 1;
6576         }
6577         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6578         CHECK(obj != NULL);
6579         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6580         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6581                 (*env)->ExceptionDescribe(env);
6582                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6583         }
6584         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6585         CHECK_ACCESS(ret_ptr);
6586         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6587         FREE((void*)ret);
6588         if (get_jenv_res == JNI_EDETACHED) {
6589                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6590         }
6591         return ret_conv;
6592 }
6593 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6594         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6595         JNIEnv *env;
6596         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6597         if (get_jenv_res == JNI_EDETACHED) {
6598                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6599         } else {
6600                 DO_ASSERT(get_jenv_res == JNI_OK);
6601         }
6602         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6603         CHECK(obj != NULL);
6604         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6605         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6606                 (*env)->ExceptionDescribe(env);
6607                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6608         }
6609         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
6610         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6611         if (ret_constr.datalen > 0)
6612                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
6613         else
6614                 ret_constr.data = NULL;
6615         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6616         for (size_t x = 0; x < ret_constr.datalen; x++) {
6617                 int64_t ret_conv_49 = ret_vals[x];
6618                 void* ret_conv_49_ptr = (void*)(((uintptr_t)ret_conv_49) & ~1);
6619                 CHECK_ACCESS(ret_conv_49_ptr);
6620                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
6621                 FREE((void*)ret_conv_49);
6622                 ret_constr.data[x] = ret_conv_49_conv;
6623         }
6624         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6625         if (get_jenv_res == JNI_EDETACHED) {
6626                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6627         }
6628         return ret_constr;
6629 }
6630 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6631         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6632         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6633 }
6634 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6635         jclass c = (*env)->GetObjectClass(env, o);
6636         CHECK(c != NULL);
6637         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6638         atomic_init(&calls->refcnt, 1);
6639         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6640         calls->o = (*env)->NewWeakGlobalRef(env, o);
6641         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
6642         CHECK(calls->watch_channel_meth != NULL);
6643         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
6644         CHECK(calls->update_channel_meth != NULL);
6645         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6646         CHECK(calls->release_pending_monitor_events_meth != NULL);
6647
6648         LDKWatch ret = {
6649                 .this_arg = (void*) calls,
6650                 .watch_channel = watch_channel_LDKWatch_jcall,
6651                 .update_channel = update_channel_LDKWatch_jcall,
6652                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6653                 .free = LDKWatch_JCalls_free,
6654         };
6655         return ret;
6656 }
6657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6658         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6659         *res_ptr = LDKWatch_init(env, clz, o);
6660         return (uint64_t)res_ptr;
6661 }
6662 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) {
6663         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6664         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6665         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6666         LDKOutPoint funding_txo_conv;
6667         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6668         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6669         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6670         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6671         LDKChannelMonitor monitor_conv;
6672         monitor_conv.inner = (void*)(monitor & (~1));
6673         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
6674         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6675         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6676         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6677         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6678         return (int64_t)ret_conv;
6679 }
6680
6681 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) {
6682         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6683         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6684         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6685         LDKOutPoint funding_txo_conv;
6686         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6687         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6688         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6689         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6690         LDKChannelMonitorUpdate update_conv;
6691         update_conv.inner = (void*)(update & (~1));
6692         update_conv.is_owned = (update & 1) || (update == 0);
6693         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6694         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6695         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6696         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6697         return (int64_t)ret_conv;
6698 }
6699
6700 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6701         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6702         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6703         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6704         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6705         int64_tArray ret_arr = NULL;
6706         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6707         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6708         for (size_t x = 0; x < ret_var.datalen; x++) {
6709                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
6710                 *ret_conv_49_conv = ret_var.data[x];
6711                 ret_arr_ptr[x] = ((int64_t)ret_conv_49_conv);
6712         }
6713         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6714         FREE(ret_var.data);
6715         return ret_arr;
6716 }
6717
6718 typedef struct LDKBroadcasterInterface_JCalls {
6719         atomic_size_t refcnt;
6720         JavaVM *vm;
6721         jweak o;
6722         jmethodID broadcast_transaction_meth;
6723 } LDKBroadcasterInterface_JCalls;
6724 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6725         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6726         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6727                 JNIEnv *env;
6728                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6729                 if (get_jenv_res == JNI_EDETACHED) {
6730                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6731                 } else {
6732                         DO_ASSERT(get_jenv_res == JNI_OK);
6733                 }
6734                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6735                 if (get_jenv_res == JNI_EDETACHED) {
6736                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6737                 }
6738                 FREE(j_calls);
6739         }
6740 }
6741 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6742         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6743         JNIEnv *env;
6744         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6745         if (get_jenv_res == JNI_EDETACHED) {
6746                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6747         } else {
6748                 DO_ASSERT(get_jenv_res == JNI_OK);
6749         }
6750         LDKTransaction tx_var = tx;
6751         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
6752         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
6753         Transaction_free(tx_var);
6754         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6755         CHECK(obj != NULL);
6756         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
6757         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6758                 (*env)->ExceptionDescribe(env);
6759                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
6760         }
6761         if (get_jenv_res == JNI_EDETACHED) {
6762                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6763         }
6764 }
6765 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6766         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6767         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6768 }
6769 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
6770         jclass c = (*env)->GetObjectClass(env, o);
6771         CHECK(c != NULL);
6772         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6773         atomic_init(&calls->refcnt, 1);
6774         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6775         calls->o = (*env)->NewWeakGlobalRef(env, o);
6776         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
6777         CHECK(calls->broadcast_transaction_meth != NULL);
6778
6779         LDKBroadcasterInterface ret = {
6780                 .this_arg = (void*) calls,
6781                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6782                 .free = LDKBroadcasterInterface_JCalls_free,
6783         };
6784         return ret;
6785 }
6786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6787         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6788         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
6789         return (uint64_t)res_ptr;
6790 }
6791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
6792         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6793         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6794         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6795         LDKTransaction tx_ref;
6796         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
6797         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6798         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
6799         tx_ref.data_is_owned = true;
6800         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6801 }
6802
6803 typedef struct LDKKeysInterface_JCalls {
6804         atomic_size_t refcnt;
6805         JavaVM *vm;
6806         jweak o;
6807         jmethodID get_node_secret_meth;
6808         jmethodID get_destination_script_meth;
6809         jmethodID get_shutdown_scriptpubkey_meth;
6810         jmethodID get_channel_signer_meth;
6811         jmethodID get_secure_random_bytes_meth;
6812         jmethodID read_chan_signer_meth;
6813         jmethodID sign_invoice_meth;
6814         jmethodID get_inbound_payment_key_material_meth;
6815 } LDKKeysInterface_JCalls;
6816 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6817         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6818         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6819                 JNIEnv *env;
6820                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6821                 if (get_jenv_res == JNI_EDETACHED) {
6822                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6823                 } else {
6824                         DO_ASSERT(get_jenv_res == JNI_OK);
6825                 }
6826                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6827                 if (get_jenv_res == JNI_EDETACHED) {
6828                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6829                 }
6830                 FREE(j_calls);
6831         }
6832 }
6833 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
6834         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6835         JNIEnv *env;
6836         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6837         if (get_jenv_res == JNI_EDETACHED) {
6838                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6839         } else {
6840                 DO_ASSERT(get_jenv_res == JNI_OK);
6841         }
6842         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
6843         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6844         CHECK(obj != NULL);
6845         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
6846         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6847                 (*env)->ExceptionDescribe(env);
6848                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
6849         }
6850         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6851         CHECK_ACCESS(ret_ptr);
6852         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
6853         FREE((void*)ret);
6854         if (get_jenv_res == JNI_EDETACHED) {
6855                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6856         }
6857         return ret_conv;
6858 }
6859 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6860         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6861         JNIEnv *env;
6862         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6863         if (get_jenv_res == JNI_EDETACHED) {
6864                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6865         } else {
6866                 DO_ASSERT(get_jenv_res == JNI_OK);
6867         }
6868         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6869         CHECK(obj != NULL);
6870         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
6871         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6872                 (*env)->ExceptionDescribe(env);
6873                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
6874         }
6875         LDKCVec_u8Z ret_ref;
6876         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6877         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6878         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6879         if (get_jenv_res == JNI_EDETACHED) {
6880                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6881         }
6882         return ret_ref;
6883 }
6884 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6885         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6886         JNIEnv *env;
6887         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6888         if (get_jenv_res == JNI_EDETACHED) {
6889                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6890         } else {
6891                 DO_ASSERT(get_jenv_res == JNI_OK);
6892         }
6893         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6894         CHECK(obj != NULL);
6895         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
6896         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6897                 (*env)->ExceptionDescribe(env);
6898                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
6899         }
6900         LDKShutdownScript ret_conv;
6901         ret_conv.inner = (void*)(ret & (~1));
6902         ret_conv.is_owned = (ret & 1) || (ret == 0);
6903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6904         if (get_jenv_res == JNI_EDETACHED) {
6905                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6906         }
6907         return ret_conv;
6908 }
6909 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6910         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6911         JNIEnv *env;
6912         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6913         if (get_jenv_res == JNI_EDETACHED) {
6914                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6915         } else {
6916                 DO_ASSERT(get_jenv_res == JNI_OK);
6917         }
6918         jboolean inbound_conv = inbound;
6919         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6920         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6921         CHECK(obj != NULL);
6922         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
6923         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6924                 (*env)->ExceptionDescribe(env);
6925                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
6926         }
6927         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6928         CHECK_ACCESS(ret_ptr);
6929         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6930         FREE((void*)ret);
6931         if (get_jenv_res == JNI_EDETACHED) {
6932                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6933         }
6934         return ret_conv;
6935 }
6936 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6937         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6938         JNIEnv *env;
6939         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6940         if (get_jenv_res == JNI_EDETACHED) {
6941                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6942         } else {
6943                 DO_ASSERT(get_jenv_res == JNI_OK);
6944         }
6945         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6946         CHECK(obj != NULL);
6947         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
6948         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6949                 (*env)->ExceptionDescribe(env);
6950                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
6951         }
6952         LDKThirtyTwoBytes ret_ref;
6953         CHECK((*env)->GetArrayLength(env, ret) == 32);
6954         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6955         if (get_jenv_res == JNI_EDETACHED) {
6956                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6957         }
6958         return ret_ref;
6959 }
6960 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6961         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6962         JNIEnv *env;
6963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6964         if (get_jenv_res == JNI_EDETACHED) {
6965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6966         } else {
6967                 DO_ASSERT(get_jenv_res == JNI_OK);
6968         }
6969         LDKu8slice reader_var = reader;
6970         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
6971         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
6972         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6973         CHECK(obj != NULL);
6974         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
6975         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6976                 (*env)->ExceptionDescribe(env);
6977                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
6978         }
6979         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6980         CHECK_ACCESS(ret_ptr);
6981         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6982         FREE((void*)ret);
6983         if (get_jenv_res == JNI_EDETACHED) {
6984                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6985         }
6986         return ret_conv;
6987 }
6988 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
6989         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6990         JNIEnv *env;
6991         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6992         if (get_jenv_res == JNI_EDETACHED) {
6993                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6994         } else {
6995                 DO_ASSERT(get_jenv_res == JNI_OK);
6996         }
6997         LDKu8slice hrp_bytes_var = hrp_bytes;
6998         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
6999         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
7000         LDKCVec_u5Z invoice_data_var = invoice_data;
7001         jobjectArray invoice_data_arr = NULL;
7002         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
7003         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
7004         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
7005                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
7006                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
7007         }
7008         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
7009         FREE(invoice_data_var.data);
7010         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
7011         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7012         CHECK(obj != NULL);
7013         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
7014         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7015                 (*env)->ExceptionDescribe(env);
7016                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
7017         }
7018         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7019         CHECK_ACCESS(ret_ptr);
7020         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
7021         FREE((void*)ret);
7022         if (get_jenv_res == JNI_EDETACHED) {
7023                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7024         }
7025         return ret_conv;
7026 }
7027 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
7028         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7029         JNIEnv *env;
7030         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7031         if (get_jenv_res == JNI_EDETACHED) {
7032                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7033         } else {
7034                 DO_ASSERT(get_jenv_res == JNI_OK);
7035         }
7036         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7037         CHECK(obj != NULL);
7038         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7039         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7040                 (*env)->ExceptionDescribe(env);
7041                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
7042         }
7043         LDKThirtyTwoBytes ret_ref;
7044         CHECK((*env)->GetArrayLength(env, ret) == 32);
7045         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7046         if (get_jenv_res == JNI_EDETACHED) {
7047                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7048         }
7049         return ret_ref;
7050 }
7051 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
7052         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
7053         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7054 }
7055 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
7056         jclass c = (*env)->GetObjectClass(env, o);
7057         CHECK(c != NULL);
7058         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
7059         atomic_init(&calls->refcnt, 1);
7060         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7061         calls->o = (*env)->NewWeakGlobalRef(env, o);
7062         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
7063         CHECK(calls->get_node_secret_meth != NULL);
7064         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
7065         CHECK(calls->get_destination_script_meth != NULL);
7066         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
7067         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
7068         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
7069         CHECK(calls->get_channel_signer_meth != NULL);
7070         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7071         CHECK(calls->get_secure_random_bytes_meth != NULL);
7072         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
7073         CHECK(calls->read_chan_signer_meth != NULL);
7074         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
7075         CHECK(calls->sign_invoice_meth != NULL);
7076         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
7077         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
7078
7079         LDKKeysInterface ret = {
7080                 .this_arg = (void*) calls,
7081                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
7082                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
7083                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
7084                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
7085                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
7086                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
7087                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
7088                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
7089                 .free = LDKKeysInterface_JCalls_free,
7090         };
7091         return ret;
7092 }
7093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7094         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7095         *res_ptr = LDKKeysInterface_init(env, clz, o);
7096         return (uint64_t)res_ptr;
7097 }
7098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7099         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7100         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7101         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7102         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7103         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
7104         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
7105         return (int64_t)ret_conv;
7106 }
7107
7108 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
7109         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7110         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7111         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7112         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
7113         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7114         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7115         CVec_u8Z_free(ret_var);
7116         return ret_arr;
7117 }
7118
7119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
7120         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7121         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7122         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7123         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
7124         int64_t ret_ref = 0;
7125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7128         ret_ref = (uintptr_t)ret_var.inner;
7129         if (ret_var.is_owned) {
7130                 ret_ref |= 1;
7131         }
7132         return ret_ref;
7133 }
7134
7135 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) {
7136         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7137         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7138         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7139         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
7140         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
7141         return (int64_t)ret_ret;
7142 }
7143
7144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7145         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7146         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7147         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7148         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7149         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7150         return ret_arr;
7151 }
7152
7153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
7154         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7155         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7156         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7157         LDKu8slice reader_ref;
7158         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
7159         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
7160         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7161         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
7162         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
7163         return (int64_t)ret_conv;
7164 }
7165
7166 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) {
7167         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7168         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7169         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7170         LDKu8slice hrp_bytes_ref;
7171         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
7172         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
7173         LDKCVec_u5Z invoice_data_constr;
7174         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
7175         if (invoice_data_constr.datalen > 0)
7176                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
7177         else
7178                 invoice_data_constr.data = NULL;
7179         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
7180         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
7181                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
7182                 
7183                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
7184         }
7185         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
7186         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
7187         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7188         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
7189         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
7190         return (int64_t)ret_conv;
7191 }
7192
7193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
7194         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7195         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7196         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7197         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7198         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
7199         return ret_arr;
7200 }
7201
7202 typedef struct LDKFeeEstimator_JCalls {
7203         atomic_size_t refcnt;
7204         JavaVM *vm;
7205         jweak o;
7206         jmethodID get_est_sat_per_1000_weight_meth;
7207 } LDKFeeEstimator_JCalls;
7208 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7209         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7210         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7211                 JNIEnv *env;
7212                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7213                 if (get_jenv_res == JNI_EDETACHED) {
7214                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7215                 } else {
7216                         DO_ASSERT(get_jenv_res == JNI_OK);
7217                 }
7218                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7219                 if (get_jenv_res == JNI_EDETACHED) {
7220                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7221                 }
7222                 FREE(j_calls);
7223         }
7224 }
7225 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7226         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7227         JNIEnv *env;
7228         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7229         if (get_jenv_res == JNI_EDETACHED) {
7230                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7231         } else {
7232                 DO_ASSERT(get_jenv_res == JNI_OK);
7233         }
7234         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7235         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7236         CHECK(obj != NULL);
7237         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7238         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7239                 (*env)->ExceptionDescribe(env);
7240                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7241         }
7242         if (get_jenv_res == JNI_EDETACHED) {
7243                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7244         }
7245         return ret;
7246 }
7247 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7248         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7249         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7250 }
7251 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7252         jclass c = (*env)->GetObjectClass(env, o);
7253         CHECK(c != NULL);
7254         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7255         atomic_init(&calls->refcnt, 1);
7256         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7257         calls->o = (*env)->NewWeakGlobalRef(env, o);
7258         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7259         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7260
7261         LDKFeeEstimator ret = {
7262                 .this_arg = (void*) calls,
7263                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7264                 .free = LDKFeeEstimator_JCalls_free,
7265         };
7266         return ret;
7267 }
7268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7269         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7270         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7271         return (uint64_t)res_ptr;
7272 }
7273 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) {
7274         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7275         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7276         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7277         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7278         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7279         return ret_conv;
7280 }
7281
7282 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7283         return ThirtyTwoBytes_clone(&owner->a);
7284 }
7285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7286         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7289         return ret_arr;
7290 }
7291
7292 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7293         return &owner->b;
7294 }
7295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7296         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7297         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7298         int64_t ret_ref = 0;
7299         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7300         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7302         ret_ref = (uintptr_t)ret_var.inner & ~1;
7303         return ret_ref;
7304 }
7305
7306 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7307 CHECK(owner->result_ok);
7308         return &*owner->contents.result;
7309 }
7310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7311         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7312         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
7313         return ret_ret;
7314 }
7315
7316 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7317 CHECK(!owner->result_ok);
7318         return DecodeError_clone(&*owner->contents.err);
7319 }
7320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7321         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7322         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7323         int64_t ret_ref = 0;
7324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7327         ret_ref = (uintptr_t)ret_var.inner;
7328         if (ret_var.is_owned) {
7329                 ret_ref |= 1;
7330         }
7331         return ret_ref;
7332 }
7333
7334 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7335 CHECK(owner->result_ok);
7336         return ChannelConfig_clone(&*owner->contents.result);
7337 }
7338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7339         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7340         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7341         int64_t ret_ref = 0;
7342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7345         ret_ref = (uintptr_t)ret_var.inner;
7346         if (ret_var.is_owned) {
7347                 ret_ref |= 1;
7348         }
7349         return ret_ref;
7350 }
7351
7352 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7353 CHECK(!owner->result_ok);
7354         return DecodeError_clone(&*owner->contents.err);
7355 }
7356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7357         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7358         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7359         int64_t ret_ref = 0;
7360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7363         ret_ref = (uintptr_t)ret_var.inner;
7364         if (ret_var.is_owned) {
7365                 ret_ref |= 1;
7366         }
7367         return ret_ref;
7368 }
7369
7370 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7371 CHECK(owner->result_ok);
7372         return OutPoint_clone(&*owner->contents.result);
7373 }
7374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7375         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7376         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7377         int64_t ret_ref = 0;
7378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7381         ret_ref = (uintptr_t)ret_var.inner;
7382         if (ret_var.is_owned) {
7383                 ret_ref |= 1;
7384         }
7385         return ret_ref;
7386 }
7387
7388 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7389 CHECK(!owner->result_ok);
7390         return DecodeError_clone(&*owner->contents.err);
7391 }
7392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7393         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7394         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7395         int64_t ret_ref = 0;
7396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7399         ret_ref = (uintptr_t)ret_var.inner;
7400         if (ret_var.is_owned) {
7401                 ret_ref |= 1;
7402         }
7403         return ret_ref;
7404 }
7405
7406 typedef struct LDKType_JCalls {
7407         atomic_size_t refcnt;
7408         JavaVM *vm;
7409         jweak o;
7410         jmethodID type_id_meth;
7411         jmethodID debug_str_meth;
7412         jmethodID write_meth;
7413 } LDKType_JCalls;
7414 static void LDKType_JCalls_free(void* this_arg) {
7415         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7416         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7417                 JNIEnv *env;
7418                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7419                 if (get_jenv_res == JNI_EDETACHED) {
7420                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7421                 } else {
7422                         DO_ASSERT(get_jenv_res == JNI_OK);
7423                 }
7424                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7425                 if (get_jenv_res == JNI_EDETACHED) {
7426                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7427                 }
7428                 FREE(j_calls);
7429         }
7430 }
7431 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7432         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7433         JNIEnv *env;
7434         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7435         if (get_jenv_res == JNI_EDETACHED) {
7436                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7437         } else {
7438                 DO_ASSERT(get_jenv_res == JNI_OK);
7439         }
7440         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7441         CHECK(obj != NULL);
7442         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
7443         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7444                 (*env)->ExceptionDescribe(env);
7445                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
7446         }
7447         if (get_jenv_res == JNI_EDETACHED) {
7448                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7449         }
7450         return ret;
7451 }
7452 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7453         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7454         JNIEnv *env;
7455         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7456         if (get_jenv_res == JNI_EDETACHED) {
7457                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7458         } else {
7459                 DO_ASSERT(get_jenv_res == JNI_OK);
7460         }
7461         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7462         CHECK(obj != NULL);
7463         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
7464         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7465                 (*env)->ExceptionDescribe(env);
7466                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
7467         }
7468         LDKStr ret_conv = java_to_owned_str(env, ret);
7469         if (get_jenv_res == JNI_EDETACHED) {
7470                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7471         }
7472         return ret_conv;
7473 }
7474 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7475         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7476         JNIEnv *env;
7477         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7478         if (get_jenv_res == JNI_EDETACHED) {
7479                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7480         } else {
7481                 DO_ASSERT(get_jenv_res == JNI_OK);
7482         }
7483         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7484         CHECK(obj != NULL);
7485         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
7486         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7487                 (*env)->ExceptionDescribe(env);
7488                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
7489         }
7490         LDKCVec_u8Z ret_ref;
7491         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7492         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7493         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7494         if (get_jenv_res == JNI_EDETACHED) {
7495                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7496         }
7497         return ret_ref;
7498 }
7499 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7500         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7501         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7502 }
7503 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
7504         jclass c = (*env)->GetObjectClass(env, o);
7505         CHECK(c != NULL);
7506         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7507         atomic_init(&calls->refcnt, 1);
7508         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7509         calls->o = (*env)->NewWeakGlobalRef(env, o);
7510         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
7511         CHECK(calls->type_id_meth != NULL);
7512         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
7513         CHECK(calls->debug_str_meth != NULL);
7514         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
7515         CHECK(calls->write_meth != NULL);
7516
7517         LDKType ret = {
7518                 .this_arg = (void*) calls,
7519                 .type_id = type_id_LDKType_jcall,
7520                 .debug_str = debug_str_LDKType_jcall,
7521                 .write = write_LDKType_jcall,
7522                 .cloned = LDKType_JCalls_cloned,
7523                 .free = LDKType_JCalls_free,
7524         };
7525         return ret;
7526 }
7527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
7528         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7529         *res_ptr = LDKType_init(env, clz, o);
7530         return (uint64_t)res_ptr;
7531 }
7532 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
7533         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7534         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7535         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7536         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7537         return ret_conv;
7538 }
7539
7540 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
7541         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7542         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7543         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7544         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7545         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7546         Str_free(ret_str);
7547         return ret_conv;
7548 }
7549
7550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
7551         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7552         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7553         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7554         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7555         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7556         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7557         CVec_u8Z_free(ret_var);
7558         return ret_arr;
7559 }
7560
7561 static jclass LDKCOption_TypeZ_Some_class = NULL;
7562 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
7563 static jclass LDKCOption_TypeZ_None_class = NULL;
7564 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
7565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
7566         LDKCOption_TypeZ_Some_class =
7567                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
7568         CHECK(LDKCOption_TypeZ_Some_class != NULL);
7569         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
7570         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
7571         LDKCOption_TypeZ_None_class =
7572                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
7573         CHECK(LDKCOption_TypeZ_None_class != NULL);
7574         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
7575         CHECK(LDKCOption_TypeZ_None_meth != NULL);
7576 }
7577 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7578         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
7579         switch(obj->tag) {
7580                 case LDKCOption_TypeZ_Some: {
7581                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7582                         *some_ret = Type_clone(&obj->some);
7583                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
7584                 }
7585                 case LDKCOption_TypeZ_None: {
7586                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
7587                 }
7588                 default: abort();
7589         }
7590 }
7591 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7592 CHECK(owner->result_ok);
7593         return COption_TypeZ_clone(&*owner->contents.result);
7594 }
7595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7596         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7597         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7598         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7599         int64_t ret_ref = (uintptr_t)ret_copy;
7600         return ret_ref;
7601 }
7602
7603 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7604 CHECK(!owner->result_ok);
7605         return DecodeError_clone(&*owner->contents.err);
7606 }
7607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7608         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7609         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7610         int64_t ret_ref = 0;
7611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7614         ret_ref = (uintptr_t)ret_var.inner;
7615         if (ret_var.is_owned) {
7616                 ret_ref |= 1;
7617         }
7618         return ret_ref;
7619 }
7620
7621 static jclass LDKPaymentError_Invoice_class = NULL;
7622 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7623 static jclass LDKPaymentError_Routing_class = NULL;
7624 static jmethodID LDKPaymentError_Routing_meth = NULL;
7625 static jclass LDKPaymentError_Sending_class = NULL;
7626 static jmethodID LDKPaymentError_Sending_meth = NULL;
7627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
7628         LDKPaymentError_Invoice_class =
7629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
7630         CHECK(LDKPaymentError_Invoice_class != NULL);
7631         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
7632         CHECK(LDKPaymentError_Invoice_meth != NULL);
7633         LDKPaymentError_Routing_class =
7634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
7635         CHECK(LDKPaymentError_Routing_class != NULL);
7636         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
7637         CHECK(LDKPaymentError_Routing_meth != NULL);
7638         LDKPaymentError_Sending_class =
7639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
7640         CHECK(LDKPaymentError_Sending_class != NULL);
7641         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
7642         CHECK(LDKPaymentError_Sending_meth != NULL);
7643 }
7644 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7645         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
7646         switch(obj->tag) {
7647                 case LDKPaymentError_Invoice: {
7648                         LDKStr invoice_str = obj->invoice;
7649                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
7650                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
7651                 }
7652                 case LDKPaymentError_Routing: {
7653                         LDKLightningError routing_var = obj->routing;
7654                         int64_t routing_ref = 0;
7655                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7656                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7657                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
7658                         routing_ref = (uintptr_t)routing_var.inner & ~1;
7659                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
7660                 }
7661                 case LDKPaymentError_Sending: {
7662                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
7663                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
7664                 }
7665                 default: abort();
7666         }
7667 }
7668 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7669 CHECK(owner->result_ok);
7670         return ThirtyTwoBytes_clone(&*owner->contents.result);
7671 }
7672 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7673         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7674         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
7676         return ret_arr;
7677 }
7678
7679 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7680 CHECK(!owner->result_ok);
7681         return PaymentError_clone(&*owner->contents.err);
7682 }
7683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7684         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7685         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
7686         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
7687         int64_t ret_ref = (uintptr_t)ret_copy;
7688         return ret_ref;
7689 }
7690
7691 static jclass LDKParseError_Bech32Error_class = NULL;
7692 static jmethodID LDKParseError_Bech32Error_meth = NULL;
7693 static jclass LDKParseError_ParseAmountError_class = NULL;
7694 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
7695 static jclass LDKParseError_MalformedSignature_class = NULL;
7696 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
7697 static jclass LDKParseError_BadPrefix_class = NULL;
7698 static jmethodID LDKParseError_BadPrefix_meth = NULL;
7699 static jclass LDKParseError_UnknownCurrency_class = NULL;
7700 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
7701 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
7702 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
7703 static jclass LDKParseError_MalformedHRP_class = NULL;
7704 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
7705 static jclass LDKParseError_TooShortDataPart_class = NULL;
7706 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
7707 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
7708 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
7709 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
7710 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
7711 static jclass LDKParseError_PaddingError_class = NULL;
7712 static jmethodID LDKParseError_PaddingError_meth = NULL;
7713 static jclass LDKParseError_IntegerOverflowError_class = NULL;
7714 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
7715 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
7716 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
7717 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
7718 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
7719 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
7720 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
7721 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
7722 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
7723 static jclass LDKParseError_InvalidSliceLength_class = NULL;
7724 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
7725 static jclass LDKParseError_Skip_class = NULL;
7726 static jmethodID LDKParseError_Skip_meth = NULL;
7727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
7728         LDKParseError_Bech32Error_class =
7729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
7730         CHECK(LDKParseError_Bech32Error_class != NULL);
7731         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
7732         CHECK(LDKParseError_Bech32Error_meth != NULL);
7733         LDKParseError_ParseAmountError_class =
7734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
7735         CHECK(LDKParseError_ParseAmountError_class != NULL);
7736         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
7737         CHECK(LDKParseError_ParseAmountError_meth != NULL);
7738         LDKParseError_MalformedSignature_class =
7739                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
7740         CHECK(LDKParseError_MalformedSignature_class != NULL);
7741         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
7742         CHECK(LDKParseError_MalformedSignature_meth != NULL);
7743         LDKParseError_BadPrefix_class =
7744                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
7745         CHECK(LDKParseError_BadPrefix_class != NULL);
7746         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
7747         CHECK(LDKParseError_BadPrefix_meth != NULL);
7748         LDKParseError_UnknownCurrency_class =
7749                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
7750         CHECK(LDKParseError_UnknownCurrency_class != NULL);
7751         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
7752         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
7753         LDKParseError_UnknownSiPrefix_class =
7754                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
7755         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
7756         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
7757         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
7758         LDKParseError_MalformedHRP_class =
7759                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
7760         CHECK(LDKParseError_MalformedHRP_class != NULL);
7761         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
7762         CHECK(LDKParseError_MalformedHRP_meth != NULL);
7763         LDKParseError_TooShortDataPart_class =
7764                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
7765         CHECK(LDKParseError_TooShortDataPart_class != NULL);
7766         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
7767         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
7768         LDKParseError_UnexpectedEndOfTaggedFields_class =
7769                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
7770         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
7771         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
7772         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
7773         LDKParseError_DescriptionDecodeError_class =
7774                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
7775         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
7776         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
7777         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
7778         LDKParseError_PaddingError_class =
7779                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
7780         CHECK(LDKParseError_PaddingError_class != NULL);
7781         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
7782         CHECK(LDKParseError_PaddingError_meth != NULL);
7783         LDKParseError_IntegerOverflowError_class =
7784                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
7785         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
7786         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
7787         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
7788         LDKParseError_InvalidSegWitProgramLength_class =
7789                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
7790         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
7791         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
7792         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
7793         LDKParseError_InvalidPubKeyHashLength_class =
7794                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
7795         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
7796         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
7797         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
7798         LDKParseError_InvalidScriptHashLength_class =
7799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
7800         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
7801         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
7802         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
7803         LDKParseError_InvalidRecoveryId_class =
7804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
7805         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
7806         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
7807         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
7808         LDKParseError_InvalidSliceLength_class =
7809                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
7810         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
7811         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
7812         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
7813         LDKParseError_Skip_class =
7814                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
7815         CHECK(LDKParseError_Skip_class != NULL);
7816         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
7817         CHECK(LDKParseError_Skip_meth != NULL);
7818 }
7819 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7820         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
7821         switch(obj->tag) {
7822                 case LDKParseError_Bech32Error: {
7823                         int64_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
7824                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
7825                 }
7826                 case LDKParseError_ParseAmountError: {
7827                         /*obj->parse_amount_error*/
7828                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
7829                 }
7830                 case LDKParseError_MalformedSignature: {
7831                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
7832                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
7833                 }
7834                 case LDKParseError_BadPrefix: {
7835                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
7836                 }
7837                 case LDKParseError_UnknownCurrency: {
7838                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
7839                 }
7840                 case LDKParseError_UnknownSiPrefix: {
7841                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
7842                 }
7843                 case LDKParseError_MalformedHRP: {
7844                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
7845                 }
7846                 case LDKParseError_TooShortDataPart: {
7847                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
7848                 }
7849                 case LDKParseError_UnexpectedEndOfTaggedFields: {
7850                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
7851                 }
7852                 case LDKParseError_DescriptionDecodeError: {
7853                         /*obj->description_decode_error*/
7854                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
7855                 }
7856                 case LDKParseError_PaddingError: {
7857                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
7858                 }
7859                 case LDKParseError_IntegerOverflowError: {
7860                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
7861                 }
7862                 case LDKParseError_InvalidSegWitProgramLength: {
7863                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
7864                 }
7865                 case LDKParseError_InvalidPubKeyHashLength: {
7866                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
7867                 }
7868                 case LDKParseError_InvalidScriptHashLength: {
7869                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
7870                 }
7871                 case LDKParseError_InvalidRecoveryId: {
7872                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
7873                 }
7874                 case LDKParseError_InvalidSliceLength: {
7875                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
7876                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
7877                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
7878                 }
7879                 case LDKParseError_Skip: {
7880                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
7881                 }
7882                 default: abort();
7883         }
7884 }
7885 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7886 CHECK(owner->result_ok);
7887         return SiPrefix_clone(&*owner->contents.result);
7888 }
7889 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7890         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7891         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
7892         return ret_conv;
7893 }
7894
7895 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7896 CHECK(!owner->result_ok);
7897         return ParseError_clone(&*owner->contents.err);
7898 }
7899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7900         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7901         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7902         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
7903         int64_t ret_ref = (uintptr_t)ret_copy;
7904         return ret_ref;
7905 }
7906
7907 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
7908 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
7909 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
7910 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
7911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
7912         LDKParseOrSemanticError_ParseError_class =
7913                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
7914         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
7915         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
7916         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
7917         LDKParseOrSemanticError_SemanticError_class =
7918                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
7919         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
7920         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
7921         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
7922 }
7923 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7924         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
7925         switch(obj->tag) {
7926                 case LDKParseOrSemanticError_ParseError: {
7927                         int64_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
7928                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
7929                 }
7930                 case LDKParseOrSemanticError_SemanticError: {
7931                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
7932                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
7933                 }
7934                 default: abort();
7935         }
7936 }
7937 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7938 CHECK(owner->result_ok);
7939         return Invoice_clone(&*owner->contents.result);
7940 }
7941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7942         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7943         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7944         int64_t ret_ref = 0;
7945         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7946         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7948         ret_ref = (uintptr_t)ret_var.inner;
7949         if (ret_var.is_owned) {
7950                 ret_ref |= 1;
7951         }
7952         return ret_ref;
7953 }
7954
7955 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7956 CHECK(!owner->result_ok);
7957         return ParseOrSemanticError_clone(&*owner->contents.err);
7958 }
7959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7960         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7961         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7962         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7963         int64_t ret_ref = (uintptr_t)ret_copy;
7964         return ret_ref;
7965 }
7966
7967 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7968 CHECK(owner->result_ok);
7969         return SignedRawInvoice_clone(&*owner->contents.result);
7970 }
7971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7972         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7973         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7974         int64_t ret_ref = 0;
7975         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7976         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7978         ret_ref = (uintptr_t)ret_var.inner;
7979         if (ret_var.is_owned) {
7980                 ret_ref |= 1;
7981         }
7982         return ret_ref;
7983 }
7984
7985 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7986 CHECK(!owner->result_ok);
7987         return ParseError_clone(&*owner->contents.err);
7988 }
7989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7990         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7991         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7992         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7993         int64_t ret_ref = (uintptr_t)ret_copy;
7994         return ret_ref;
7995 }
7996
7997 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7998         return RawInvoice_clone(&owner->a);
7999 }
8000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8001         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
8002         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
8003         int64_t ret_ref = 0;
8004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8007         ret_ref = (uintptr_t)ret_var.inner;
8008         if (ret_var.is_owned) {
8009                 ret_ref |= 1;
8010         }
8011         return ret_ref;
8012 }
8013
8014 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8015         return ThirtyTwoBytes_clone(&owner->b);
8016 }
8017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8018         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
8019         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8020         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
8021         return ret_arr;
8022 }
8023
8024 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8025         return InvoiceSignature_clone(&owner->c);
8026 }
8027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
8028         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
8029         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
8030         int64_t ret_ref = 0;
8031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8034         ret_ref = (uintptr_t)ret_var.inner;
8035         if (ret_var.is_owned) {
8036                 ret_ref |= 1;
8037         }
8038         return ret_ref;
8039 }
8040
8041 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8042 CHECK(owner->result_ok);
8043         return PayeePubKey_clone(&*owner->contents.result);
8044 }
8045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8046         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
8047         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
8048         int64_t ret_ref = 0;
8049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8052         ret_ref = (uintptr_t)ret_var.inner;
8053         if (ret_var.is_owned) {
8054                 ret_ref |= 1;
8055         }
8056         return ret_ref;
8057 }
8058
8059 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8060 CHECK(!owner->result_ok);
8061         return *owner->contents.err;
8062 }
8063 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8064         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
8065         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
8066         return ret_conv;
8067 }
8068
8069 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
8070         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
8071         for (size_t i = 0; i < ret.datalen; i++) {
8072                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
8073         }
8074         return ret;
8075 }
8076 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8077 CHECK(owner->result_ok);
8078         return PositiveTimestamp_clone(&*owner->contents.result);
8079 }
8080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8081         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
8082         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
8083         int64_t ret_ref = 0;
8084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8087         ret_ref = (uintptr_t)ret_var.inner;
8088         if (ret_var.is_owned) {
8089                 ret_ref |= 1;
8090         }
8091         return ret_ref;
8092 }
8093
8094 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8095 CHECK(!owner->result_ok);
8096         return CreationError_clone(&*owner->contents.err);
8097 }
8098 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8099         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
8100         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
8101         return ret_conv;
8102 }
8103
8104 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8105 CHECK(owner->result_ok);
8106         return *owner->contents.result;
8107 }
8108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8109         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
8110         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
8111 }
8112
8113 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8114 CHECK(!owner->result_ok);
8115         return SemanticError_clone(&*owner->contents.err);
8116 }
8117 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8118         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
8119         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
8120         return ret_conv;
8121 }
8122
8123 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8124 CHECK(owner->result_ok);
8125         return Invoice_clone(&*owner->contents.result);
8126 }
8127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8128         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
8129         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
8130         int64_t ret_ref = 0;
8131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8134         ret_ref = (uintptr_t)ret_var.inner;
8135         if (ret_var.is_owned) {
8136                 ret_ref |= 1;
8137         }
8138         return ret_ref;
8139 }
8140
8141 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8142 CHECK(!owner->result_ok);
8143         return SemanticError_clone(&*owner->contents.err);
8144 }
8145 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8146         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
8147         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
8148         return ret_conv;
8149 }
8150
8151 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8152 CHECK(owner->result_ok);
8153         return Description_clone(&*owner->contents.result);
8154 }
8155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8156         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
8157         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
8158         int64_t ret_ref = 0;
8159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8162         ret_ref = (uintptr_t)ret_var.inner;
8163         if (ret_var.is_owned) {
8164                 ret_ref |= 1;
8165         }
8166         return ret_ref;
8167 }
8168
8169 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8170 CHECK(!owner->result_ok);
8171         return CreationError_clone(&*owner->contents.err);
8172 }
8173 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8174         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
8175         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
8176         return ret_conv;
8177 }
8178
8179 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8180 CHECK(owner->result_ok);
8181         return PrivateRoute_clone(&*owner->contents.result);
8182 }
8183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8184         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
8185         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(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 enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8198 CHECK(!owner->result_ok);
8199         return CreationError_clone(&*owner->contents.err);
8200 }
8201 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8202         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
8203         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
8204         return ret_conv;
8205 }
8206
8207 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8208 CHECK(owner->result_ok);
8209         return *owner->contents.result;
8210 }
8211 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8212         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8213         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8214         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8215         return ret_conv;
8216 }
8217
8218 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8219 CHECK(!owner->result_ok);
8220         return *owner->contents.err;
8221 }
8222 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8223         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8224         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8225         return ret_conv;
8226 }
8227
8228 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8229 CHECK(owner->result_ok);
8230         return ChannelMonitorUpdate_clone(&*owner->contents.result);
8231 }
8232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8233         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8234         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8235         int64_t ret_ref = 0;
8236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8239         ret_ref = (uintptr_t)ret_var.inner;
8240         if (ret_var.is_owned) {
8241                 ret_ref |= 1;
8242         }
8243         return ret_ref;
8244 }
8245
8246 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8247 CHECK(!owner->result_ok);
8248         return DecodeError_clone(&*owner->contents.err);
8249 }
8250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8251         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8252         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8253         int64_t ret_ref = 0;
8254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8257         ret_ref = (uintptr_t)ret_var.inner;
8258         if (ret_var.is_owned) {
8259                 ret_ref |= 1;
8260         }
8261         return ret_ref;
8262 }
8263
8264 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8265 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8266 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8267 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8269         LDKCOption_MonitorEventZ_Some_class =
8270                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8271         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8272         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8273         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8274         LDKCOption_MonitorEventZ_None_class =
8275                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8276         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8277         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8278         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8279 }
8280 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8281         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
8282         switch(obj->tag) {
8283                 case LDKCOption_MonitorEventZ_Some: {
8284                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8285                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8286                 }
8287                 case LDKCOption_MonitorEventZ_None: {
8288                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8289                 }
8290                 default: abort();
8291         }
8292 }
8293 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8294 CHECK(owner->result_ok);
8295         return COption_MonitorEventZ_clone(&*owner->contents.result);
8296 }
8297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8298         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8299         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8300         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8301         int64_t ret_ref = (uintptr_t)ret_copy;
8302         return ret_ref;
8303 }
8304
8305 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8306 CHECK(!owner->result_ok);
8307         return DecodeError_clone(&*owner->contents.err);
8308 }
8309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8310         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8311         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8312         int64_t ret_ref = 0;
8313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8316         ret_ref = (uintptr_t)ret_var.inner;
8317         if (ret_var.is_owned) {
8318                 ret_ref |= 1;
8319         }
8320         return ret_ref;
8321 }
8322
8323 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8324 CHECK(owner->result_ok);
8325         return HTLCUpdate_clone(&*owner->contents.result);
8326 }
8327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8328         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8329         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8330         int64_t ret_ref = 0;
8331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8334         ret_ref = (uintptr_t)ret_var.inner;
8335         if (ret_var.is_owned) {
8336                 ret_ref |= 1;
8337         }
8338         return ret_ref;
8339 }
8340
8341 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8342 CHECK(!owner->result_ok);
8343         return DecodeError_clone(&*owner->contents.err);
8344 }
8345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8346         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8347         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8348         int64_t ret_ref = 0;
8349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8352         ret_ref = (uintptr_t)ret_var.inner;
8353         if (ret_var.is_owned) {
8354                 ret_ref |= 1;
8355         }
8356         return ret_ref;
8357 }
8358
8359 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8360         return OutPoint_clone(&owner->a);
8361 }
8362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8363         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8364         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8365         int64_t ret_ref = 0;
8366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8369         ret_ref = (uintptr_t)ret_var.inner;
8370         if (ret_var.is_owned) {
8371                 ret_ref |= 1;
8372         }
8373         return ret_ref;
8374 }
8375
8376 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8377         return CVec_u8Z_clone(&owner->b);
8378 }
8379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8380         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8381         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8382         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8383         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8384         CVec_u8Z_free(ret_var);
8385         return ret_arr;
8386 }
8387
8388 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8389         return owner->a;
8390 }
8391 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8392         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8393         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8394         return ret_conv;
8395 }
8396
8397 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8398         return CVec_u8Z_clone(&owner->b);
8399 }
8400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8401         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8402         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8403         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8404         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8405         CVec_u8Z_free(ret_var);
8406         return ret_arr;
8407 }
8408
8409 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8410         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8411         for (size_t i = 0; i < ret.datalen; i++) {
8412                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8413         }
8414         return ret;
8415 }
8416 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8417         return ThirtyTwoBytes_clone(&owner->a);
8418 }
8419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8420         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8421         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8422         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8423         return ret_arr;
8424 }
8425
8426 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8427         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8428 }
8429 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8430         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8431         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8432         int64_tArray ret_arr = NULL;
8433         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8434         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8435         for (size_t v = 0; v < ret_var.datalen; v++) {
8436                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8437                 *ret_conv_21_conv = ret_var.data[v];
8438                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
8439         }
8440         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8441         FREE(ret_var.data);
8442         return ret_arr;
8443 }
8444
8445 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8446         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 };
8447         for (size_t i = 0; i < ret.datalen; i++) {
8448                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8449         }
8450         return ret;
8451 }
8452 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8453         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8454         for (size_t i = 0; i < ret.datalen; i++) {
8455                 ret.data[i] = Event_clone(&orig->data[i]);
8456         }
8457         return ret;
8458 }
8459 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8460         return owner->a;
8461 }
8462 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8463         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8464         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8465         return ret_conv;
8466 }
8467
8468 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8469         return TxOut_clone(&owner->b);
8470 }
8471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8472         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8473         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8474         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8475         return (int64_t)ret_ref;
8476 }
8477
8478 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8479         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8480         for (size_t i = 0; i < ret.datalen; i++) {
8481                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8482         }
8483         return ret;
8484 }
8485 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8486         return ThirtyTwoBytes_clone(&owner->a);
8487 }
8488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8489         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8490         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8491         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8492         return ret_arr;
8493 }
8494
8495 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8496         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8497 }
8498 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8499         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8500         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8501         int64_tArray ret_arr = NULL;
8502         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8503         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8504         for (size_t u = 0; u < ret_var.datalen; u++) {
8505                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8506                 *ret_conv_20_conv = ret_var.data[u];
8507                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
8508         }
8509         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8510         FREE(ret_var.data);
8511         return ret_arr;
8512 }
8513
8514 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8515         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 };
8516         for (size_t i = 0; i < ret.datalen; i++) {
8517                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8518         }
8519         return ret;
8520 }
8521 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8522 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8523 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8524 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8525 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8526 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8527 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
8528 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
8529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8530         LDKBalance_ClaimableOnChannelClose_class =
8531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8532         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8533         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8534         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8535         LDKBalance_ClaimableAwaitingConfirmations_class =
8536                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8537         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8538         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8539         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8540         LDKBalance_ContentiousClaimable_class =
8541                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8542         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8543         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8544         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8545         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
8546                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
8547         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
8548         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
8549         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
8550 }
8551 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8552         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
8553         switch(obj->tag) {
8554                 case LDKBalance_ClaimableOnChannelClose: {
8555                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8556                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8557                 }
8558                 case LDKBalance_ClaimableAwaitingConfirmations: {
8559                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8560                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8561                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8562                 }
8563                 case LDKBalance_ContentiousClaimable: {
8564                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8565                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8566                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8567                 }
8568                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
8569                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
8570                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
8571                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8572                 }
8573                 default: abort();
8574         }
8575 }
8576 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8577         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8578         for (size_t i = 0; i < ret.datalen; i++) {
8579                 ret.data[i] = Balance_clone(&orig->data[i]);
8580         }
8581         return ret;
8582 }
8583 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8584 CHECK(owner->result_ok);
8585         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8586 }
8587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8588         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8589         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8590         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8591         return ((int64_t)ret_conv);
8592 }
8593
8594 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8595 CHECK(!owner->result_ok);
8596         return DecodeError_clone(&*owner->contents.err);
8597 }
8598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8599         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8600         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8601         int64_t ret_ref = 0;
8602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8605         ret_ref = (uintptr_t)ret_var.inner;
8606         if (ret_var.is_owned) {
8607                 ret_ref |= 1;
8608         }
8609         return ret_ref;
8610 }
8611
8612 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8613         return owner->a;
8614 }
8615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8616         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8617         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8618         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8619         return ret_arr;
8620 }
8621
8622 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8623         return Type_clone(&owner->b);
8624 }
8625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8626         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8627         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8628         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8629         return (int64_t)ret_ret;
8630 }
8631
8632 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8633         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8634         for (size_t i = 0; i < ret.datalen; i++) {
8635                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8636         }
8637         return ret;
8638 }
8639 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
8640 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
8641 static jclass LDKCOption_NetAddressZ_None_class = NULL;
8642 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
8643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
8644         LDKCOption_NetAddressZ_Some_class =
8645                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
8646         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
8647         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
8648         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
8649         LDKCOption_NetAddressZ_None_class =
8650                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
8651         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
8652         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
8653         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
8654 }
8655 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8656         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
8657         switch(obj->tag) {
8658                 case LDKCOption_NetAddressZ_Some: {
8659                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8660                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
8661                 }
8662                 case LDKCOption_NetAddressZ_None: {
8663                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
8664                 }
8665                 default: abort();
8666         }
8667 }
8668 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8669 CHECK(owner->result_ok);
8670         return CVec_u8Z_clone(&*owner->contents.result);
8671 }
8672 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8673         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8674         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
8675         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8676         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8677         CVec_u8Z_free(ret_var);
8678         return ret_arr;
8679 }
8680
8681 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8682 CHECK(!owner->result_ok);
8683         return PeerHandleError_clone(&*owner->contents.err);
8684 }
8685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8686         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8687         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8688         int64_t ret_ref = 0;
8689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8692         ret_ref = (uintptr_t)ret_var.inner;
8693         if (ret_var.is_owned) {
8694                 ret_ref |= 1;
8695         }
8696         return ret_ref;
8697 }
8698
8699 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8700 CHECK(owner->result_ok);
8701         return *owner->contents.result;
8702 }
8703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8704         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8705         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8706 }
8707
8708 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8709 CHECK(!owner->result_ok);
8710         return PeerHandleError_clone(&*owner->contents.err);
8711 }
8712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8713         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8714         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
8715         int64_t ret_ref = 0;
8716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8719         ret_ref = (uintptr_t)ret_var.inner;
8720         if (ret_var.is_owned) {
8721                 ret_ref |= 1;
8722         }
8723         return ret_ref;
8724 }
8725
8726 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8727 CHECK(owner->result_ok);
8728         return *owner->contents.result;
8729 }
8730 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8731         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8732         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
8733         return ret_conv;
8734 }
8735
8736 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8737 CHECK(!owner->result_ok);
8738         return PeerHandleError_clone(&*owner->contents.err);
8739 }
8740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8741         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8742         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
8743         int64_t ret_ref = 0;
8744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8747         ret_ref = (uintptr_t)ret_var.inner;
8748         if (ret_var.is_owned) {
8749                 ret_ref |= 1;
8750         }
8751         return ret_ref;
8752 }
8753
8754 static jclass LDKGraphSyncError_DecodeError_class = NULL;
8755 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
8756 static jclass LDKGraphSyncError_LightningError_class = NULL;
8757 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
8758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
8759         LDKGraphSyncError_DecodeError_class =
8760                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
8761         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
8762         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
8763         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
8764         LDKGraphSyncError_LightningError_class =
8765                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
8766         CHECK(LDKGraphSyncError_LightningError_class != NULL);
8767         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
8768         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
8769 }
8770 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8771         LDKGraphSyncError *obj = (LDKGraphSyncError*)(ptr & ~1);
8772         switch(obj->tag) {
8773                 case LDKGraphSyncError_DecodeError: {
8774                         LDKDecodeError decode_error_var = obj->decode_error;
8775                         int64_t decode_error_ref = 0;
8776                         CHECK((((uintptr_t)decode_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8777                         CHECK((((uintptr_t)&decode_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8778                         CHECK_INNER_FIELD_ACCESS_OR_NULL(decode_error_var);
8779                         decode_error_ref = (uintptr_t)decode_error_var.inner & ~1;
8780                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
8781                 }
8782                 case LDKGraphSyncError_LightningError: {
8783                         LDKLightningError lightning_error_var = obj->lightning_error;
8784                         int64_t lightning_error_ref = 0;
8785                         CHECK((((uintptr_t)lightning_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8786                         CHECK((((uintptr_t)&lightning_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8787                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
8788                         lightning_error_ref = (uintptr_t)lightning_error_var.inner & ~1;
8789                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
8790                 }
8791                 default: abort();
8792         }
8793 }
8794 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8795 CHECK(owner->result_ok);
8796         return *owner->contents.result;
8797 }
8798 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8799         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8800         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
8801         return ret_conv;
8802 }
8803
8804 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8805 CHECK(!owner->result_ok);
8806         return GraphSyncError_clone(&*owner->contents.err);
8807 }
8808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8809         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8810         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
8811         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
8812         int64_t ret_ref = (uintptr_t)ret_copy;
8813         return ret_ref;
8814 }
8815
8816 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8817 CHECK(owner->result_ok);
8818         return NetAddress_clone(&*owner->contents.result);
8819 }
8820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8821         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8822         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8823         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8824         int64_t ret_ref = (uintptr_t)ret_copy;
8825         return ret_ref;
8826 }
8827
8828 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8829 CHECK(!owner->result_ok);
8830         return DecodeError_clone(&*owner->contents.err);
8831 }
8832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8833         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8834         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8835         int64_t ret_ref = 0;
8836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8839         ret_ref = (uintptr_t)ret_var.inner;
8840         if (ret_var.is_owned) {
8841                 ret_ref |= 1;
8842         }
8843         return ret_ref;
8844 }
8845
8846 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8847         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8848         for (size_t i = 0; i < ret.datalen; i++) {
8849                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8850         }
8851         return ret;
8852 }
8853 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8854         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8855         for (size_t i = 0; i < ret.datalen; i++) {
8856                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8857         }
8858         return ret;
8859 }
8860 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8861         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8862         for (size_t i = 0; i < ret.datalen; i++) {
8863                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8864         }
8865         return ret;
8866 }
8867 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8868         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8869         for (size_t i = 0; i < ret.datalen; i++) {
8870                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8871         }
8872         return ret;
8873 }
8874 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8875 CHECK(owner->result_ok);
8876         return AcceptChannel_clone(&*owner->contents.result);
8877 }
8878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8879         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8880         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8881         int64_t ret_ref = 0;
8882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8885         ret_ref = (uintptr_t)ret_var.inner;
8886         if (ret_var.is_owned) {
8887                 ret_ref |= 1;
8888         }
8889         return ret_ref;
8890 }
8891
8892 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8893 CHECK(!owner->result_ok);
8894         return DecodeError_clone(&*owner->contents.err);
8895 }
8896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8897         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8898         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8899         int64_t ret_ref = 0;
8900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8903         ret_ref = (uintptr_t)ret_var.inner;
8904         if (ret_var.is_owned) {
8905                 ret_ref |= 1;
8906         }
8907         return ret_ref;
8908 }
8909
8910 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8911 CHECK(owner->result_ok);
8912         return AnnouncementSignatures_clone(&*owner->contents.result);
8913 }
8914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8915         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8916         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8917         int64_t ret_ref = 0;
8918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8921         ret_ref = (uintptr_t)ret_var.inner;
8922         if (ret_var.is_owned) {
8923                 ret_ref |= 1;
8924         }
8925         return ret_ref;
8926 }
8927
8928 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8929 CHECK(!owner->result_ok);
8930         return DecodeError_clone(&*owner->contents.err);
8931 }
8932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8933         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8934         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8935         int64_t ret_ref = 0;
8936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8939         ret_ref = (uintptr_t)ret_var.inner;
8940         if (ret_var.is_owned) {
8941                 ret_ref |= 1;
8942         }
8943         return ret_ref;
8944 }
8945
8946 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8947 CHECK(owner->result_ok);
8948         return ChannelReestablish_clone(&*owner->contents.result);
8949 }
8950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8951         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8952         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8953         int64_t ret_ref = 0;
8954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8957         ret_ref = (uintptr_t)ret_var.inner;
8958         if (ret_var.is_owned) {
8959                 ret_ref |= 1;
8960         }
8961         return ret_ref;
8962 }
8963
8964 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8965 CHECK(!owner->result_ok);
8966         return DecodeError_clone(&*owner->contents.err);
8967 }
8968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8969         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8970         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8971         int64_t ret_ref = 0;
8972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8975         ret_ref = (uintptr_t)ret_var.inner;
8976         if (ret_var.is_owned) {
8977                 ret_ref |= 1;
8978         }
8979         return ret_ref;
8980 }
8981
8982 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8983 CHECK(owner->result_ok);
8984         return ClosingSigned_clone(&*owner->contents.result);
8985 }
8986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8987         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8988         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8989         int64_t ret_ref = 0;
8990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8993         ret_ref = (uintptr_t)ret_var.inner;
8994         if (ret_var.is_owned) {
8995                 ret_ref |= 1;
8996         }
8997         return ret_ref;
8998 }
8999
9000 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9001 CHECK(!owner->result_ok);
9002         return DecodeError_clone(&*owner->contents.err);
9003 }
9004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9005         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
9006         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
9007         int64_t ret_ref = 0;
9008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9011         ret_ref = (uintptr_t)ret_var.inner;
9012         if (ret_var.is_owned) {
9013                 ret_ref |= 1;
9014         }
9015         return ret_ref;
9016 }
9017
9018 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9019 CHECK(owner->result_ok);
9020         return ClosingSignedFeeRange_clone(&*owner->contents.result);
9021 }
9022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9023         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
9024         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
9025         int64_t ret_ref = 0;
9026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9029         ret_ref = (uintptr_t)ret_var.inner;
9030         if (ret_var.is_owned) {
9031                 ret_ref |= 1;
9032         }
9033         return ret_ref;
9034 }
9035
9036 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9037 CHECK(!owner->result_ok);
9038         return DecodeError_clone(&*owner->contents.err);
9039 }
9040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9041         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
9042         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
9043         int64_t ret_ref = 0;
9044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9047         ret_ref = (uintptr_t)ret_var.inner;
9048         if (ret_var.is_owned) {
9049                 ret_ref |= 1;
9050         }
9051         return ret_ref;
9052 }
9053
9054 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9055 CHECK(owner->result_ok);
9056         return CommitmentSigned_clone(&*owner->contents.result);
9057 }
9058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9059         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
9060         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
9061         int64_t ret_ref = 0;
9062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9065         ret_ref = (uintptr_t)ret_var.inner;
9066         if (ret_var.is_owned) {
9067                 ret_ref |= 1;
9068         }
9069         return ret_ref;
9070 }
9071
9072 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9073 CHECK(!owner->result_ok);
9074         return DecodeError_clone(&*owner->contents.err);
9075 }
9076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9077         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
9078         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
9079         int64_t ret_ref = 0;
9080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9083         ret_ref = (uintptr_t)ret_var.inner;
9084         if (ret_var.is_owned) {
9085                 ret_ref |= 1;
9086         }
9087         return ret_ref;
9088 }
9089
9090 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9091 CHECK(owner->result_ok);
9092         return FundingCreated_clone(&*owner->contents.result);
9093 }
9094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9095         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
9096         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
9097         int64_t ret_ref = 0;
9098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9101         ret_ref = (uintptr_t)ret_var.inner;
9102         if (ret_var.is_owned) {
9103                 ret_ref |= 1;
9104         }
9105         return ret_ref;
9106 }
9107
9108 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9109 CHECK(!owner->result_ok);
9110         return DecodeError_clone(&*owner->contents.err);
9111 }
9112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9113         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
9114         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
9115         int64_t ret_ref = 0;
9116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9119         ret_ref = (uintptr_t)ret_var.inner;
9120         if (ret_var.is_owned) {
9121                 ret_ref |= 1;
9122         }
9123         return ret_ref;
9124 }
9125
9126 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9127 CHECK(owner->result_ok);
9128         return FundingSigned_clone(&*owner->contents.result);
9129 }
9130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9131         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
9132         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
9133         int64_t ret_ref = 0;
9134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9135         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9137         ret_ref = (uintptr_t)ret_var.inner;
9138         if (ret_var.is_owned) {
9139                 ret_ref |= 1;
9140         }
9141         return ret_ref;
9142 }
9143
9144 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9145 CHECK(!owner->result_ok);
9146         return DecodeError_clone(&*owner->contents.err);
9147 }
9148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9149         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
9150         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
9151         int64_t ret_ref = 0;
9152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9155         ret_ref = (uintptr_t)ret_var.inner;
9156         if (ret_var.is_owned) {
9157                 ret_ref |= 1;
9158         }
9159         return ret_ref;
9160 }
9161
9162 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9163 CHECK(owner->result_ok);
9164         return ChannelReady_clone(&*owner->contents.result);
9165 }
9166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9167         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
9168         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
9169         int64_t ret_ref = 0;
9170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9173         ret_ref = (uintptr_t)ret_var.inner;
9174         if (ret_var.is_owned) {
9175                 ret_ref |= 1;
9176         }
9177         return ret_ref;
9178 }
9179
9180 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9181 CHECK(!owner->result_ok);
9182         return DecodeError_clone(&*owner->contents.err);
9183 }
9184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9185         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
9186         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
9187         int64_t ret_ref = 0;
9188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9191         ret_ref = (uintptr_t)ret_var.inner;
9192         if (ret_var.is_owned) {
9193                 ret_ref |= 1;
9194         }
9195         return ret_ref;
9196 }
9197
9198 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9199 CHECK(owner->result_ok);
9200         return Init_clone(&*owner->contents.result);
9201 }
9202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9203         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9204         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9205         int64_t ret_ref = 0;
9206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9209         ret_ref = (uintptr_t)ret_var.inner;
9210         if (ret_var.is_owned) {
9211                 ret_ref |= 1;
9212         }
9213         return ret_ref;
9214 }
9215
9216 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9217 CHECK(!owner->result_ok);
9218         return DecodeError_clone(&*owner->contents.err);
9219 }
9220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9221         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9222         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
9223         int64_t ret_ref = 0;
9224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9227         ret_ref = (uintptr_t)ret_var.inner;
9228         if (ret_var.is_owned) {
9229                 ret_ref |= 1;
9230         }
9231         return ret_ref;
9232 }
9233
9234 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9235 CHECK(owner->result_ok);
9236         return OpenChannel_clone(&*owner->contents.result);
9237 }
9238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9239         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9240         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9241         int64_t ret_ref = 0;
9242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9245         ret_ref = (uintptr_t)ret_var.inner;
9246         if (ret_var.is_owned) {
9247                 ret_ref |= 1;
9248         }
9249         return ret_ref;
9250 }
9251
9252 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9253 CHECK(!owner->result_ok);
9254         return DecodeError_clone(&*owner->contents.err);
9255 }
9256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9257         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9258         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9259         int64_t ret_ref = 0;
9260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9263         ret_ref = (uintptr_t)ret_var.inner;
9264         if (ret_var.is_owned) {
9265                 ret_ref |= 1;
9266         }
9267         return ret_ref;
9268 }
9269
9270 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9271 CHECK(owner->result_ok);
9272         return RevokeAndACK_clone(&*owner->contents.result);
9273 }
9274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9275         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9276         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9277         int64_t ret_ref = 0;
9278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9281         ret_ref = (uintptr_t)ret_var.inner;
9282         if (ret_var.is_owned) {
9283                 ret_ref |= 1;
9284         }
9285         return ret_ref;
9286 }
9287
9288 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9289 CHECK(!owner->result_ok);
9290         return DecodeError_clone(&*owner->contents.err);
9291 }
9292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9293         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9294         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9295         int64_t ret_ref = 0;
9296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9299         ret_ref = (uintptr_t)ret_var.inner;
9300         if (ret_var.is_owned) {
9301                 ret_ref |= 1;
9302         }
9303         return ret_ref;
9304 }
9305
9306 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9307 CHECK(owner->result_ok);
9308         return Shutdown_clone(&*owner->contents.result);
9309 }
9310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9311         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9312         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9313         int64_t ret_ref = 0;
9314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9317         ret_ref = (uintptr_t)ret_var.inner;
9318         if (ret_var.is_owned) {
9319                 ret_ref |= 1;
9320         }
9321         return ret_ref;
9322 }
9323
9324 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9325 CHECK(!owner->result_ok);
9326         return DecodeError_clone(&*owner->contents.err);
9327 }
9328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9329         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9330         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
9331         int64_t ret_ref = 0;
9332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9335         ret_ref = (uintptr_t)ret_var.inner;
9336         if (ret_var.is_owned) {
9337                 ret_ref |= 1;
9338         }
9339         return ret_ref;
9340 }
9341
9342 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9343 CHECK(owner->result_ok);
9344         return UpdateFailHTLC_clone(&*owner->contents.result);
9345 }
9346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9347         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9348         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
9349         int64_t ret_ref = 0;
9350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9353         ret_ref = (uintptr_t)ret_var.inner;
9354         if (ret_var.is_owned) {
9355                 ret_ref |= 1;
9356         }
9357         return ret_ref;
9358 }
9359
9360 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9361 CHECK(!owner->result_ok);
9362         return DecodeError_clone(&*owner->contents.err);
9363 }
9364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9365         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9366         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
9367         int64_t ret_ref = 0;
9368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9371         ret_ref = (uintptr_t)ret_var.inner;
9372         if (ret_var.is_owned) {
9373                 ret_ref |= 1;
9374         }
9375         return ret_ref;
9376 }
9377
9378 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9379 CHECK(owner->result_ok);
9380         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
9381 }
9382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9383         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9384         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
9385         int64_t ret_ref = 0;
9386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9389         ret_ref = (uintptr_t)ret_var.inner;
9390         if (ret_var.is_owned) {
9391                 ret_ref |= 1;
9392         }
9393         return ret_ref;
9394 }
9395
9396 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9397 CHECK(!owner->result_ok);
9398         return DecodeError_clone(&*owner->contents.err);
9399 }
9400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9401         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9402         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9403         int64_t ret_ref = 0;
9404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9407         ret_ref = (uintptr_t)ret_var.inner;
9408         if (ret_var.is_owned) {
9409                 ret_ref |= 1;
9410         }
9411         return ret_ref;
9412 }
9413
9414 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9415 CHECK(owner->result_ok);
9416         return UpdateFee_clone(&*owner->contents.result);
9417 }
9418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9419         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9420         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9421         int64_t ret_ref = 0;
9422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9425         ret_ref = (uintptr_t)ret_var.inner;
9426         if (ret_var.is_owned) {
9427                 ret_ref |= 1;
9428         }
9429         return ret_ref;
9430 }
9431
9432 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9433 CHECK(!owner->result_ok);
9434         return DecodeError_clone(&*owner->contents.err);
9435 }
9436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9437         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9438         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9439         int64_t ret_ref = 0;
9440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9443         ret_ref = (uintptr_t)ret_var.inner;
9444         if (ret_var.is_owned) {
9445                 ret_ref |= 1;
9446         }
9447         return ret_ref;
9448 }
9449
9450 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9451 CHECK(owner->result_ok);
9452         return UpdateFulfillHTLC_clone(&*owner->contents.result);
9453 }
9454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9455         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9456         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9457         int64_t ret_ref = 0;
9458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9461         ret_ref = (uintptr_t)ret_var.inner;
9462         if (ret_var.is_owned) {
9463                 ret_ref |= 1;
9464         }
9465         return ret_ref;
9466 }
9467
9468 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9469 CHECK(!owner->result_ok);
9470         return DecodeError_clone(&*owner->contents.err);
9471 }
9472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9473         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9474         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9475         int64_t ret_ref = 0;
9476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9479         ret_ref = (uintptr_t)ret_var.inner;
9480         if (ret_var.is_owned) {
9481                 ret_ref |= 1;
9482         }
9483         return ret_ref;
9484 }
9485
9486 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9487 CHECK(owner->result_ok);
9488         return UpdateAddHTLC_clone(&*owner->contents.result);
9489 }
9490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9491         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9492         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9493         int64_t ret_ref = 0;
9494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9497         ret_ref = (uintptr_t)ret_var.inner;
9498         if (ret_var.is_owned) {
9499                 ret_ref |= 1;
9500         }
9501         return ret_ref;
9502 }
9503
9504 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9505 CHECK(!owner->result_ok);
9506         return DecodeError_clone(&*owner->contents.err);
9507 }
9508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9509         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9510         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9511         int64_t ret_ref = 0;
9512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9515         ret_ref = (uintptr_t)ret_var.inner;
9516         if (ret_var.is_owned) {
9517                 ret_ref |= 1;
9518         }
9519         return ret_ref;
9520 }
9521
9522 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9523 CHECK(owner->result_ok);
9524         return Ping_clone(&*owner->contents.result);
9525 }
9526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9527         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9528         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9529         int64_t ret_ref = 0;
9530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9533         ret_ref = (uintptr_t)ret_var.inner;
9534         if (ret_var.is_owned) {
9535                 ret_ref |= 1;
9536         }
9537         return ret_ref;
9538 }
9539
9540 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9541 CHECK(!owner->result_ok);
9542         return DecodeError_clone(&*owner->contents.err);
9543 }
9544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9545         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9546         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9547         int64_t ret_ref = 0;
9548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9551         ret_ref = (uintptr_t)ret_var.inner;
9552         if (ret_var.is_owned) {
9553                 ret_ref |= 1;
9554         }
9555         return ret_ref;
9556 }
9557
9558 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9559 CHECK(owner->result_ok);
9560         return Pong_clone(&*owner->contents.result);
9561 }
9562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9563         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9564         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9565         int64_t ret_ref = 0;
9566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9569         ret_ref = (uintptr_t)ret_var.inner;
9570         if (ret_var.is_owned) {
9571                 ret_ref |= 1;
9572         }
9573         return ret_ref;
9574 }
9575
9576 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9577 CHECK(!owner->result_ok);
9578         return DecodeError_clone(&*owner->contents.err);
9579 }
9580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9581         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9582         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9583         int64_t ret_ref = 0;
9584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9587         ret_ref = (uintptr_t)ret_var.inner;
9588         if (ret_var.is_owned) {
9589                 ret_ref |= 1;
9590         }
9591         return ret_ref;
9592 }
9593
9594 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9595 CHECK(owner->result_ok);
9596         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
9597 }
9598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9599         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9600         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9601         int64_t ret_ref = 0;
9602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9605         ret_ref = (uintptr_t)ret_var.inner;
9606         if (ret_var.is_owned) {
9607                 ret_ref |= 1;
9608         }
9609         return ret_ref;
9610 }
9611
9612 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9613 CHECK(!owner->result_ok);
9614         return DecodeError_clone(&*owner->contents.err);
9615 }
9616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9617         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9618         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9619         int64_t ret_ref = 0;
9620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9623         ret_ref = (uintptr_t)ret_var.inner;
9624         if (ret_var.is_owned) {
9625                 ret_ref |= 1;
9626         }
9627         return ret_ref;
9628 }
9629
9630 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9631 CHECK(owner->result_ok);
9632         return ChannelAnnouncement_clone(&*owner->contents.result);
9633 }
9634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9635         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9636         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9637         int64_t ret_ref = 0;
9638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9641         ret_ref = (uintptr_t)ret_var.inner;
9642         if (ret_var.is_owned) {
9643                 ret_ref |= 1;
9644         }
9645         return ret_ref;
9646 }
9647
9648 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9649 CHECK(!owner->result_ok);
9650         return DecodeError_clone(&*owner->contents.err);
9651 }
9652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9653         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9654         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9655         int64_t ret_ref = 0;
9656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9659         ret_ref = (uintptr_t)ret_var.inner;
9660         if (ret_var.is_owned) {
9661                 ret_ref |= 1;
9662         }
9663         return ret_ref;
9664 }
9665
9666 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9667 CHECK(owner->result_ok);
9668         return UnsignedChannelUpdate_clone(&*owner->contents.result);
9669 }
9670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9671         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9672         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9673         int64_t ret_ref = 0;
9674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9677         ret_ref = (uintptr_t)ret_var.inner;
9678         if (ret_var.is_owned) {
9679                 ret_ref |= 1;
9680         }
9681         return ret_ref;
9682 }
9683
9684 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9685 CHECK(!owner->result_ok);
9686         return DecodeError_clone(&*owner->contents.err);
9687 }
9688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9689         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9690         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9691         int64_t ret_ref = 0;
9692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9695         ret_ref = (uintptr_t)ret_var.inner;
9696         if (ret_var.is_owned) {
9697                 ret_ref |= 1;
9698         }
9699         return ret_ref;
9700 }
9701
9702 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9703 CHECK(owner->result_ok);
9704         return ChannelUpdate_clone(&*owner->contents.result);
9705 }
9706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9707         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9708         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9709         int64_t ret_ref = 0;
9710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9713         ret_ref = (uintptr_t)ret_var.inner;
9714         if (ret_var.is_owned) {
9715                 ret_ref |= 1;
9716         }
9717         return ret_ref;
9718 }
9719
9720 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9721 CHECK(!owner->result_ok);
9722         return DecodeError_clone(&*owner->contents.err);
9723 }
9724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9725         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9726         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9727         int64_t ret_ref = 0;
9728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9731         ret_ref = (uintptr_t)ret_var.inner;
9732         if (ret_var.is_owned) {
9733                 ret_ref |= 1;
9734         }
9735         return ret_ref;
9736 }
9737
9738 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9739 CHECK(owner->result_ok);
9740         return ErrorMessage_clone(&*owner->contents.result);
9741 }
9742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9743         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9744         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9745         int64_t ret_ref = 0;
9746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9749         ret_ref = (uintptr_t)ret_var.inner;
9750         if (ret_var.is_owned) {
9751                 ret_ref |= 1;
9752         }
9753         return ret_ref;
9754 }
9755
9756 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9757 CHECK(!owner->result_ok);
9758         return DecodeError_clone(&*owner->contents.err);
9759 }
9760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9761         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9762         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9763         int64_t ret_ref = 0;
9764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9767         ret_ref = (uintptr_t)ret_var.inner;
9768         if (ret_var.is_owned) {
9769                 ret_ref |= 1;
9770         }
9771         return ret_ref;
9772 }
9773
9774 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9775 CHECK(owner->result_ok);
9776         return WarningMessage_clone(&*owner->contents.result);
9777 }
9778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9779         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9780         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9781         int64_t ret_ref = 0;
9782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9785         ret_ref = (uintptr_t)ret_var.inner;
9786         if (ret_var.is_owned) {
9787                 ret_ref |= 1;
9788         }
9789         return ret_ref;
9790 }
9791
9792 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9793 CHECK(!owner->result_ok);
9794         return DecodeError_clone(&*owner->contents.err);
9795 }
9796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9797         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9798         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9799         int64_t ret_ref = 0;
9800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9803         ret_ref = (uintptr_t)ret_var.inner;
9804         if (ret_var.is_owned) {
9805                 ret_ref |= 1;
9806         }
9807         return ret_ref;
9808 }
9809
9810 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9811 CHECK(owner->result_ok);
9812         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9813 }
9814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9815         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9816         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9817         int64_t ret_ref = 0;
9818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9821         ret_ref = (uintptr_t)ret_var.inner;
9822         if (ret_var.is_owned) {
9823                 ret_ref |= 1;
9824         }
9825         return ret_ref;
9826 }
9827
9828 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9829 CHECK(!owner->result_ok);
9830         return DecodeError_clone(&*owner->contents.err);
9831 }
9832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9833         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9834         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9835         int64_t ret_ref = 0;
9836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9839         ret_ref = (uintptr_t)ret_var.inner;
9840         if (ret_var.is_owned) {
9841                 ret_ref |= 1;
9842         }
9843         return ret_ref;
9844 }
9845
9846 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9847 CHECK(owner->result_ok);
9848         return NodeAnnouncement_clone(&*owner->contents.result);
9849 }
9850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9851         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9852         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9853         int64_t ret_ref = 0;
9854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9857         ret_ref = (uintptr_t)ret_var.inner;
9858         if (ret_var.is_owned) {
9859                 ret_ref |= 1;
9860         }
9861         return ret_ref;
9862 }
9863
9864 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9865 CHECK(!owner->result_ok);
9866         return DecodeError_clone(&*owner->contents.err);
9867 }
9868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9869         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9870         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9871         int64_t ret_ref = 0;
9872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9875         ret_ref = (uintptr_t)ret_var.inner;
9876         if (ret_var.is_owned) {
9877                 ret_ref |= 1;
9878         }
9879         return ret_ref;
9880 }
9881
9882 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9883 CHECK(owner->result_ok);
9884         return QueryShortChannelIds_clone(&*owner->contents.result);
9885 }
9886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9887         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9888         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9889         int64_t ret_ref = 0;
9890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9893         ret_ref = (uintptr_t)ret_var.inner;
9894         if (ret_var.is_owned) {
9895                 ret_ref |= 1;
9896         }
9897         return ret_ref;
9898 }
9899
9900 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9901 CHECK(!owner->result_ok);
9902         return DecodeError_clone(&*owner->contents.err);
9903 }
9904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9905         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9906         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9907         int64_t ret_ref = 0;
9908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9911         ret_ref = (uintptr_t)ret_var.inner;
9912         if (ret_var.is_owned) {
9913                 ret_ref |= 1;
9914         }
9915         return ret_ref;
9916 }
9917
9918 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9919 CHECK(owner->result_ok);
9920         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9921 }
9922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9923         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9924         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9925         int64_t ret_ref = 0;
9926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9929         ret_ref = (uintptr_t)ret_var.inner;
9930         if (ret_var.is_owned) {
9931                 ret_ref |= 1;
9932         }
9933         return ret_ref;
9934 }
9935
9936 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9937 CHECK(!owner->result_ok);
9938         return DecodeError_clone(&*owner->contents.err);
9939 }
9940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9941         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9942         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9943         int64_t ret_ref = 0;
9944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9947         ret_ref = (uintptr_t)ret_var.inner;
9948         if (ret_var.is_owned) {
9949                 ret_ref |= 1;
9950         }
9951         return ret_ref;
9952 }
9953
9954 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9955 CHECK(owner->result_ok);
9956         return QueryChannelRange_clone(&*owner->contents.result);
9957 }
9958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9959         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9960         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9961         int64_t ret_ref = 0;
9962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9965         ret_ref = (uintptr_t)ret_var.inner;
9966         if (ret_var.is_owned) {
9967                 ret_ref |= 1;
9968         }
9969         return ret_ref;
9970 }
9971
9972 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9973 CHECK(!owner->result_ok);
9974         return DecodeError_clone(&*owner->contents.err);
9975 }
9976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9977         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9978         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9979         int64_t ret_ref = 0;
9980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9983         ret_ref = (uintptr_t)ret_var.inner;
9984         if (ret_var.is_owned) {
9985                 ret_ref |= 1;
9986         }
9987         return ret_ref;
9988 }
9989
9990 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9991 CHECK(owner->result_ok);
9992         return ReplyChannelRange_clone(&*owner->contents.result);
9993 }
9994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9995         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9996         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9997         int64_t ret_ref = 0;
9998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10001         ret_ref = (uintptr_t)ret_var.inner;
10002         if (ret_var.is_owned) {
10003                 ret_ref |= 1;
10004         }
10005         return ret_ref;
10006 }
10007
10008 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10009 CHECK(!owner->result_ok);
10010         return DecodeError_clone(&*owner->contents.err);
10011 }
10012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10013         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
10014         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
10015         int64_t ret_ref = 0;
10016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10019         ret_ref = (uintptr_t)ret_var.inner;
10020         if (ret_var.is_owned) {
10021                 ret_ref |= 1;
10022         }
10023         return ret_ref;
10024 }
10025
10026 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10027 CHECK(owner->result_ok);
10028         return GossipTimestampFilter_clone(&*owner->contents.result);
10029 }
10030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10031         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
10032         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
10033         int64_t ret_ref = 0;
10034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10037         ret_ref = (uintptr_t)ret_var.inner;
10038         if (ret_var.is_owned) {
10039                 ret_ref |= 1;
10040         }
10041         return ret_ref;
10042 }
10043
10044 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10045 CHECK(!owner->result_ok);
10046         return DecodeError_clone(&*owner->contents.err);
10047 }
10048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10049         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
10050         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
10051         int64_t ret_ref = 0;
10052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10055         ret_ref = (uintptr_t)ret_var.inner;
10056         if (ret_var.is_owned) {
10057                 ret_ref |= 1;
10058         }
10059         return ret_ref;
10060 }
10061
10062 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
10063         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
10064         for (size_t i = 0; i < ret.datalen; i++) {
10065                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
10066         }
10067         return ret;
10068 }
10069 static jclass LDKSignOrCreationError_SignError_class = NULL;
10070 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
10071 static jclass LDKSignOrCreationError_CreationError_class = NULL;
10072 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
10073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
10074         LDKSignOrCreationError_SignError_class =
10075                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
10076         CHECK(LDKSignOrCreationError_SignError_class != NULL);
10077         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
10078         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
10079         LDKSignOrCreationError_CreationError_class =
10080                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
10081         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
10082         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
10083         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
10084 }
10085 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10086         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
10087         switch(obj->tag) {
10088                 case LDKSignOrCreationError_SignError: {
10089                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
10090                 }
10091                 case LDKSignOrCreationError_CreationError: {
10092                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
10093                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
10094                 }
10095                 default: abort();
10096         }
10097 }
10098 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10099 CHECK(owner->result_ok);
10100         return Invoice_clone(&*owner->contents.result);
10101 }
10102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10103         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
10104         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
10105         int64_t ret_ref = 0;
10106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10109         ret_ref = (uintptr_t)ret_var.inner;
10110         if (ret_var.is_owned) {
10111                 ret_ref |= 1;
10112         }
10113         return ret_ref;
10114 }
10115
10116 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10117 CHECK(!owner->result_ok);
10118         return SignOrCreationError_clone(&*owner->contents.err);
10119 }
10120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10121         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
10122         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
10123         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
10124         int64_t ret_ref = (uintptr_t)ret_copy;
10125         return ret_ref;
10126 }
10127
10128 typedef struct LDKFilter_JCalls {
10129         atomic_size_t refcnt;
10130         JavaVM *vm;
10131         jweak o;
10132         jmethodID register_tx_meth;
10133         jmethodID register_output_meth;
10134 } LDKFilter_JCalls;
10135 static void LDKFilter_JCalls_free(void* this_arg) {
10136         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10137         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10138                 JNIEnv *env;
10139                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10140                 if (get_jenv_res == JNI_EDETACHED) {
10141                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10142                 } else {
10143                         DO_ASSERT(get_jenv_res == JNI_OK);
10144                 }
10145                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10146                 if (get_jenv_res == JNI_EDETACHED) {
10147                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10148                 }
10149                 FREE(j_calls);
10150         }
10151 }
10152 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
10153         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10154         JNIEnv *env;
10155         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10156         if (get_jenv_res == JNI_EDETACHED) {
10157                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10158         } else {
10159                 DO_ASSERT(get_jenv_res == JNI_OK);
10160         }
10161         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10162         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10163         LDKu8slice script_pubkey_var = script_pubkey;
10164         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
10165         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
10166         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10167         CHECK(obj != NULL);
10168         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
10169         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10170                 (*env)->ExceptionDescribe(env);
10171                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
10172         }
10173         if (get_jenv_res == JNI_EDETACHED) {
10174                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10175         }
10176 }
10177 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
10178         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10179         JNIEnv *env;
10180         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10181         if (get_jenv_res == JNI_EDETACHED) {
10182                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10183         } else {
10184                 DO_ASSERT(get_jenv_res == JNI_OK);
10185         }
10186         LDKWatchedOutput output_var = output;
10187         int64_t output_ref = 0;
10188         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10189         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10190         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
10191         output_ref = (uintptr_t)output_var.inner;
10192         if (output_var.is_owned) {
10193                 output_ref |= 1;
10194         }
10195         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10196         CHECK(obj != NULL);
10197         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
10198         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10199                 (*env)->ExceptionDescribe(env);
10200                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
10201         }
10202         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10203         CHECK_ACCESS(ret_ptr);
10204         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
10205         FREE((void*)ret);
10206         if (get_jenv_res == JNI_EDETACHED) {
10207                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10208         }
10209         return ret_conv;
10210 }
10211 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10212         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10213         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10214 }
10215 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10216         jclass c = (*env)->GetObjectClass(env, o);
10217         CHECK(c != NULL);
10218         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10219         atomic_init(&calls->refcnt, 1);
10220         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10221         calls->o = (*env)->NewWeakGlobalRef(env, o);
10222         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10223         CHECK(calls->register_tx_meth != NULL);
10224         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
10225         CHECK(calls->register_output_meth != NULL);
10226
10227         LDKFilter ret = {
10228                 .this_arg = (void*) calls,
10229                 .register_tx = register_tx_LDKFilter_jcall,
10230                 .register_output = register_output_LDKFilter_jcall,
10231                 .free = LDKFilter_JCalls_free,
10232         };
10233         return ret;
10234 }
10235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10236         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10237         *res_ptr = LDKFilter_init(env, clz, o);
10238         return (uint64_t)res_ptr;
10239 }
10240 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) {
10241         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10242         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10243         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10244         unsigned char txid_arr[32];
10245         CHECK((*env)->GetArrayLength(env, txid) == 32);
10246         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10247         unsigned char (*txid_ref)[32] = &txid_arr;
10248         LDKu8slice script_pubkey_ref;
10249         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10250         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10251         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10252         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10253 }
10254
10255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10256         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10257         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10258         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10259         LDKWatchedOutput output_conv;
10260         output_conv.inner = (void*)(output & (~1));
10261         output_conv.is_owned = (output & 1) || (output == 0);
10262         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10263         output_conv = WatchedOutput_clone(&output_conv);
10264         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10265         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10266         int64_t ret_ref = (uintptr_t)ret_copy;
10267         return ret_ref;
10268 }
10269
10270 static jclass LDKCOption_FilterZ_Some_class = NULL;
10271 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10272 static jclass LDKCOption_FilterZ_None_class = NULL;
10273 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10275         LDKCOption_FilterZ_Some_class =
10276                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10277         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10278         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10279         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10280         LDKCOption_FilterZ_None_class =
10281                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10282         CHECK(LDKCOption_FilterZ_None_class != NULL);
10283         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10284         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10285 }
10286 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10287         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
10288         switch(obj->tag) {
10289                 case LDKCOption_FilterZ_Some: {
10290                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10291                         *some_ret = obj->some;
10292                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10293                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10294                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10295                                 LDKFilter_JCalls_cloned(&(*some_ret));
10296                         }
10297                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
10298                 }
10299                 case LDKCOption_FilterZ_None: {
10300                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10301                 }
10302                 default: abort();
10303         }
10304 }
10305 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10306 CHECK(owner->result_ok);
10307         return &*owner->contents.result;
10308 }
10309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10310         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10311         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10312         int64_t ret_ref = 0;
10313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10316         ret_ref = (uintptr_t)ret_var.inner & ~1;
10317         return ret_ref;
10318 }
10319
10320 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10321 CHECK(!owner->result_ok);
10322         return *owner->contents.err;
10323 }
10324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10325         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10326         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10327 }
10328
10329 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10330         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10331         for (size_t i = 0; i < ret.datalen; i++) {
10332                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10333         }
10334         return ret;
10335 }
10336 typedef struct LDKMessageSendEventsProvider_JCalls {
10337         atomic_size_t refcnt;
10338         JavaVM *vm;
10339         jweak o;
10340         jmethodID get_and_clear_pending_msg_events_meth;
10341 } LDKMessageSendEventsProvider_JCalls;
10342 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10343         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10344         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10345                 JNIEnv *env;
10346                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10347                 if (get_jenv_res == JNI_EDETACHED) {
10348                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10349                 } else {
10350                         DO_ASSERT(get_jenv_res == JNI_OK);
10351                 }
10352                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10353                 if (get_jenv_res == JNI_EDETACHED) {
10354                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10355                 }
10356                 FREE(j_calls);
10357         }
10358 }
10359 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10360         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10361         JNIEnv *env;
10362         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10363         if (get_jenv_res == JNI_EDETACHED) {
10364                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10365         } else {
10366                 DO_ASSERT(get_jenv_res == JNI_OK);
10367         }
10368         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10369         CHECK(obj != NULL);
10370         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10371         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10372                 (*env)->ExceptionDescribe(env);
10373                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10374         }
10375         LDKCVec_MessageSendEventZ ret_constr;
10376         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10377         if (ret_constr.datalen > 0)
10378                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10379         else
10380                 ret_constr.data = NULL;
10381         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10382         for (size_t s = 0; s < ret_constr.datalen; s++) {
10383                 int64_t ret_conv_18 = ret_vals[s];
10384                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
10385                 CHECK_ACCESS(ret_conv_18_ptr);
10386                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10387                 FREE((void*)ret_conv_18);
10388                 ret_constr.data[s] = ret_conv_18_conv;
10389         }
10390         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10391         if (get_jenv_res == JNI_EDETACHED) {
10392                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10393         }
10394         return ret_constr;
10395 }
10396 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10397         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10398         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10399 }
10400 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10401         jclass c = (*env)->GetObjectClass(env, o);
10402         CHECK(c != NULL);
10403         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10404         atomic_init(&calls->refcnt, 1);
10405         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10406         calls->o = (*env)->NewWeakGlobalRef(env, o);
10407         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10408         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10409
10410         LDKMessageSendEventsProvider ret = {
10411                 .this_arg = (void*) calls,
10412                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10413                 .free = LDKMessageSendEventsProvider_JCalls_free,
10414         };
10415         return ret;
10416 }
10417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10418         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10419         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10420         return (uint64_t)res_ptr;
10421 }
10422 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10423         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10424         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10425         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10426         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10427         int64_tArray ret_arr = NULL;
10428         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10429         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10430         for (size_t s = 0; s < ret_var.datalen; s++) {
10431                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10432                 *ret_conv_18_copy = ret_var.data[s];
10433                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
10434                 ret_arr_ptr[s] = ret_conv_18_ref;
10435         }
10436         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10437         FREE(ret_var.data);
10438         return ret_arr;
10439 }
10440
10441 typedef struct LDKEventHandler_JCalls {
10442         atomic_size_t refcnt;
10443         JavaVM *vm;
10444         jweak o;
10445         jmethodID handle_event_meth;
10446 } LDKEventHandler_JCalls;
10447 static void LDKEventHandler_JCalls_free(void* this_arg) {
10448         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10449         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10450                 JNIEnv *env;
10451                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10452                 if (get_jenv_res == JNI_EDETACHED) {
10453                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10454                 } else {
10455                         DO_ASSERT(get_jenv_res == JNI_OK);
10456                 }
10457                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10458                 if (get_jenv_res == JNI_EDETACHED) {
10459                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10460                 }
10461                 FREE(j_calls);
10462         }
10463 }
10464 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10465         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10466         JNIEnv *env;
10467         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10468         if (get_jenv_res == JNI_EDETACHED) {
10469                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10470         } else {
10471                 DO_ASSERT(get_jenv_res == JNI_OK);
10472         }
10473         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10474         *ret_event = Event_clone(event);
10475         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10476         CHECK(obj != NULL);
10477         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
10478         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10479                 (*env)->ExceptionDescribe(env);
10480                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10481         }
10482         if (get_jenv_res == JNI_EDETACHED) {
10483                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10484         }
10485 }
10486 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10487         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10488         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10489 }
10490 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10491         jclass c = (*env)->GetObjectClass(env, o);
10492         CHECK(c != NULL);
10493         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10494         atomic_init(&calls->refcnt, 1);
10495         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10496         calls->o = (*env)->NewWeakGlobalRef(env, o);
10497         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10498         CHECK(calls->handle_event_meth != NULL);
10499
10500         LDKEventHandler ret = {
10501                 .this_arg = (void*) calls,
10502                 .handle_event = handle_event_LDKEventHandler_jcall,
10503                 .free = LDKEventHandler_JCalls_free,
10504         };
10505         return ret;
10506 }
10507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10508         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10509         *res_ptr = LDKEventHandler_init(env, clz, o);
10510         return (uint64_t)res_ptr;
10511 }
10512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10513         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10514         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10515         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10516         LDKEvent* event_conv = (LDKEvent*)event;
10517         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10518 }
10519
10520 typedef struct LDKEventsProvider_JCalls {
10521         atomic_size_t refcnt;
10522         JavaVM *vm;
10523         jweak o;
10524         jmethodID process_pending_events_meth;
10525 } LDKEventsProvider_JCalls;
10526 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10527         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10528         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10529                 JNIEnv *env;
10530                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10531                 if (get_jenv_res == JNI_EDETACHED) {
10532                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10533                 } else {
10534                         DO_ASSERT(get_jenv_res == JNI_OK);
10535                 }
10536                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10537                 if (get_jenv_res == JNI_EDETACHED) {
10538                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10539                 }
10540                 FREE(j_calls);
10541         }
10542 }
10543 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10544         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10545         JNIEnv *env;
10546         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10547         if (get_jenv_res == JNI_EDETACHED) {
10548                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10549         } else {
10550                 DO_ASSERT(get_jenv_res == JNI_OK);
10551         }
10552         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10553         *handler_ret = handler;
10554         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10555         CHECK(obj != NULL);
10556         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
10557         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10558                 (*env)->ExceptionDescribe(env);
10559                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10560         }
10561         if (get_jenv_res == JNI_EDETACHED) {
10562                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10563         }
10564 }
10565 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10566         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10567         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10568 }
10569 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10570         jclass c = (*env)->GetObjectClass(env, o);
10571         CHECK(c != NULL);
10572         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10573         atomic_init(&calls->refcnt, 1);
10574         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10575         calls->o = (*env)->NewWeakGlobalRef(env, o);
10576         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10577         CHECK(calls->process_pending_events_meth != NULL);
10578
10579         LDKEventsProvider ret = {
10580                 .this_arg = (void*) calls,
10581                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10582                 .free = LDKEventsProvider_JCalls_free,
10583         };
10584         return ret;
10585 }
10586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10587         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10588         *res_ptr = LDKEventsProvider_init(env, clz, o);
10589         return (uint64_t)res_ptr;
10590 }
10591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10592         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10593         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10594         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10595         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
10596         CHECK_ACCESS(handler_ptr);
10597         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10598         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10599                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10600                 LDKEventHandler_JCalls_cloned(&handler_conv);
10601         }
10602         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10603 }
10604
10605 typedef struct LDKScore_JCalls {
10606         atomic_size_t refcnt;
10607         JavaVM *vm;
10608         jweak o;
10609         jmethodID channel_penalty_msat_meth;
10610         jmethodID payment_path_failed_meth;
10611         jmethodID payment_path_successful_meth;
10612         jmethodID probe_failed_meth;
10613         jmethodID probe_successful_meth;
10614         jmethodID write_meth;
10615 } LDKScore_JCalls;
10616 static void LDKScore_JCalls_free(void* this_arg) {
10617         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10618         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10619                 JNIEnv *env;
10620                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10621                 if (get_jenv_res == JNI_EDETACHED) {
10622                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10623                 } else {
10624                         DO_ASSERT(get_jenv_res == JNI_OK);
10625                 }
10626                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10627                 if (get_jenv_res == JNI_EDETACHED) {
10628                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10629                 }
10630                 FREE(j_calls);
10631         }
10632 }
10633 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
10634         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10635         JNIEnv *env;
10636         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10637         if (get_jenv_res == JNI_EDETACHED) {
10638                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10639         } else {
10640                 DO_ASSERT(get_jenv_res == JNI_OK);
10641         }
10642         int64_t short_channel_id_conv = short_channel_id;
10643         LDKNodeId source_var = *source;
10644         int64_t source_ref = 0;
10645         source_var = NodeId_clone(&source_var);
10646         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10647         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10648         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
10649         source_ref = (uintptr_t)source_var.inner;
10650         if (source_var.is_owned) {
10651                 source_ref |= 1;
10652         }
10653         LDKNodeId target_var = *target;
10654         int64_t target_ref = 0;
10655         target_var = NodeId_clone(&target_var);
10656         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10657         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10658         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
10659         target_ref = (uintptr_t)target_var.inner;
10660         if (target_var.is_owned) {
10661                 target_ref |= 1;
10662         }
10663         LDKChannelUsage usage_var = usage;
10664         int64_t usage_ref = 0;
10665         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10666         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10667         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
10668         usage_ref = (uintptr_t)usage_var.inner;
10669         if (usage_var.is_owned) {
10670                 usage_ref |= 1;
10671         }
10672         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10673         CHECK(obj != NULL);
10674         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
10675         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10676                 (*env)->ExceptionDescribe(env);
10677                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10678         }
10679         if (get_jenv_res == JNI_EDETACHED) {
10680                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10681         }
10682         return ret;
10683 }
10684 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10685         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10686         JNIEnv *env;
10687         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10688         if (get_jenv_res == JNI_EDETACHED) {
10689                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10690         } else {
10691                 DO_ASSERT(get_jenv_res == JNI_OK);
10692         }
10693         LDKCVec_RouteHopZ path_var = path;
10694         int64_tArray path_arr = NULL;
10695         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10696         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10697         for (size_t k = 0; k < path_var.datalen; k++) {
10698                 LDKRouteHop path_conv_10_var = path_var.data[k];
10699                 int64_t path_conv_10_ref = 0;
10700                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10701                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10702                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10703                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10704                 if (path_conv_10_var.is_owned) {
10705                         path_conv_10_ref |= 1;
10706                 }
10707                 path_arr_ptr[k] = path_conv_10_ref;
10708         }
10709         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10710         FREE(path_var.data);
10711         int64_t short_channel_id_conv = short_channel_id;
10712         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10713         CHECK(obj != NULL);
10714         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
10715         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10716                 (*env)->ExceptionDescribe(env);
10717                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10718         }
10719         if (get_jenv_res == JNI_EDETACHED) {
10720                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10721         }
10722 }
10723 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10724         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10725         JNIEnv *env;
10726         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10727         if (get_jenv_res == JNI_EDETACHED) {
10728                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10729         } else {
10730                 DO_ASSERT(get_jenv_res == JNI_OK);
10731         }
10732         LDKCVec_RouteHopZ path_var = path;
10733         int64_tArray path_arr = NULL;
10734         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10735         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10736         for (size_t k = 0; k < path_var.datalen; k++) {
10737                 LDKRouteHop path_conv_10_var = path_var.data[k];
10738                 int64_t path_conv_10_ref = 0;
10739                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10740                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10741                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10742                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10743                 if (path_conv_10_var.is_owned) {
10744                         path_conv_10_ref |= 1;
10745                 }
10746                 path_arr_ptr[k] = path_conv_10_ref;
10747         }
10748         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10749         FREE(path_var.data);
10750         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10751         CHECK(obj != NULL);
10752         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
10753         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10754                 (*env)->ExceptionDescribe(env);
10755                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
10756         }
10757         if (get_jenv_res == JNI_EDETACHED) {
10758                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10759         }
10760 }
10761 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10762         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10763         JNIEnv *env;
10764         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10765         if (get_jenv_res == JNI_EDETACHED) {
10766                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10767         } else {
10768                 DO_ASSERT(get_jenv_res == JNI_OK);
10769         }
10770         LDKCVec_RouteHopZ path_var = path;
10771         int64_tArray path_arr = NULL;
10772         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10773         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10774         for (size_t k = 0; k < path_var.datalen; k++) {
10775                 LDKRouteHop path_conv_10_var = path_var.data[k];
10776                 int64_t path_conv_10_ref = 0;
10777                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10778                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10779                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10780                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10781                 if (path_conv_10_var.is_owned) {
10782                         path_conv_10_ref |= 1;
10783                 }
10784                 path_arr_ptr[k] = path_conv_10_ref;
10785         }
10786         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10787         FREE(path_var.data);
10788         int64_t short_channel_id_conv = short_channel_id;
10789         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10790         CHECK(obj != NULL);
10791         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
10792         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10793                 (*env)->ExceptionDescribe(env);
10794                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
10795         }
10796         if (get_jenv_res == JNI_EDETACHED) {
10797                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10798         }
10799 }
10800 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10801         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10802         JNIEnv *env;
10803         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10804         if (get_jenv_res == JNI_EDETACHED) {
10805                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10806         } else {
10807                 DO_ASSERT(get_jenv_res == JNI_OK);
10808         }
10809         LDKCVec_RouteHopZ path_var = path;
10810         int64_tArray path_arr = NULL;
10811         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10812         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10813         for (size_t k = 0; k < path_var.datalen; k++) {
10814                 LDKRouteHop path_conv_10_var = path_var.data[k];
10815                 int64_t path_conv_10_ref = 0;
10816                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10817                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10818                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10819                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10820                 if (path_conv_10_var.is_owned) {
10821                         path_conv_10_ref |= 1;
10822                 }
10823                 path_arr_ptr[k] = path_conv_10_ref;
10824         }
10825         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10826         FREE(path_var.data);
10827         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10828         CHECK(obj != NULL);
10829         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
10830         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10831                 (*env)->ExceptionDescribe(env);
10832                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
10833         }
10834         if (get_jenv_res == JNI_EDETACHED) {
10835                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10836         }
10837 }
10838 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10839         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10840         JNIEnv *env;
10841         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10842         if (get_jenv_res == JNI_EDETACHED) {
10843                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10844         } else {
10845                 DO_ASSERT(get_jenv_res == JNI_OK);
10846         }
10847         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10848         CHECK(obj != NULL);
10849         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10850         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10851                 (*env)->ExceptionDescribe(env);
10852                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10853         }
10854         LDKCVec_u8Z ret_ref;
10855         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10856         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10857         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10858         if (get_jenv_res == JNI_EDETACHED) {
10859                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10860         }
10861         return ret_ref;
10862 }
10863 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10864         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10865         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10866 }
10867 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10868         jclass c = (*env)->GetObjectClass(env, o);
10869         CHECK(c != NULL);
10870         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10871         atomic_init(&calls->refcnt, 1);
10872         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10873         calls->o = (*env)->NewWeakGlobalRef(env, o);
10874         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
10875         CHECK(calls->channel_penalty_msat_meth != NULL);
10876         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10877         CHECK(calls->payment_path_failed_meth != NULL);
10878         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
10879         CHECK(calls->payment_path_successful_meth != NULL);
10880         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
10881         CHECK(calls->probe_failed_meth != NULL);
10882         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
10883         CHECK(calls->probe_successful_meth != NULL);
10884         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10885         CHECK(calls->write_meth != NULL);
10886
10887         LDKScore ret = {
10888                 .this_arg = (void*) calls,
10889                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10890                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10891                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
10892                 .probe_failed = probe_failed_LDKScore_jcall,
10893                 .probe_successful = probe_successful_LDKScore_jcall,
10894                 .write = write_LDKScore_jcall,
10895                 .free = LDKScore_JCalls_free,
10896         };
10897         return ret;
10898 }
10899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10900         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10901         *res_ptr = LDKScore_init(env, clz, o);
10902         return (uint64_t)res_ptr;
10903 }
10904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t source, int64_t target, int64_t usage) {
10905         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10906         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10907         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10908         LDKNodeId source_conv;
10909         source_conv.inner = (void*)(source & (~1));
10910         source_conv.is_owned = false;
10911         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10912         LDKNodeId target_conv;
10913         target_conv.inner = (void*)(target & (~1));
10914         target_conv.is_owned = false;
10915         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10916         LDKChannelUsage usage_conv;
10917         usage_conv.inner = (void*)(usage & (~1));
10918         usage_conv.is_owned = (usage & 1) || (usage == 0);
10919         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
10920         usage_conv = ChannelUsage_clone(&usage_conv);
10921         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
10922         return ret_conv;
10923 }
10924
10925 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) {
10926         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10927         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10928         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10929         LDKCVec_RouteHopZ path_constr;
10930         path_constr.datalen = (*env)->GetArrayLength(env, path);
10931         if (path_constr.datalen > 0)
10932                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10933         else
10934                 path_constr.data = NULL;
10935         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10936         for (size_t k = 0; k < path_constr.datalen; k++) {
10937                 int64_t path_conv_10 = path_vals[k];
10938                 LDKRouteHop path_conv_10_conv;
10939                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10940                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10941                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10942                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10943                 path_constr.data[k] = path_conv_10_conv;
10944         }
10945         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10946         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10947 }
10948
10949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10950         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10951         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10952         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10953         LDKCVec_RouteHopZ path_constr;
10954         path_constr.datalen = (*env)->GetArrayLength(env, path);
10955         if (path_constr.datalen > 0)
10956                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10957         else
10958                 path_constr.data = NULL;
10959         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10960         for (size_t k = 0; k < path_constr.datalen; k++) {
10961                 int64_t path_conv_10 = path_vals[k];
10962                 LDKRouteHop path_conv_10_conv;
10963                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10964                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10965                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10966                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10967                 path_constr.data[k] = path_conv_10_conv;
10968         }
10969         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10970         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10971 }
10972
10973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
10974         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10975         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10976         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10977         LDKCVec_RouteHopZ path_constr;
10978         path_constr.datalen = (*env)->GetArrayLength(env, path);
10979         if (path_constr.datalen > 0)
10980                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10981         else
10982                 path_constr.data = NULL;
10983         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10984         for (size_t k = 0; k < path_constr.datalen; k++) {
10985                 int64_t path_conv_10 = path_vals[k];
10986                 LDKRouteHop path_conv_10_conv;
10987                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10988                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10989                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10990                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10991                 path_constr.data[k] = path_conv_10_conv;
10992         }
10993         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10994         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10995 }
10996
10997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10998         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10999         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11000         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
11001         LDKCVec_RouteHopZ path_constr;
11002         path_constr.datalen = (*env)->GetArrayLength(env, path);
11003         if (path_constr.datalen > 0)
11004                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11005         else
11006                 path_constr.data = NULL;
11007         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
11008         for (size_t k = 0; k < path_constr.datalen; k++) {
11009                 int64_t path_conv_10 = path_vals[k];
11010                 LDKRouteHop path_conv_10_conv;
11011                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
11012                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
11013                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
11014                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
11015                 path_constr.data[k] = path_conv_10_conv;
11016         }
11017         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
11018         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
11019 }
11020
11021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
11022         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11023         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11024         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
11025         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
11026         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11027         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11028         CVec_u8Z_free(ret_var);
11029         return ret_arr;
11030 }
11031
11032 typedef struct LDKPersister_JCalls {
11033         atomic_size_t refcnt;
11034         JavaVM *vm;
11035         jweak o;
11036         jmethodID persist_manager_meth;
11037         jmethodID persist_graph_meth;
11038         jmethodID persist_scorer_meth;
11039 } LDKPersister_JCalls;
11040 static void LDKPersister_JCalls_free(void* this_arg) {
11041         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11042         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11043                 JNIEnv *env;
11044                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11045                 if (get_jenv_res == JNI_EDETACHED) {
11046                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11047                 } else {
11048                         DO_ASSERT(get_jenv_res == JNI_OK);
11049                 }
11050                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11051                 if (get_jenv_res == JNI_EDETACHED) {
11052                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11053                 }
11054                 FREE(j_calls);
11055         }
11056 }
11057 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
11058         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11059         JNIEnv *env;
11060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11061         if (get_jenv_res == JNI_EDETACHED) {
11062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11063         } else {
11064                 DO_ASSERT(get_jenv_res == JNI_OK);
11065         }
11066         LDKChannelManager channel_manager_var = *channel_manager;
11067         int64_t channel_manager_ref = 0;
11068         // WARNING: we may need a move here but no clone is available for LDKChannelManager
11069         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11070         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11071         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
11072         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
11073         if (channel_manager_var.is_owned) {
11074                 channel_manager_ref |= 1;
11075         }
11076         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11077         CHECK(obj != NULL);
11078         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
11079         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11080                 (*env)->ExceptionDescribe(env);
11081                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
11082         }
11083         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11084         CHECK_ACCESS(ret_ptr);
11085         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11086         FREE((void*)ret);
11087         if (get_jenv_res == JNI_EDETACHED) {
11088                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11089         }
11090         return ret_conv;
11091 }
11092 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
11093         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11094         JNIEnv *env;
11095         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11096         if (get_jenv_res == JNI_EDETACHED) {
11097                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11098         } else {
11099                 DO_ASSERT(get_jenv_res == JNI_OK);
11100         }
11101         LDKNetworkGraph network_graph_var = *network_graph;
11102         int64_t network_graph_ref = 0;
11103         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
11104         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11105         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11106         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
11107         network_graph_ref = (uintptr_t)network_graph_var.inner;
11108         if (network_graph_var.is_owned) {
11109                 network_graph_ref |= 1;
11110         }
11111         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11112         CHECK(obj != NULL);
11113         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
11114         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11115                 (*env)->ExceptionDescribe(env);
11116                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
11117         }
11118         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11119         CHECK_ACCESS(ret_ptr);
11120         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11121         FREE((void*)ret);
11122         if (get_jenv_res == JNI_EDETACHED) {
11123                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11124         }
11125         return ret_conv;
11126 }
11127 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
11128         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11129         JNIEnv *env;
11130         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11131         if (get_jenv_res == JNI_EDETACHED) {
11132                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11133         } else {
11134                 DO_ASSERT(get_jenv_res == JNI_OK);
11135         }
11136         LDKMultiThreadedLockableScore scorer_var = *scorer;
11137         int64_t scorer_ref = 0;
11138         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
11139         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11140         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11141         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
11142         scorer_ref = (uintptr_t)scorer_var.inner;
11143         if (scorer_var.is_owned) {
11144                 scorer_ref |= 1;
11145         }
11146         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11147         CHECK(obj != NULL);
11148         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, scorer_ref);
11149         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11150                 (*env)->ExceptionDescribe(env);
11151                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
11152         }
11153         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11154         CHECK_ACCESS(ret_ptr);
11155         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11156         FREE((void*)ret);
11157         if (get_jenv_res == JNI_EDETACHED) {
11158                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11159         }
11160         return ret_conv;
11161 }
11162 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
11163         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
11164         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11165 }
11166 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
11167         jclass c = (*env)->GetObjectClass(env, o);
11168         CHECK(c != NULL);
11169         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
11170         atomic_init(&calls->refcnt, 1);
11171         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11172         calls->o = (*env)->NewWeakGlobalRef(env, o);
11173         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
11174         CHECK(calls->persist_manager_meth != NULL);
11175         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
11176         CHECK(calls->persist_graph_meth != NULL);
11177         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
11178         CHECK(calls->persist_scorer_meth != NULL);
11179
11180         LDKPersister ret = {
11181                 .this_arg = (void*) calls,
11182                 .persist_manager = persist_manager_LDKPersister_jcall,
11183                 .persist_graph = persist_graph_LDKPersister_jcall,
11184                 .persist_scorer = persist_scorer_LDKPersister_jcall,
11185                 .free = LDKPersister_JCalls_free,
11186         };
11187         return ret;
11188 }
11189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
11190         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
11191         *res_ptr = LDKPersister_init(env, clz, o);
11192         return (uint64_t)res_ptr;
11193 }
11194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
11195         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11196         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11197         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11198         LDKChannelManager channel_manager_conv;
11199         channel_manager_conv.inner = (void*)(channel_manager & (~1));
11200         channel_manager_conv.is_owned = false;
11201         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
11202         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11203         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
11204         return (int64_t)ret_conv;
11205 }
11206
11207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
11208         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11209         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11210         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11211         LDKNetworkGraph network_graph_conv;
11212         network_graph_conv.inner = (void*)(network_graph & (~1));
11213         network_graph_conv.is_owned = false;
11214         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
11215         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11216         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
11217         return (int64_t)ret_conv;
11218 }
11219
11220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
11221         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11222         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11223         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11224         LDKMultiThreadedLockableScore scorer_conv;
11225         scorer_conv.inner = (void*)(scorer & (~1));
11226         scorer_conv.is_owned = false;
11227         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
11228         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11229         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
11230         return (int64_t)ret_conv;
11231 }
11232
11233 typedef struct LDKListen_JCalls {
11234         atomic_size_t refcnt;
11235         JavaVM *vm;
11236         jweak o;
11237         jmethodID filtered_block_connected_meth;
11238         jmethodID block_connected_meth;
11239         jmethodID block_disconnected_meth;
11240 } LDKListen_JCalls;
11241 static void LDKListen_JCalls_free(void* this_arg) {
11242         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11243         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11244                 JNIEnv *env;
11245                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11246                 if (get_jenv_res == JNI_EDETACHED) {
11247                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11248                 } else {
11249                         DO_ASSERT(get_jenv_res == JNI_OK);
11250                 }
11251                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11252                 if (get_jenv_res == JNI_EDETACHED) {
11253                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11254                 }
11255                 FREE(j_calls);
11256         }
11257 }
11258 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11259         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11260         JNIEnv *env;
11261         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11262         if (get_jenv_res == JNI_EDETACHED) {
11263                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11264         } else {
11265                 DO_ASSERT(get_jenv_res == JNI_OK);
11266         }
11267         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11268         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11269         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11270         int64_tArray txdata_arr = NULL;
11271         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11272         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11273         for (size_t c = 0; c < txdata_var.datalen; c++) {
11274                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11275                 *txdata_conv_28_conv = txdata_var.data[c];
11276                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
11277         }
11278         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11279         FREE(txdata_var.data);
11280         int32_t height_conv = height;
11281         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11282         CHECK(obj != NULL);
11283         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
11284         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11285                 (*env)->ExceptionDescribe(env);
11286                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
11287         }
11288         if (get_jenv_res == JNI_EDETACHED) {
11289                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11290         }
11291 }
11292 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
11293         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11294         JNIEnv *env;
11295         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11296         if (get_jenv_res == JNI_EDETACHED) {
11297                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11298         } else {
11299                 DO_ASSERT(get_jenv_res == JNI_OK);
11300         }
11301         LDKu8slice block_var = block;
11302         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
11303         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
11304         int32_t height_conv = height;
11305         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11306         CHECK(obj != NULL);
11307         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
11308         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11309                 (*env)->ExceptionDescribe(env);
11310                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
11311         }
11312         if (get_jenv_res == JNI_EDETACHED) {
11313                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11314         }
11315 }
11316 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11317         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11318         JNIEnv *env;
11319         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11320         if (get_jenv_res == JNI_EDETACHED) {
11321                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11322         } else {
11323                 DO_ASSERT(get_jenv_res == JNI_OK);
11324         }
11325         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11326         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11327         int32_t height_conv = height;
11328         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11329         CHECK(obj != NULL);
11330         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
11331         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11332                 (*env)->ExceptionDescribe(env);
11333                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
11334         }
11335         if (get_jenv_res == JNI_EDETACHED) {
11336                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11337         }
11338 }
11339 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11340         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11341         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11342 }
11343 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11344         jclass c = (*env)->GetObjectClass(env, o);
11345         CHECK(c != NULL);
11346         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11347         atomic_init(&calls->refcnt, 1);
11348         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11349         calls->o = (*env)->NewWeakGlobalRef(env, o);
11350         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11351         CHECK(calls->filtered_block_connected_meth != NULL);
11352         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11353         CHECK(calls->block_connected_meth != NULL);
11354         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11355         CHECK(calls->block_disconnected_meth != NULL);
11356
11357         LDKListen ret = {
11358                 .this_arg = (void*) calls,
11359                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11360                 .block_connected = block_connected_LDKListen_jcall,
11361                 .block_disconnected = block_disconnected_LDKListen_jcall,
11362                 .free = LDKListen_JCalls_free,
11363         };
11364         return ret;
11365 }
11366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11367         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11368         *res_ptr = LDKListen_init(env, clz, o);
11369         return (uint64_t)res_ptr;
11370 }
11371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1filtered_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
11372         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11373         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11374         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11375         unsigned char header_arr[80];
11376         CHECK((*env)->GetArrayLength(env, header) == 80);
11377         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11378         unsigned char (*header_ref)[80] = &header_arr;
11379         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11380         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11381         if (txdata_constr.datalen > 0)
11382                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11383         else
11384                 txdata_constr.data = NULL;
11385         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11386         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11387                 int64_t txdata_conv_28 = txdata_vals[c];
11388                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11389                 CHECK_ACCESS(txdata_conv_28_ptr);
11390                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11391                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11392                 txdata_constr.data[c] = txdata_conv_28_conv;
11393         }
11394         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11395         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11396 }
11397
11398 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) {
11399         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11400         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11401         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11402         LDKu8slice block_ref;
11403         block_ref.datalen = (*env)->GetArrayLength(env, block);
11404         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11405         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11406         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11407 }
11408
11409 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) {
11410         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11411         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11412         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11413         unsigned char header_arr[80];
11414         CHECK((*env)->GetArrayLength(env, header) == 80);
11415         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11416         unsigned char (*header_ref)[80] = &header_arr;
11417         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11418 }
11419
11420 typedef struct LDKConfirm_JCalls {
11421         atomic_size_t refcnt;
11422         JavaVM *vm;
11423         jweak o;
11424         jmethodID transactions_confirmed_meth;
11425         jmethodID transaction_unconfirmed_meth;
11426         jmethodID best_block_updated_meth;
11427         jmethodID get_relevant_txids_meth;
11428 } LDKConfirm_JCalls;
11429 static void LDKConfirm_JCalls_free(void* this_arg) {
11430         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11431         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11440                 if (get_jenv_res == JNI_EDETACHED) {
11441                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11442                 }
11443                 FREE(j_calls);
11444         }
11445 }
11446 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11447         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11448         JNIEnv *env;
11449         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11450         if (get_jenv_res == JNI_EDETACHED) {
11451                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11452         } else {
11453                 DO_ASSERT(get_jenv_res == JNI_OK);
11454         }
11455         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11456         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11457         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11458         int64_tArray txdata_arr = NULL;
11459         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11460         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11461         for (size_t c = 0; c < txdata_var.datalen; c++) {
11462                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11463                 *txdata_conv_28_conv = txdata_var.data[c];
11464                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
11465         }
11466         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11467         FREE(txdata_var.data);
11468         int32_t height_conv = height;
11469         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11470         CHECK(obj != NULL);
11471         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11472         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11473                 (*env)->ExceptionDescribe(env);
11474                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11475         }
11476         if (get_jenv_res == JNI_EDETACHED) {
11477                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11478         }
11479 }
11480 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11481         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11482         JNIEnv *env;
11483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11484         if (get_jenv_res == JNI_EDETACHED) {
11485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11486         } else {
11487                 DO_ASSERT(get_jenv_res == JNI_OK);
11488         }
11489         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11490         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11491         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11492         CHECK(obj != NULL);
11493         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11494         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11495                 (*env)->ExceptionDescribe(env);
11496                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11497         }
11498         if (get_jenv_res == JNI_EDETACHED) {
11499                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11500         }
11501 }
11502 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11503         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11504         JNIEnv *env;
11505         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11506         if (get_jenv_res == JNI_EDETACHED) {
11507                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11508         } else {
11509                 DO_ASSERT(get_jenv_res == JNI_OK);
11510         }
11511         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11512         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11513         int32_t height_conv = height;
11514         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11515         CHECK(obj != NULL);
11516         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11517         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11518                 (*env)->ExceptionDescribe(env);
11519                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11520         }
11521         if (get_jenv_res == JNI_EDETACHED) {
11522                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11523         }
11524 }
11525 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11526         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11527         JNIEnv *env;
11528         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11529         if (get_jenv_res == JNI_EDETACHED) {
11530                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11531         } else {
11532                 DO_ASSERT(get_jenv_res == JNI_OK);
11533         }
11534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11535         CHECK(obj != NULL);
11536         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11537         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11538                 (*env)->ExceptionDescribe(env);
11539                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11540         }
11541         LDKCVec_TxidZ ret_constr;
11542         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11543         if (ret_constr.datalen > 0)
11544                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11545         else
11546                 ret_constr.data = NULL;
11547         for (size_t i = 0; i < ret_constr.datalen; i++) {
11548                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
11549                 LDKThirtyTwoBytes ret_conv_8_ref;
11550                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
11551                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
11552                 ret_constr.data[i] = ret_conv_8_ref;
11553         }
11554         if (get_jenv_res == JNI_EDETACHED) {
11555                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11556         }
11557         return ret_constr;
11558 }
11559 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11560         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11561         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11562 }
11563 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11564         jclass c = (*env)->GetObjectClass(env, o);
11565         CHECK(c != NULL);
11566         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11567         atomic_init(&calls->refcnt, 1);
11568         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11569         calls->o = (*env)->NewWeakGlobalRef(env, o);
11570         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11571         CHECK(calls->transactions_confirmed_meth != NULL);
11572         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11573         CHECK(calls->transaction_unconfirmed_meth != NULL);
11574         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11575         CHECK(calls->best_block_updated_meth != NULL);
11576         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
11577         CHECK(calls->get_relevant_txids_meth != NULL);
11578
11579         LDKConfirm ret = {
11580                 .this_arg = (void*) calls,
11581                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11582                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11583                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11584                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11585                 .free = LDKConfirm_JCalls_free,
11586         };
11587         return ret;
11588 }
11589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11590         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11591         *res_ptr = LDKConfirm_init(env, clz, o);
11592         return (uint64_t)res_ptr;
11593 }
11594 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) {
11595         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11596         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11597         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11598         unsigned char header_arr[80];
11599         CHECK((*env)->GetArrayLength(env, header) == 80);
11600         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11601         unsigned char (*header_ref)[80] = &header_arr;
11602         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11603         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11604         if (txdata_constr.datalen > 0)
11605                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11606         else
11607                 txdata_constr.data = NULL;
11608         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11609         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11610                 int64_t txdata_conv_28 = txdata_vals[c];
11611                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11612                 CHECK_ACCESS(txdata_conv_28_ptr);
11613                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11614                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11615                 txdata_constr.data[c] = txdata_conv_28_conv;
11616         }
11617         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11618         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11619 }
11620
11621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11622         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11623         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11624         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11625         unsigned char txid_arr[32];
11626         CHECK((*env)->GetArrayLength(env, txid) == 32);
11627         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11628         unsigned char (*txid_ref)[32] = &txid_arr;
11629         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11630 }
11631
11632 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) {
11633         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11634         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11635         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11636         unsigned char header_arr[80];
11637         CHECK((*env)->GetArrayLength(env, header) == 80);
11638         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11639         unsigned char (*header_ref)[80] = &header_arr;
11640         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11641 }
11642
11643 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11644         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11645         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11646         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11647         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11648         jobjectArray ret_arr = NULL;
11649         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11650         ;
11651         for (size_t i = 0; i < ret_var.datalen; i++) {
11652                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11653                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11654                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11655         }
11656         
11657         FREE(ret_var.data);
11658         return ret_arr;
11659 }
11660
11661 typedef struct LDKPersist_JCalls {
11662         atomic_size_t refcnt;
11663         JavaVM *vm;
11664         jweak o;
11665         jmethodID persist_new_channel_meth;
11666         jmethodID update_persisted_channel_meth;
11667 } LDKPersist_JCalls;
11668 static void LDKPersist_JCalls_free(void* this_arg) {
11669         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11670         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11671                 JNIEnv *env;
11672                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11673                 if (get_jenv_res == JNI_EDETACHED) {
11674                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11675                 } else {
11676                         DO_ASSERT(get_jenv_res == JNI_OK);
11677                 }
11678                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11679                 if (get_jenv_res == JNI_EDETACHED) {
11680                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11681                 }
11682                 FREE(j_calls);
11683         }
11684 }
11685 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11686         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11687         JNIEnv *env;
11688         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11689         if (get_jenv_res == JNI_EDETACHED) {
11690                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11691         } else {
11692                 DO_ASSERT(get_jenv_res == JNI_OK);
11693         }
11694         LDKOutPoint channel_id_var = channel_id;
11695         int64_t channel_id_ref = 0;
11696         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11697         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11698         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11699         channel_id_ref = (uintptr_t)channel_id_var.inner;
11700         if (channel_id_var.is_owned) {
11701                 channel_id_ref |= 1;
11702         }
11703         LDKChannelMonitor data_var = *data;
11704         int64_t data_ref = 0;
11705         data_var = ChannelMonitor_clone(&data_var);
11706         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11707         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11708         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11709         data_ref = (uintptr_t)data_var.inner;
11710         if (data_var.is_owned) {
11711                 data_ref |= 1;
11712         }
11713         LDKMonitorUpdateId update_id_var = update_id;
11714         int64_t update_id_ref = 0;
11715         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11716         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11717         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11718         update_id_ref = (uintptr_t)update_id_var.inner;
11719         if (update_id_var.is_owned) {
11720                 update_id_ref |= 1;
11721         }
11722         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11723         CHECK(obj != NULL);
11724         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11725         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11726                 (*env)->ExceptionDescribe(env);
11727                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11728         }
11729         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11730         CHECK_ACCESS(ret_ptr);
11731         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11732         FREE((void*)ret);
11733         if (get_jenv_res == JNI_EDETACHED) {
11734                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11735         }
11736         return ret_conv;
11737 }
11738 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11739         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11740         JNIEnv *env;
11741         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11742         if (get_jenv_res == JNI_EDETACHED) {
11743                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11744         } else {
11745                 DO_ASSERT(get_jenv_res == JNI_OK);
11746         }
11747         LDKOutPoint channel_id_var = channel_id;
11748         int64_t channel_id_ref = 0;
11749         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11750         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11751         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11752         channel_id_ref = (uintptr_t)channel_id_var.inner;
11753         if (channel_id_var.is_owned) {
11754                 channel_id_ref |= 1;
11755         }
11756         LDKChannelMonitorUpdate update_var = *update;
11757         int64_t update_ref = 0;
11758         if ((uintptr_t)update_var.inner > 4096) {
11759                 update_var = ChannelMonitorUpdate_clone(&update_var);
11760                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11761                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11762         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11763                 update_ref = (uintptr_t)update_var.inner;
11764                 if (update_var.is_owned) {
11765                         update_ref |= 1;
11766                 }
11767         }
11768         LDKChannelMonitor data_var = *data;
11769         int64_t data_ref = 0;
11770         data_var = ChannelMonitor_clone(&data_var);
11771         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11772         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11773         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11774         data_ref = (uintptr_t)data_var.inner;
11775         if (data_var.is_owned) {
11776                 data_ref |= 1;
11777         }
11778         LDKMonitorUpdateId update_id_var = update_id;
11779         int64_t update_id_ref = 0;
11780         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11781         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11782         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11783         update_id_ref = (uintptr_t)update_id_var.inner;
11784         if (update_id_var.is_owned) {
11785                 update_id_ref |= 1;
11786         }
11787         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11788         CHECK(obj != NULL);
11789         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
11790         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11791                 (*env)->ExceptionDescribe(env);
11792                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
11793         }
11794         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11795         CHECK_ACCESS(ret_ptr);
11796         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11797         FREE((void*)ret);
11798         if (get_jenv_res == JNI_EDETACHED) {
11799                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11800         }
11801         return ret_conv;
11802 }
11803 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
11804         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
11805         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11806 }
11807 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
11808         jclass c = (*env)->GetObjectClass(env, o);
11809         CHECK(c != NULL);
11810         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
11811         atomic_init(&calls->refcnt, 1);
11812         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11813         calls->o = (*env)->NewWeakGlobalRef(env, o);
11814         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
11815         CHECK(calls->persist_new_channel_meth != NULL);
11816         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
11817         CHECK(calls->update_persisted_channel_meth != NULL);
11818
11819         LDKPersist ret = {
11820                 .this_arg = (void*) calls,
11821                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
11822                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
11823                 .free = LDKPersist_JCalls_free,
11824         };
11825         return ret;
11826 }
11827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
11828         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
11829         *res_ptr = LDKPersist_init(env, clz, o);
11830         return (uint64_t)res_ptr;
11831 }
11832 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) {
11833         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11834         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11835         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11836         LDKOutPoint channel_id_conv;
11837         channel_id_conv.inner = (void*)(channel_id & (~1));
11838         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11839         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11840         channel_id_conv = OutPoint_clone(&channel_id_conv);
11841         LDKChannelMonitor data_conv;
11842         data_conv.inner = (void*)(data & (~1));
11843         data_conv.is_owned = false;
11844         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11845         LDKMonitorUpdateId update_id_conv;
11846         update_id_conv.inner = (void*)(update_id & (~1));
11847         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11848         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11849         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11850         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11851         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
11852         return (int64_t)ret_conv;
11853 }
11854
11855 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) {
11856         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11857         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11858         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11859         LDKOutPoint channel_id_conv;
11860         channel_id_conv.inner = (void*)(channel_id & (~1));
11861         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11862         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11863         channel_id_conv = OutPoint_clone(&channel_id_conv);
11864         LDKChannelMonitorUpdate update_conv;
11865         update_conv.inner = (void*)(update & (~1));
11866         update_conv.is_owned = false;
11867         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
11868         LDKChannelMonitor data_conv;
11869         data_conv.inner = (void*)(data & (~1));
11870         data_conv.is_owned = false;
11871         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11872         LDKMonitorUpdateId update_id_conv;
11873         update_id_conv.inner = (void*)(update_id & (~1));
11874         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11875         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11876         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11877         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11878         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
11879         return (int64_t)ret_conv;
11880 }
11881
11882 typedef struct LDKChannelMessageHandler_JCalls {
11883         atomic_size_t refcnt;
11884         JavaVM *vm;
11885         jweak o;
11886         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11887         jmethodID handle_open_channel_meth;
11888         jmethodID handle_accept_channel_meth;
11889         jmethodID handle_funding_created_meth;
11890         jmethodID handle_funding_signed_meth;
11891         jmethodID handle_channel_ready_meth;
11892         jmethodID handle_shutdown_meth;
11893         jmethodID handle_closing_signed_meth;
11894         jmethodID handle_update_add_htlc_meth;
11895         jmethodID handle_update_fulfill_htlc_meth;
11896         jmethodID handle_update_fail_htlc_meth;
11897         jmethodID handle_update_fail_malformed_htlc_meth;
11898         jmethodID handle_commitment_signed_meth;
11899         jmethodID handle_revoke_and_ack_meth;
11900         jmethodID handle_update_fee_meth;
11901         jmethodID handle_announcement_signatures_meth;
11902         jmethodID peer_disconnected_meth;
11903         jmethodID peer_connected_meth;
11904         jmethodID handle_channel_reestablish_meth;
11905         jmethodID handle_channel_update_meth;
11906         jmethodID handle_error_meth;
11907 } LDKChannelMessageHandler_JCalls;
11908 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
11909         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11910         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11919                 if (get_jenv_res == JNI_EDETACHED) {
11920                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11921                 }
11922                 FREE(j_calls);
11923         }
11924 }
11925 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
11926         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11927         JNIEnv *env;
11928         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11929         if (get_jenv_res == JNI_EDETACHED) {
11930                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11931         } else {
11932                 DO_ASSERT(get_jenv_res == JNI_OK);
11933         }
11934         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11935         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11936         LDKInitFeatures their_features_var = their_features;
11937         int64_t their_features_ref = 0;
11938         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11939         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11940         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11941         their_features_ref = (uintptr_t)their_features_var.inner;
11942         if (their_features_var.is_owned) {
11943                 their_features_ref |= 1;
11944         }
11945         LDKOpenChannel msg_var = *msg;
11946         int64_t msg_ref = 0;
11947         msg_var = OpenChannel_clone(&msg_var);
11948         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11949         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11950         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11951         msg_ref = (uintptr_t)msg_var.inner;
11952         if (msg_var.is_owned) {
11953                 msg_ref |= 1;
11954         }
11955         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11956         CHECK(obj != NULL);
11957         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11958         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11959                 (*env)->ExceptionDescribe(env);
11960                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
11961         }
11962         if (get_jenv_res == JNI_EDETACHED) {
11963                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11964         }
11965 }
11966 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
11967         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11968         JNIEnv *env;
11969         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11970         if (get_jenv_res == JNI_EDETACHED) {
11971                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11972         } else {
11973                 DO_ASSERT(get_jenv_res == JNI_OK);
11974         }
11975         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11976         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11977         LDKInitFeatures their_features_var = their_features;
11978         int64_t their_features_ref = 0;
11979         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11980         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11981         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11982         their_features_ref = (uintptr_t)their_features_var.inner;
11983         if (their_features_var.is_owned) {
11984                 their_features_ref |= 1;
11985         }
11986         LDKAcceptChannel msg_var = *msg;
11987         int64_t msg_ref = 0;
11988         msg_var = AcceptChannel_clone(&msg_var);
11989         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11990         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11991         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11992         msg_ref = (uintptr_t)msg_var.inner;
11993         if (msg_var.is_owned) {
11994                 msg_ref |= 1;
11995         }
11996         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11997         CHECK(obj != NULL);
11998         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11999         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12000                 (*env)->ExceptionDescribe(env);
12001                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
12002         }
12003         if (get_jenv_res == JNI_EDETACHED) {
12004                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12005         }
12006 }
12007 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
12008         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12009         JNIEnv *env;
12010         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12011         if (get_jenv_res == JNI_EDETACHED) {
12012                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12013         } else {
12014                 DO_ASSERT(get_jenv_res == JNI_OK);
12015         }
12016         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12017         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12018         LDKFundingCreated msg_var = *msg;
12019         int64_t msg_ref = 0;
12020         msg_var = FundingCreated_clone(&msg_var);
12021         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12022         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12023         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12024         msg_ref = (uintptr_t)msg_var.inner;
12025         if (msg_var.is_owned) {
12026                 msg_ref |= 1;
12027         }
12028         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12029         CHECK(obj != NULL);
12030         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
12031         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12032                 (*env)->ExceptionDescribe(env);
12033                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
12034         }
12035         if (get_jenv_res == JNI_EDETACHED) {
12036                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12037         }
12038 }
12039 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
12040         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12041         JNIEnv *env;
12042         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12043         if (get_jenv_res == JNI_EDETACHED) {
12044                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12045         } else {
12046                 DO_ASSERT(get_jenv_res == JNI_OK);
12047         }
12048         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12049         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12050         LDKFundingSigned msg_var = *msg;
12051         int64_t msg_ref = 0;
12052         msg_var = FundingSigned_clone(&msg_var);
12053         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12054         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12055         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12056         msg_ref = (uintptr_t)msg_var.inner;
12057         if (msg_var.is_owned) {
12058                 msg_ref |= 1;
12059         }
12060         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12061         CHECK(obj != NULL);
12062         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
12063         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12064                 (*env)->ExceptionDescribe(env);
12065                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
12066         }
12067         if (get_jenv_res == JNI_EDETACHED) {
12068                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12069         }
12070 }
12071 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
12072         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12073         JNIEnv *env;
12074         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12075         if (get_jenv_res == JNI_EDETACHED) {
12076                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12077         } else {
12078                 DO_ASSERT(get_jenv_res == JNI_OK);
12079         }
12080         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12081         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12082         LDKChannelReady msg_var = *msg;
12083         int64_t msg_ref = 0;
12084         msg_var = ChannelReady_clone(&msg_var);
12085         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12086         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12087         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12088         msg_ref = (uintptr_t)msg_var.inner;
12089         if (msg_var.is_owned) {
12090                 msg_ref |= 1;
12091         }
12092         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12093         CHECK(obj != NULL);
12094         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
12095         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12096                 (*env)->ExceptionDescribe(env);
12097                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
12098         }
12099         if (get_jenv_res == JNI_EDETACHED) {
12100                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12101         }
12102 }
12103 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
12104         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12105         JNIEnv *env;
12106         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12107         if (get_jenv_res == JNI_EDETACHED) {
12108                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12109         } else {
12110                 DO_ASSERT(get_jenv_res == JNI_OK);
12111         }
12112         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12113         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12114         LDKInitFeatures their_features_var = *their_features;
12115         int64_t their_features_ref = 0;
12116         their_features_var = InitFeatures_clone(&their_features_var);
12117         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12118         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12119         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12120         their_features_ref = (uintptr_t)their_features_var.inner;
12121         if (their_features_var.is_owned) {
12122                 their_features_ref |= 1;
12123         }
12124         LDKShutdown msg_var = *msg;
12125         int64_t msg_ref = 0;
12126         msg_var = Shutdown_clone(&msg_var);
12127         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12128         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12129         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12130         msg_ref = (uintptr_t)msg_var.inner;
12131         if (msg_var.is_owned) {
12132                 msg_ref |= 1;
12133         }
12134         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12135         CHECK(obj != NULL);
12136         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
12137         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12138                 (*env)->ExceptionDescribe(env);
12139                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
12140         }
12141         if (get_jenv_res == JNI_EDETACHED) {
12142                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12143         }
12144 }
12145 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
12146         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12147         JNIEnv *env;
12148         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12149         if (get_jenv_res == JNI_EDETACHED) {
12150                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12151         } else {
12152                 DO_ASSERT(get_jenv_res == JNI_OK);
12153         }
12154         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12155         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12156         LDKClosingSigned msg_var = *msg;
12157         int64_t msg_ref = 0;
12158         msg_var = ClosingSigned_clone(&msg_var);
12159         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12160         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12161         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12162         msg_ref = (uintptr_t)msg_var.inner;
12163         if (msg_var.is_owned) {
12164                 msg_ref |= 1;
12165         }
12166         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12167         CHECK(obj != NULL);
12168         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
12169         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12170                 (*env)->ExceptionDescribe(env);
12171                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
12172         }
12173         if (get_jenv_res == JNI_EDETACHED) {
12174                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12175         }
12176 }
12177 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
12178         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12179         JNIEnv *env;
12180         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12181         if (get_jenv_res == JNI_EDETACHED) {
12182                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12183         } else {
12184                 DO_ASSERT(get_jenv_res == JNI_OK);
12185         }
12186         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12187         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12188         LDKUpdateAddHTLC msg_var = *msg;
12189         int64_t msg_ref = 0;
12190         msg_var = UpdateAddHTLC_clone(&msg_var);
12191         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12192         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12193         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12194         msg_ref = (uintptr_t)msg_var.inner;
12195         if (msg_var.is_owned) {
12196                 msg_ref |= 1;
12197         }
12198         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12199         CHECK(obj != NULL);
12200         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
12201         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12202                 (*env)->ExceptionDescribe(env);
12203                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
12204         }
12205         if (get_jenv_res == JNI_EDETACHED) {
12206                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12207         }
12208 }
12209 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
12210         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12211         JNIEnv *env;
12212         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12213         if (get_jenv_res == JNI_EDETACHED) {
12214                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12215         } else {
12216                 DO_ASSERT(get_jenv_res == JNI_OK);
12217         }
12218         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12219         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12220         LDKUpdateFulfillHTLC msg_var = *msg;
12221         int64_t msg_ref = 0;
12222         msg_var = UpdateFulfillHTLC_clone(&msg_var);
12223         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12224         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12225         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12226         msg_ref = (uintptr_t)msg_var.inner;
12227         if (msg_var.is_owned) {
12228                 msg_ref |= 1;
12229         }
12230         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12231         CHECK(obj != NULL);
12232         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
12233         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12234                 (*env)->ExceptionDescribe(env);
12235                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
12236         }
12237         if (get_jenv_res == JNI_EDETACHED) {
12238                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12239         }
12240 }
12241 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
12242         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12243         JNIEnv *env;
12244         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12245         if (get_jenv_res == JNI_EDETACHED) {
12246                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12247         } else {
12248                 DO_ASSERT(get_jenv_res == JNI_OK);
12249         }
12250         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12251         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12252         LDKUpdateFailHTLC msg_var = *msg;
12253         int64_t msg_ref = 0;
12254         msg_var = UpdateFailHTLC_clone(&msg_var);
12255         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12256         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12257         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12258         msg_ref = (uintptr_t)msg_var.inner;
12259         if (msg_var.is_owned) {
12260                 msg_ref |= 1;
12261         }
12262         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12263         CHECK(obj != NULL);
12264         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
12265         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12266                 (*env)->ExceptionDescribe(env);
12267                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
12268         }
12269         if (get_jenv_res == JNI_EDETACHED) {
12270                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12271         }
12272 }
12273 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
12274         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12275         JNIEnv *env;
12276         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12277         if (get_jenv_res == JNI_EDETACHED) {
12278                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12279         } else {
12280                 DO_ASSERT(get_jenv_res == JNI_OK);
12281         }
12282         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12283         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12284         LDKUpdateFailMalformedHTLC msg_var = *msg;
12285         int64_t msg_ref = 0;
12286         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
12287         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12288         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12289         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12290         msg_ref = (uintptr_t)msg_var.inner;
12291         if (msg_var.is_owned) {
12292                 msg_ref |= 1;
12293         }
12294         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12295         CHECK(obj != NULL);
12296         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
12297         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12298                 (*env)->ExceptionDescribe(env);
12299                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
12300         }
12301         if (get_jenv_res == JNI_EDETACHED) {
12302                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12303         }
12304 }
12305 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
12306         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12307         JNIEnv *env;
12308         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12309         if (get_jenv_res == JNI_EDETACHED) {
12310                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12311         } else {
12312                 DO_ASSERT(get_jenv_res == JNI_OK);
12313         }
12314         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12315         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12316         LDKCommitmentSigned msg_var = *msg;
12317         int64_t msg_ref = 0;
12318         msg_var = CommitmentSigned_clone(&msg_var);
12319         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12320         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12321         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12322         msg_ref = (uintptr_t)msg_var.inner;
12323         if (msg_var.is_owned) {
12324                 msg_ref |= 1;
12325         }
12326         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12327         CHECK(obj != NULL);
12328         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
12329         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12330                 (*env)->ExceptionDescribe(env);
12331                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
12332         }
12333         if (get_jenv_res == JNI_EDETACHED) {
12334                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12335         }
12336 }
12337 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12338         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12339         JNIEnv *env;
12340         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12341         if (get_jenv_res == JNI_EDETACHED) {
12342                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12343         } else {
12344                 DO_ASSERT(get_jenv_res == JNI_OK);
12345         }
12346         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12347         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12348         LDKRevokeAndACK msg_var = *msg;
12349         int64_t msg_ref = 0;
12350         msg_var = RevokeAndACK_clone(&msg_var);
12351         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12352         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12353         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12354         msg_ref = (uintptr_t)msg_var.inner;
12355         if (msg_var.is_owned) {
12356                 msg_ref |= 1;
12357         }
12358         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12359         CHECK(obj != NULL);
12360         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12361         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12362                 (*env)->ExceptionDescribe(env);
12363                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12364         }
12365         if (get_jenv_res == JNI_EDETACHED) {
12366                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12367         }
12368 }
12369 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12370         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12371         JNIEnv *env;
12372         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12373         if (get_jenv_res == JNI_EDETACHED) {
12374                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12375         } else {
12376                 DO_ASSERT(get_jenv_res == JNI_OK);
12377         }
12378         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12379         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12380         LDKUpdateFee msg_var = *msg;
12381         int64_t msg_ref = 0;
12382         msg_var = UpdateFee_clone(&msg_var);
12383         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12384         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12385         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12386         msg_ref = (uintptr_t)msg_var.inner;
12387         if (msg_var.is_owned) {
12388                 msg_ref |= 1;
12389         }
12390         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12391         CHECK(obj != NULL);
12392         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12393         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12394                 (*env)->ExceptionDescribe(env);
12395                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12396         }
12397         if (get_jenv_res == JNI_EDETACHED) {
12398                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12399         }
12400 }
12401 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12402         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12403         JNIEnv *env;
12404         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12405         if (get_jenv_res == JNI_EDETACHED) {
12406                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12407         } else {
12408                 DO_ASSERT(get_jenv_res == JNI_OK);
12409         }
12410         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12411         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12412         LDKAnnouncementSignatures msg_var = *msg;
12413         int64_t msg_ref = 0;
12414         msg_var = AnnouncementSignatures_clone(&msg_var);
12415         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12416         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12417         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12418         msg_ref = (uintptr_t)msg_var.inner;
12419         if (msg_var.is_owned) {
12420                 msg_ref |= 1;
12421         }
12422         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12423         CHECK(obj != NULL);
12424         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12425         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12426                 (*env)->ExceptionDescribe(env);
12427                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12428         }
12429         if (get_jenv_res == JNI_EDETACHED) {
12430                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12431         }
12432 }
12433 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12434         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12435         JNIEnv *env;
12436         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12437         if (get_jenv_res == JNI_EDETACHED) {
12438                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12439         } else {
12440                 DO_ASSERT(get_jenv_res == JNI_OK);
12441         }
12442         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12443         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12444         jboolean no_connection_possible_conv = no_connection_possible;
12445         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12446         CHECK(obj != NULL);
12447         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12448         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12449                 (*env)->ExceptionDescribe(env);
12450                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12451         }
12452         if (get_jenv_res == JNI_EDETACHED) {
12453                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12454         }
12455 }
12456 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12457         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12458         JNIEnv *env;
12459         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12460         if (get_jenv_res == JNI_EDETACHED) {
12461                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12462         } else {
12463                 DO_ASSERT(get_jenv_res == JNI_OK);
12464         }
12465         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12466         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12467         LDKInit msg_var = *msg;
12468         int64_t msg_ref = 0;
12469         msg_var = Init_clone(&msg_var);
12470         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12471         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12472         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12473         msg_ref = (uintptr_t)msg_var.inner;
12474         if (msg_var.is_owned) {
12475                 msg_ref |= 1;
12476         }
12477         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12478         CHECK(obj != NULL);
12479         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12480         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12481                 (*env)->ExceptionDescribe(env);
12482                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12483         }
12484         if (get_jenv_res == JNI_EDETACHED) {
12485                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12486         }
12487 }
12488 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12489         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12490         JNIEnv *env;
12491         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12492         if (get_jenv_res == JNI_EDETACHED) {
12493                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12494         } else {
12495                 DO_ASSERT(get_jenv_res == JNI_OK);
12496         }
12497         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12498         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12499         LDKChannelReestablish msg_var = *msg;
12500         int64_t msg_ref = 0;
12501         msg_var = ChannelReestablish_clone(&msg_var);
12502         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12503         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12504         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12505         msg_ref = (uintptr_t)msg_var.inner;
12506         if (msg_var.is_owned) {
12507                 msg_ref |= 1;
12508         }
12509         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12510         CHECK(obj != NULL);
12511         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12512         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12513                 (*env)->ExceptionDescribe(env);
12514                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12515         }
12516         if (get_jenv_res == JNI_EDETACHED) {
12517                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12518         }
12519 }
12520 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12521         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12522         JNIEnv *env;
12523         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12524         if (get_jenv_res == JNI_EDETACHED) {
12525                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12526         } else {
12527                 DO_ASSERT(get_jenv_res == JNI_OK);
12528         }
12529         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12530         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12531         LDKChannelUpdate msg_var = *msg;
12532         int64_t msg_ref = 0;
12533         msg_var = ChannelUpdate_clone(&msg_var);
12534         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12535         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12536         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12537         msg_ref = (uintptr_t)msg_var.inner;
12538         if (msg_var.is_owned) {
12539                 msg_ref |= 1;
12540         }
12541         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12542         CHECK(obj != NULL);
12543         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12544         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12545                 (*env)->ExceptionDescribe(env);
12546                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12547         }
12548         if (get_jenv_res == JNI_EDETACHED) {
12549                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12550         }
12551 }
12552 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12553         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12554         JNIEnv *env;
12555         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12556         if (get_jenv_res == JNI_EDETACHED) {
12557                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12558         } else {
12559                 DO_ASSERT(get_jenv_res == JNI_OK);
12560         }
12561         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12562         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12563         LDKErrorMessage msg_var = *msg;
12564         int64_t msg_ref = 0;
12565         msg_var = ErrorMessage_clone(&msg_var);
12566         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12567         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12568         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12569         msg_ref = (uintptr_t)msg_var.inner;
12570         if (msg_var.is_owned) {
12571                 msg_ref |= 1;
12572         }
12573         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12574         CHECK(obj != NULL);
12575         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12576         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12577                 (*env)->ExceptionDescribe(env);
12578                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12579         }
12580         if (get_jenv_res == JNI_EDETACHED) {
12581                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12582         }
12583 }
12584 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12585         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12586         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12587         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12588 }
12589 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12590         jclass c = (*env)->GetObjectClass(env, o);
12591         CHECK(c != NULL);
12592         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12593         atomic_init(&calls->refcnt, 1);
12594         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12595         calls->o = (*env)->NewWeakGlobalRef(env, o);
12596         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12597         CHECK(calls->handle_open_channel_meth != NULL);
12598         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12599         CHECK(calls->handle_accept_channel_meth != NULL);
12600         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12601         CHECK(calls->handle_funding_created_meth != NULL);
12602         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12603         CHECK(calls->handle_funding_signed_meth != NULL);
12604         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12605         CHECK(calls->handle_channel_ready_meth != NULL);
12606         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12607         CHECK(calls->handle_shutdown_meth != NULL);
12608         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12609         CHECK(calls->handle_closing_signed_meth != NULL);
12610         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12611         CHECK(calls->handle_update_add_htlc_meth != NULL);
12612         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12613         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12614         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12615         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12616         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12617         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12618         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12619         CHECK(calls->handle_commitment_signed_meth != NULL);
12620         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12621         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12622         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12623         CHECK(calls->handle_update_fee_meth != NULL);
12624         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12625         CHECK(calls->handle_announcement_signatures_meth != NULL);
12626         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12627         CHECK(calls->peer_disconnected_meth != NULL);
12628         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12629         CHECK(calls->peer_connected_meth != NULL);
12630         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12631         CHECK(calls->handle_channel_reestablish_meth != NULL);
12632         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12633         CHECK(calls->handle_channel_update_meth != NULL);
12634         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12635         CHECK(calls->handle_error_meth != NULL);
12636
12637         LDKChannelMessageHandler ret = {
12638                 .this_arg = (void*) calls,
12639                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12640                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12641                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12642                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12643                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12644                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12645                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12646                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12647                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12648                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12649                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12650                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12651                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12652                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12653                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12654                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12655                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12656                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12657                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12658                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12659                 .free = LDKChannelMessageHandler_JCalls_free,
12660                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12661         };
12662         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12663         return ret;
12664 }
12665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12666         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12667         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12668         return (uint64_t)res_ptr;
12669 }
12670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12671         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
12672         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12673         DO_ASSERT((res_ptr & 1) == 0);
12674         return (int64_t)(res_ptr | 1);
12675 }
12676 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) {
12677         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12678         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12679         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12680         LDKPublicKey their_node_id_ref;
12681         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12682         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12683         LDKInitFeatures their_features_conv;
12684         their_features_conv.inner = (void*)(their_features & (~1));
12685         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12686         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12687         their_features_conv = InitFeatures_clone(&their_features_conv);
12688         LDKOpenChannel msg_conv;
12689         msg_conv.inner = (void*)(msg & (~1));
12690         msg_conv.is_owned = false;
12691         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12692         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12693 }
12694
12695 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) {
12696         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12697         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12698         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12699         LDKPublicKey their_node_id_ref;
12700         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12701         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12702         LDKInitFeatures their_features_conv;
12703         their_features_conv.inner = (void*)(their_features & (~1));
12704         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12705         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12706         their_features_conv = InitFeatures_clone(&their_features_conv);
12707         LDKAcceptChannel msg_conv;
12708         msg_conv.inner = (void*)(msg & (~1));
12709         msg_conv.is_owned = false;
12710         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12711         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12712 }
12713
12714 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) {
12715         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12716         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12717         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12718         LDKPublicKey their_node_id_ref;
12719         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12720         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12721         LDKFundingCreated msg_conv;
12722         msg_conv.inner = (void*)(msg & (~1));
12723         msg_conv.is_owned = false;
12724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12725         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12726 }
12727
12728 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) {
12729         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12730         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12731         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12732         LDKPublicKey their_node_id_ref;
12733         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12734         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12735         LDKFundingSigned msg_conv;
12736         msg_conv.inner = (void*)(msg & (~1));
12737         msg_conv.is_owned = false;
12738         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12739         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12740 }
12741
12742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12743         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12744         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12745         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12746         LDKPublicKey their_node_id_ref;
12747         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12748         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12749         LDKChannelReady msg_conv;
12750         msg_conv.inner = (void*)(msg & (~1));
12751         msg_conv.is_owned = false;
12752         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12753         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12754 }
12755
12756 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) {
12757         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12758         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12759         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12760         LDKPublicKey their_node_id_ref;
12761         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12762         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12763         LDKInitFeatures their_features_conv;
12764         their_features_conv.inner = (void*)(their_features & (~1));
12765         their_features_conv.is_owned = false;
12766         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12767         LDKShutdown msg_conv;
12768         msg_conv.inner = (void*)(msg & (~1));
12769         msg_conv.is_owned = false;
12770         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12771         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12772 }
12773
12774 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) {
12775         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12776         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12777         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12778         LDKPublicKey their_node_id_ref;
12779         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12780         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12781         LDKClosingSigned msg_conv;
12782         msg_conv.inner = (void*)(msg & (~1));
12783         msg_conv.is_owned = false;
12784         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12785         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12786 }
12787
12788 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) {
12789         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12790         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12791         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12792         LDKPublicKey their_node_id_ref;
12793         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12794         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12795         LDKUpdateAddHTLC msg_conv;
12796         msg_conv.inner = (void*)(msg & (~1));
12797         msg_conv.is_owned = false;
12798         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12799         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12800 }
12801
12802 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) {
12803         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12804         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12805         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12806         LDKPublicKey their_node_id_ref;
12807         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12808         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12809         LDKUpdateFulfillHTLC msg_conv;
12810         msg_conv.inner = (void*)(msg & (~1));
12811         msg_conv.is_owned = false;
12812         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12813         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12814 }
12815
12816 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) {
12817         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12818         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12819         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12820         LDKPublicKey their_node_id_ref;
12821         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12822         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12823         LDKUpdateFailHTLC msg_conv;
12824         msg_conv.inner = (void*)(msg & (~1));
12825         msg_conv.is_owned = false;
12826         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12827         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12828 }
12829
12830 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) {
12831         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12832         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12833         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12834         LDKPublicKey their_node_id_ref;
12835         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12836         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12837         LDKUpdateFailMalformedHTLC msg_conv;
12838         msg_conv.inner = (void*)(msg & (~1));
12839         msg_conv.is_owned = false;
12840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12841         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12842 }
12843
12844 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) {
12845         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12846         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12847         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12848         LDKPublicKey their_node_id_ref;
12849         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12850         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12851         LDKCommitmentSigned msg_conv;
12852         msg_conv.inner = (void*)(msg & (~1));
12853         msg_conv.is_owned = false;
12854         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12855         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12856 }
12857
12858 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) {
12859         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12860         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12861         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12862         LDKPublicKey their_node_id_ref;
12863         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12864         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12865         LDKRevokeAndACK msg_conv;
12866         msg_conv.inner = (void*)(msg & (~1));
12867         msg_conv.is_owned = false;
12868         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12869         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12870 }
12871
12872 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) {
12873         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12874         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12875         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12876         LDKPublicKey their_node_id_ref;
12877         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12878         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12879         LDKUpdateFee msg_conv;
12880         msg_conv.inner = (void*)(msg & (~1));
12881         msg_conv.is_owned = false;
12882         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12883         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12884 }
12885
12886 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) {
12887         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12888         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12889         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12890         LDKPublicKey their_node_id_ref;
12891         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12892         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12893         LDKAnnouncementSignatures msg_conv;
12894         msg_conv.inner = (void*)(msg & (~1));
12895         msg_conv.is_owned = false;
12896         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12897         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12898 }
12899
12900 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) {
12901         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12902         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12903         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12904         LDKPublicKey their_node_id_ref;
12905         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12906         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12907         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
12908 }
12909
12910 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) {
12911         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12912         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12913         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12914         LDKPublicKey their_node_id_ref;
12915         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12916         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12917         LDKInit msg_conv;
12918         msg_conv.inner = (void*)(msg & (~1));
12919         msg_conv.is_owned = false;
12920         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12921         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12922 }
12923
12924 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) {
12925         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12926         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12927         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12928         LDKPublicKey their_node_id_ref;
12929         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12930         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12931         LDKChannelReestablish msg_conv;
12932         msg_conv.inner = (void*)(msg & (~1));
12933         msg_conv.is_owned = false;
12934         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12935         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12936 }
12937
12938 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) {
12939         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12940         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12941         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12942         LDKPublicKey their_node_id_ref;
12943         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12944         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12945         LDKChannelUpdate msg_conv;
12946         msg_conv.inner = (void*)(msg & (~1));
12947         msg_conv.is_owned = false;
12948         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12949         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12950 }
12951
12952 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) {
12953         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12954         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12955         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12956         LDKPublicKey their_node_id_ref;
12957         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12958         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12959         LDKErrorMessage msg_conv;
12960         msg_conv.inner = (void*)(msg & (~1));
12961         msg_conv.is_owned = false;
12962         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12963         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12964 }
12965
12966 typedef struct LDKRoutingMessageHandler_JCalls {
12967         atomic_size_t refcnt;
12968         JavaVM *vm;
12969         jweak o;
12970         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12971         jmethodID handle_node_announcement_meth;
12972         jmethodID handle_channel_announcement_meth;
12973         jmethodID handle_channel_update_meth;
12974         jmethodID get_next_channel_announcements_meth;
12975         jmethodID get_next_node_announcements_meth;
12976         jmethodID peer_connected_meth;
12977         jmethodID handle_reply_channel_range_meth;
12978         jmethodID handle_reply_short_channel_ids_end_meth;
12979         jmethodID handle_query_channel_range_meth;
12980         jmethodID handle_query_short_channel_ids_meth;
12981 } LDKRoutingMessageHandler_JCalls;
12982 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
12983         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12984         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12985                 JNIEnv *env;
12986                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12987                 if (get_jenv_res == JNI_EDETACHED) {
12988                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12989                 } else {
12990                         DO_ASSERT(get_jenv_res == JNI_OK);
12991                 }
12992                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12993                 if (get_jenv_res == JNI_EDETACHED) {
12994                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12995                 }
12996                 FREE(j_calls);
12997         }
12998 }
12999 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
13000         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13001         JNIEnv *env;
13002         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13003         if (get_jenv_res == JNI_EDETACHED) {
13004                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13005         } else {
13006                 DO_ASSERT(get_jenv_res == JNI_OK);
13007         }
13008         LDKNodeAnnouncement msg_var = *msg;
13009         int64_t msg_ref = 0;
13010         msg_var = NodeAnnouncement_clone(&msg_var);
13011         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13012         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13013         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13014         msg_ref = (uintptr_t)msg_var.inner;
13015         if (msg_var.is_owned) {
13016                 msg_ref |= 1;
13017         }
13018         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13019         CHECK(obj != NULL);
13020         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
13021         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13022                 (*env)->ExceptionDescribe(env);
13023                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13024         }
13025         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13026         CHECK_ACCESS(ret_ptr);
13027         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13028         FREE((void*)ret);
13029         if (get_jenv_res == JNI_EDETACHED) {
13030                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13031         }
13032         return ret_conv;
13033 }
13034 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
13035         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13036         JNIEnv *env;
13037         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13038         if (get_jenv_res == JNI_EDETACHED) {
13039                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13040         } else {
13041                 DO_ASSERT(get_jenv_res == JNI_OK);
13042         }
13043         LDKChannelAnnouncement msg_var = *msg;
13044         int64_t msg_ref = 0;
13045         msg_var = ChannelAnnouncement_clone(&msg_var);
13046         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13047         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13048         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13049         msg_ref = (uintptr_t)msg_var.inner;
13050         if (msg_var.is_owned) {
13051                 msg_ref |= 1;
13052         }
13053         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13054         CHECK(obj != NULL);
13055         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
13056         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13057                 (*env)->ExceptionDescribe(env);
13058                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13059         }
13060         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13061         CHECK_ACCESS(ret_ptr);
13062         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13063         FREE((void*)ret);
13064         if (get_jenv_res == JNI_EDETACHED) {
13065                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13066         }
13067         return ret_conv;
13068 }
13069 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
13070         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13071         JNIEnv *env;
13072         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13073         if (get_jenv_res == JNI_EDETACHED) {
13074                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13075         } else {
13076                 DO_ASSERT(get_jenv_res == JNI_OK);
13077         }
13078         LDKChannelUpdate msg_var = *msg;
13079         int64_t msg_ref = 0;
13080         msg_var = ChannelUpdate_clone(&msg_var);
13081         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13082         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13083         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13084         msg_ref = (uintptr_t)msg_var.inner;
13085         if (msg_var.is_owned) {
13086                 msg_ref |= 1;
13087         }
13088         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13089         CHECK(obj != NULL);
13090         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
13091         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13092                 (*env)->ExceptionDescribe(env);
13093                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
13094         }
13095         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13096         CHECK_ACCESS(ret_ptr);
13097         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13098         FREE((void*)ret);
13099         if (get_jenv_res == JNI_EDETACHED) {
13100                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13101         }
13102         return ret_conv;
13103 }
13104 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
13105         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13106         JNIEnv *env;
13107         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13108         if (get_jenv_res == JNI_EDETACHED) {
13109                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13110         } else {
13111                 DO_ASSERT(get_jenv_res == JNI_OK);
13112         }
13113         int64_t starting_point_conv = starting_point;
13114         int8_t batch_amount_conv = batch_amount;
13115         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13116         CHECK(obj != NULL);
13117         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point_conv, batch_amount_conv);
13118         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13119                 (*env)->ExceptionDescribe(env);
13120                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
13121         }
13122         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
13123         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13124         if (ret_constr.datalen > 0)
13125                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
13126         else
13127                 ret_constr.data = NULL;
13128         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13129         for (size_t h = 0; h < ret_constr.datalen; h++) {
13130                 int64_t ret_conv_59 = ret_vals[h];
13131                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
13132                 CHECK_ACCESS(ret_conv_59_ptr);
13133                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
13134                 FREE((void*)ret_conv_59);
13135                 ret_constr.data[h] = ret_conv_59_conv;
13136         }
13137         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13138         if (get_jenv_res == JNI_EDETACHED) {
13139                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13140         }
13141         return ret_constr;
13142 }
13143 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
13144         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13145         JNIEnv *env;
13146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13147         if (get_jenv_res == JNI_EDETACHED) {
13148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13149         } else {
13150                 DO_ASSERT(get_jenv_res == JNI_OK);
13151         }
13152         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
13153         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
13154         int8_t batch_amount_conv = batch_amount;
13155         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13156         CHECK(obj != NULL);
13157         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount_conv);
13158         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13159                 (*env)->ExceptionDescribe(env);
13160                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
13161         }
13162         LDKCVec_NodeAnnouncementZ ret_constr;
13163         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13164         if (ret_constr.datalen > 0)
13165                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
13166         else
13167                 ret_constr.data = NULL;
13168         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13169         for (size_t s = 0; s < ret_constr.datalen; s++) {
13170                 int64_t ret_conv_18 = ret_vals[s];
13171                 LDKNodeAnnouncement ret_conv_18_conv;
13172                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
13173                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
13174                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
13175                 ret_constr.data[s] = ret_conv_18_conv;
13176         }
13177         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13178         if (get_jenv_res == JNI_EDETACHED) {
13179                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13180         }
13181         return ret_constr;
13182 }
13183 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13184         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13185         JNIEnv *env;
13186         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13187         if (get_jenv_res == JNI_EDETACHED) {
13188                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13189         } else {
13190                 DO_ASSERT(get_jenv_res == JNI_OK);
13191         }
13192         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13193         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13194         LDKInit init_var = *init;
13195         int64_t init_ref = 0;
13196         init_var = Init_clone(&init_var);
13197         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13198         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13199         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13200         init_ref = (uintptr_t)init_var.inner;
13201         if (init_var.is_owned) {
13202                 init_ref |= 1;
13203         }
13204         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13205         CHECK(obj != NULL);
13206         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13207         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13208                 (*env)->ExceptionDescribe(env);
13209                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
13210         }
13211         if (get_jenv_res == JNI_EDETACHED) {
13212                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13213         }
13214 }
13215 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
13216         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13217         JNIEnv *env;
13218         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13219         if (get_jenv_res == JNI_EDETACHED) {
13220                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13221         } else {
13222                 DO_ASSERT(get_jenv_res == JNI_OK);
13223         }
13224         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13225         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13226         LDKReplyChannelRange msg_var = msg;
13227         int64_t msg_ref = 0;
13228         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13229         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13230         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13231         msg_ref = (uintptr_t)msg_var.inner;
13232         if (msg_var.is_owned) {
13233                 msg_ref |= 1;
13234         }
13235         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13236         CHECK(obj != NULL);
13237         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
13238         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13239                 (*env)->ExceptionDescribe(env);
13240                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13241         }
13242         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13243         CHECK_ACCESS(ret_ptr);
13244         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13245         FREE((void*)ret);
13246         if (get_jenv_res == JNI_EDETACHED) {
13247                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13248         }
13249         return ret_conv;
13250 }
13251 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
13252         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13253         JNIEnv *env;
13254         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13255         if (get_jenv_res == JNI_EDETACHED) {
13256                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13257         } else {
13258                 DO_ASSERT(get_jenv_res == JNI_OK);
13259         }
13260         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13261         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13262         LDKReplyShortChannelIdsEnd msg_var = msg;
13263         int64_t msg_ref = 0;
13264         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13265         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13266         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13267         msg_ref = (uintptr_t)msg_var.inner;
13268         if (msg_var.is_owned) {
13269                 msg_ref |= 1;
13270         }
13271         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13272         CHECK(obj != NULL);
13273         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
13274         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13275                 (*env)->ExceptionDescribe(env);
13276                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
13277         }
13278         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13279         CHECK_ACCESS(ret_ptr);
13280         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13281         FREE((void*)ret);
13282         if (get_jenv_res == JNI_EDETACHED) {
13283                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13284         }
13285         return ret_conv;
13286 }
13287 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
13288         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13289         JNIEnv *env;
13290         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13291         if (get_jenv_res == JNI_EDETACHED) {
13292                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13293         } else {
13294                 DO_ASSERT(get_jenv_res == JNI_OK);
13295         }
13296         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13297         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13298         LDKQueryChannelRange msg_var = msg;
13299         int64_t msg_ref = 0;
13300         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13301         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13302         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13303         msg_ref = (uintptr_t)msg_var.inner;
13304         if (msg_var.is_owned) {
13305                 msg_ref |= 1;
13306         }
13307         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13308         CHECK(obj != NULL);
13309         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
13310         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13311                 (*env)->ExceptionDescribe(env);
13312                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13313         }
13314         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13315         CHECK_ACCESS(ret_ptr);
13316         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13317         FREE((void*)ret);
13318         if (get_jenv_res == JNI_EDETACHED) {
13319                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13320         }
13321         return ret_conv;
13322 }
13323 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
13324         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13325         JNIEnv *env;
13326         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13327         if (get_jenv_res == JNI_EDETACHED) {
13328                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13329         } else {
13330                 DO_ASSERT(get_jenv_res == JNI_OK);
13331         }
13332         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13333         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13334         LDKQueryShortChannelIds msg_var = msg;
13335         int64_t msg_ref = 0;
13336         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13337         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13338         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13339         msg_ref = (uintptr_t)msg_var.inner;
13340         if (msg_var.is_owned) {
13341                 msg_ref |= 1;
13342         }
13343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13344         CHECK(obj != NULL);
13345         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13346         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13347                 (*env)->ExceptionDescribe(env);
13348                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13349         }
13350         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13351         CHECK_ACCESS(ret_ptr);
13352         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13353         FREE((void*)ret);
13354         if (get_jenv_res == JNI_EDETACHED) {
13355                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13356         }
13357         return ret_conv;
13358 }
13359 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13360         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13361         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13362         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13363 }
13364 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13365         jclass c = (*env)->GetObjectClass(env, o);
13366         CHECK(c != NULL);
13367         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13368         atomic_init(&calls->refcnt, 1);
13369         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13370         calls->o = (*env)->NewWeakGlobalRef(env, o);
13371         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13372         CHECK(calls->handle_node_announcement_meth != NULL);
13373         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13374         CHECK(calls->handle_channel_announcement_meth != NULL);
13375         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13376         CHECK(calls->handle_channel_update_meth != NULL);
13377         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
13378         CHECK(calls->get_next_channel_announcements_meth != NULL);
13379         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
13380         CHECK(calls->get_next_node_announcements_meth != NULL);
13381         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
13382         CHECK(calls->peer_connected_meth != NULL);
13383         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13384         CHECK(calls->handle_reply_channel_range_meth != NULL);
13385         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13386         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13387         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13388         CHECK(calls->handle_query_channel_range_meth != NULL);
13389         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13390         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13391
13392         LDKRoutingMessageHandler ret = {
13393                 .this_arg = (void*) calls,
13394                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13395                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13396                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13397                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
13398                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
13399                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13400                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13401                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13402                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13403                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13404                 .free = LDKRoutingMessageHandler_JCalls_free,
13405                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13406         };
13407         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13408         return ret;
13409 }
13410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13411         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13412         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13413         return (uint64_t)res_ptr;
13414 }
13415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13416         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
13417         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
13418         DO_ASSERT((res_ptr & 1) == 0);
13419         return (int64_t)(res_ptr | 1);
13420 }
13421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13422         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13423         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13424         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13425         LDKNodeAnnouncement msg_conv;
13426         msg_conv.inner = (void*)(msg & (~1));
13427         msg_conv.is_owned = false;
13428         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13429         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13430         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13431         return (int64_t)ret_conv;
13432 }
13433
13434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13435         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13436         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13437         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13438         LDKChannelAnnouncement msg_conv;
13439         msg_conv.inner = (void*)(msg & (~1));
13440         msg_conv.is_owned = false;
13441         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13442         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13443         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13444         return (int64_t)ret_conv;
13445 }
13446
13447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13448         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13449         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13450         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13451         LDKChannelUpdate msg_conv;
13452         msg_conv.inner = (void*)(msg & (~1));
13453         msg_conv.is_owned = false;
13454         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13455         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13456         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13457         return (int64_t)ret_conv;
13458 }
13459
13460 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) {
13461         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13462         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13463         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13464         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
13465         int64_tArray ret_arr = NULL;
13466         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13467         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13468         for (size_t h = 0; h < ret_var.datalen; h++) {
13469                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13470                 *ret_conv_59_conv = ret_var.data[h];
13471                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
13472         }
13473         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13474         FREE(ret_var.data);
13475         return ret_arr;
13476 }
13477
13478 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) {
13479         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13480         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13481         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13482         LDKPublicKey starting_point_ref;
13483         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13484         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13485         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
13486         int64_tArray ret_arr = NULL;
13487         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13488         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13489         for (size_t s = 0; s < ret_var.datalen; s++) {
13490                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
13491                 int64_t ret_conv_18_ref = 0;
13492                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13493                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13494                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
13495                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
13496                 if (ret_conv_18_var.is_owned) {
13497                         ret_conv_18_ref |= 1;
13498                 }
13499                 ret_arr_ptr[s] = ret_conv_18_ref;
13500         }
13501         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13502         FREE(ret_var.data);
13503         return ret_arr;
13504 }
13505
13506 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) {
13507         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13508         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13509         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13510         LDKPublicKey their_node_id_ref;
13511         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13512         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13513         LDKInit init_conv;
13514         init_conv.inner = (void*)(init & (~1));
13515         init_conv.is_owned = false;
13516         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13517         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13518 }
13519
13520 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) {
13521         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13522         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13523         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13524         LDKPublicKey their_node_id_ref;
13525         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13526         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13527         LDKReplyChannelRange msg_conv;
13528         msg_conv.inner = (void*)(msg & (~1));
13529         msg_conv.is_owned = (msg & 1) || (msg == 0);
13530         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13531         msg_conv = ReplyChannelRange_clone(&msg_conv);
13532         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13533         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13534         return (int64_t)ret_conv;
13535 }
13536
13537 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) {
13538         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13539         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13540         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13541         LDKPublicKey their_node_id_ref;
13542         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13543         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13544         LDKReplyShortChannelIdsEnd msg_conv;
13545         msg_conv.inner = (void*)(msg & (~1));
13546         msg_conv.is_owned = (msg & 1) || (msg == 0);
13547         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13548         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13549         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13550         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13551         return (int64_t)ret_conv;
13552 }
13553
13554 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) {
13555         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13556         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13557         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13558         LDKPublicKey their_node_id_ref;
13559         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13560         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13561         LDKQueryChannelRange msg_conv;
13562         msg_conv.inner = (void*)(msg & (~1));
13563         msg_conv.is_owned = (msg & 1) || (msg == 0);
13564         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13565         msg_conv = QueryChannelRange_clone(&msg_conv);
13566         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13567         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13568         return (int64_t)ret_conv;
13569 }
13570
13571 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) {
13572         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13573         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13574         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13575         LDKPublicKey their_node_id_ref;
13576         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13577         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13578         LDKQueryShortChannelIds msg_conv;
13579         msg_conv.inner = (void*)(msg & (~1));
13580         msg_conv.is_owned = (msg & 1) || (msg == 0);
13581         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13582         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13583         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13584         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13585         return (int64_t)ret_conv;
13586 }
13587
13588 typedef struct LDKCustomMessageReader_JCalls {
13589         atomic_size_t refcnt;
13590         JavaVM *vm;
13591         jweak o;
13592         jmethodID read_meth;
13593 } LDKCustomMessageReader_JCalls;
13594 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
13595         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13596         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13597                 JNIEnv *env;
13598                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13599                 if (get_jenv_res == JNI_EDETACHED) {
13600                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13601                 } else {
13602                         DO_ASSERT(get_jenv_res == JNI_OK);
13603                 }
13604                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13605                 if (get_jenv_res == JNI_EDETACHED) {
13606                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13607                 }
13608                 FREE(j_calls);
13609         }
13610 }
13611 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
13612         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13613         JNIEnv *env;
13614         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13615         if (get_jenv_res == JNI_EDETACHED) {
13616                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13617         } else {
13618                 DO_ASSERT(get_jenv_res == JNI_OK);
13619         }
13620         int16_t message_type_conv = message_type;
13621         LDKu8slice buffer_var = buffer;
13622         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
13623         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
13624         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13625         CHECK(obj != NULL);
13626         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
13627         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13628                 (*env)->ExceptionDescribe(env);
13629                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
13630         }
13631         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13632         CHECK_ACCESS(ret_ptr);
13633         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
13634         FREE((void*)ret);
13635         if (get_jenv_res == JNI_EDETACHED) {
13636                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13637         }
13638         return ret_conv;
13639 }
13640 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
13641         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
13642         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13643 }
13644 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
13645         jclass c = (*env)->GetObjectClass(env, o);
13646         CHECK(c != NULL);
13647         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
13648         atomic_init(&calls->refcnt, 1);
13649         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13650         calls->o = (*env)->NewWeakGlobalRef(env, o);
13651         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
13652         CHECK(calls->read_meth != NULL);
13653
13654         LDKCustomMessageReader ret = {
13655                 .this_arg = (void*) calls,
13656                 .read = read_LDKCustomMessageReader_jcall,
13657                 .free = LDKCustomMessageReader_JCalls_free,
13658         };
13659         return ret;
13660 }
13661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
13662         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
13663         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
13664         return (uint64_t)res_ptr;
13665 }
13666 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) {
13667         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13668         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13669         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
13670         LDKu8slice buffer_ref;
13671         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
13672         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
13673         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
13674         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
13675         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
13676         return (int64_t)ret_conv;
13677 }
13678
13679 typedef struct LDKCustomMessageHandler_JCalls {
13680         atomic_size_t refcnt;
13681         JavaVM *vm;
13682         jweak o;
13683         LDKCustomMessageReader_JCalls* CustomMessageReader;
13684         jmethodID handle_custom_message_meth;
13685         jmethodID get_and_clear_pending_msg_meth;
13686 } LDKCustomMessageHandler_JCalls;
13687 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
13688         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13689         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13690                 JNIEnv *env;
13691                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13692                 if (get_jenv_res == JNI_EDETACHED) {
13693                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13694                 } else {
13695                         DO_ASSERT(get_jenv_res == JNI_OK);
13696                 }
13697                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13698                 if (get_jenv_res == JNI_EDETACHED) {
13699                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13700                 }
13701                 FREE(j_calls);
13702         }
13703 }
13704 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
13705         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13706         JNIEnv *env;
13707         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13708         if (get_jenv_res == JNI_EDETACHED) {
13709                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13710         } else {
13711                 DO_ASSERT(get_jenv_res == JNI_OK);
13712         }
13713         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
13714         *msg_ret = msg;
13715         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
13716         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
13717         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13718         CHECK(obj != NULL);
13719         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
13720         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13721                 (*env)->ExceptionDescribe(env);
13722                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
13723         }
13724         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13725         CHECK_ACCESS(ret_ptr);
13726         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13727         FREE((void*)ret);
13728         if (get_jenv_res == JNI_EDETACHED) {
13729                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13730         }
13731         return ret_conv;
13732 }
13733 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
13734         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13735         JNIEnv *env;
13736         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13737         if (get_jenv_res == JNI_EDETACHED) {
13738                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13739         } else {
13740                 DO_ASSERT(get_jenv_res == JNI_OK);
13741         }
13742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13743         CHECK(obj != NULL);
13744         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
13745         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13746                 (*env)->ExceptionDescribe(env);
13747                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
13748         }
13749         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
13750         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13751         if (ret_constr.datalen > 0)
13752                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13753         else
13754                 ret_constr.data = NULL;
13755         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13756         for (size_t z = 0; z < ret_constr.datalen; z++) {
13757                 int64_t ret_conv_25 = ret_vals[z];
13758                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
13759                 CHECK_ACCESS(ret_conv_25_ptr);
13760                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
13761                 FREE((void*)ret_conv_25);
13762                 ret_constr.data[z] = ret_conv_25_conv;
13763         }
13764         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13765         if (get_jenv_res == JNI_EDETACHED) {
13766                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13767         }
13768         return ret_constr;
13769 }
13770 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
13771         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
13772         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13773         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
13774 }
13775 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13776         jclass c = (*env)->GetObjectClass(env, o);
13777         CHECK(c != NULL);
13778         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
13779         atomic_init(&calls->refcnt, 1);
13780         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13781         calls->o = (*env)->NewWeakGlobalRef(env, o);
13782         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
13783         CHECK(calls->handle_custom_message_meth != NULL);
13784         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
13785         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
13786
13787         LDKCustomMessageHandler ret = {
13788                 .this_arg = (void*) calls,
13789                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
13790                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
13791                 .free = LDKCustomMessageHandler_JCalls_free,
13792                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
13793         };
13794         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
13795         return ret;
13796 }
13797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13798         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
13799         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
13800         return (uint64_t)res_ptr;
13801 }
13802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
13803         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
13804         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
13805         DO_ASSERT((res_ptr & 1) == 0);
13806         return (int64_t)(res_ptr | 1);
13807 }
13808 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) {
13809         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13810         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13811         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13812         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
13813         CHECK_ACCESS(msg_ptr);
13814         LDKType msg_conv = *(LDKType*)(msg_ptr);
13815         if (msg_conv.free == LDKType_JCalls_free) {
13816                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13817                 LDKType_JCalls_cloned(&msg_conv);
13818         }
13819         LDKPublicKey sender_node_id_ref;
13820         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
13821         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
13822         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13823         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
13824         return (int64_t)ret_conv;
13825 }
13826
13827 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
13828         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13829         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13830         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13831         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
13832         int64_tArray ret_arr = NULL;
13833         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13834         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13835         for (size_t z = 0; z < ret_var.datalen; z++) {
13836                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13837                 *ret_conv_25_conv = ret_var.data[z];
13838                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
13839         }
13840         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13841         FREE(ret_var.data);
13842         return ret_arr;
13843 }
13844
13845 typedef struct LDKSocketDescriptor_JCalls {
13846         atomic_size_t refcnt;
13847         JavaVM *vm;
13848         jweak o;
13849         jmethodID send_data_meth;
13850         jmethodID disconnect_socket_meth;
13851         jmethodID eq_meth;
13852         jmethodID hash_meth;
13853 } LDKSocketDescriptor_JCalls;
13854 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
13855         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13856         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13857                 JNIEnv *env;
13858                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13859                 if (get_jenv_res == JNI_EDETACHED) {
13860                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13861                 } else {
13862                         DO_ASSERT(get_jenv_res == JNI_OK);
13863                 }
13864                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13865                 if (get_jenv_res == JNI_EDETACHED) {
13866                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13867                 }
13868                 FREE(j_calls);
13869         }
13870 }
13871 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
13872         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13873         JNIEnv *env;
13874         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13875         if (get_jenv_res == JNI_EDETACHED) {
13876                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13877         } else {
13878                 DO_ASSERT(get_jenv_res == JNI_OK);
13879         }
13880         LDKu8slice data_var = data;
13881         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
13882         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
13883         jboolean resume_read_conv = resume_read;
13884         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13885         CHECK(obj != NULL);
13886         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
13887         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13888                 (*env)->ExceptionDescribe(env);
13889                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
13890         }
13891         if (get_jenv_res == JNI_EDETACHED) {
13892                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13893         }
13894         return ret;
13895 }
13896 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
13897         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13898         JNIEnv *env;
13899         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13900         if (get_jenv_res == JNI_EDETACHED) {
13901                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13902         } else {
13903                 DO_ASSERT(get_jenv_res == JNI_OK);
13904         }
13905         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13906         CHECK(obj != NULL);
13907         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
13908         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13909                 (*env)->ExceptionDescribe(env);
13910                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
13911         }
13912         if (get_jenv_res == JNI_EDETACHED) {
13913                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13914         }
13915 }
13916 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
13917         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13918         JNIEnv *env;
13919         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13920         if (get_jenv_res == JNI_EDETACHED) {
13921                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13922         } else {
13923                 DO_ASSERT(get_jenv_res == JNI_OK);
13924         }
13925         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13926         *other_arg_clone = SocketDescriptor_clone(other_arg);
13927         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13928         CHECK(obj != NULL);
13929         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
13930         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13931                 (*env)->ExceptionDescribe(env);
13932                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
13933         }
13934         if (get_jenv_res == JNI_EDETACHED) {
13935                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13936         }
13937         return ret;
13938 }
13939 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
13940         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13941         JNIEnv *env;
13942         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13943         if (get_jenv_res == JNI_EDETACHED) {
13944                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13945         } else {
13946                 DO_ASSERT(get_jenv_res == JNI_OK);
13947         }
13948         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13949         CHECK(obj != NULL);
13950         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
13951         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13952                 (*env)->ExceptionDescribe(env);
13953                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
13954         }
13955         if (get_jenv_res == JNI_EDETACHED) {
13956                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13957         }
13958         return ret;
13959 }
13960 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
13961         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
13962         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13963 }
13964 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
13965         jclass c = (*env)->GetObjectClass(env, o);
13966         CHECK(c != NULL);
13967         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
13968         atomic_init(&calls->refcnt, 1);
13969         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13970         calls->o = (*env)->NewWeakGlobalRef(env, o);
13971         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
13972         CHECK(calls->send_data_meth != NULL);
13973         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
13974         CHECK(calls->disconnect_socket_meth != NULL);
13975         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
13976         CHECK(calls->eq_meth != NULL);
13977         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
13978         CHECK(calls->hash_meth != NULL);
13979
13980         LDKSocketDescriptor ret = {
13981                 .this_arg = (void*) calls,
13982                 .send_data = send_data_LDKSocketDescriptor_jcall,
13983                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
13984                 .eq = eq_LDKSocketDescriptor_jcall,
13985                 .hash = hash_LDKSocketDescriptor_jcall,
13986                 .cloned = LDKSocketDescriptor_JCalls_cloned,
13987                 .free = LDKSocketDescriptor_JCalls_free,
13988         };
13989         return ret;
13990 }
13991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
13992         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13993         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
13994         return (uint64_t)res_ptr;
13995 }
13996 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) {
13997         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13998         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13999         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14000         LDKu8slice data_ref;
14001         data_ref.datalen = (*env)->GetArrayLength(env, data);
14002         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
14003         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14004         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
14005         return ret_conv;
14006 }
14007
14008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
14009         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14010         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14011         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14012         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14013 }
14014
14015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14016         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14017         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14018         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14019         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14020         return ret_conv;
14021 }
14022
14023 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
14024 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
14025 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
14026 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
14027 static jclass LDKEffectiveCapacity_Total_class = NULL;
14028 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
14029 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
14030 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
14031 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
14032 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
14033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
14034         LDKEffectiveCapacity_ExactLiquidity_class =
14035                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
14036         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
14037         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
14038         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
14039         LDKEffectiveCapacity_MaximumHTLC_class =
14040                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
14041         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
14042         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
14043         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
14044         LDKEffectiveCapacity_Total_class =
14045                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
14046         CHECK(LDKEffectiveCapacity_Total_class != NULL);
14047         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
14048         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
14049         LDKEffectiveCapacity_Infinite_class =
14050                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
14051         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
14052         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
14053         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
14054         LDKEffectiveCapacity_Unknown_class =
14055                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
14056         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
14057         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
14058         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
14059 }
14060 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14061         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
14062         switch(obj->tag) {
14063                 case LDKEffectiveCapacity_ExactLiquidity: {
14064                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14065                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
14066                 }
14067                 case LDKEffectiveCapacity_MaximumHTLC: {
14068                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
14069                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
14070                 }
14071                 case LDKEffectiveCapacity_Total: {
14072                         int64_t capacity_msat_conv = obj->total.capacity_msat;
14073                         int64_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
14074                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_ref);
14075                 }
14076                 case LDKEffectiveCapacity_Infinite: {
14077                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
14078                 }
14079                 case LDKEffectiveCapacity_Unknown: {
14080                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
14081                 }
14082                 default: abort();
14083         }
14084 }
14085 typedef struct LDKLockableScore_JCalls {
14086         atomic_size_t refcnt;
14087         JavaVM *vm;
14088         jweak o;
14089         jmethodID lock_meth;
14090 } LDKLockableScore_JCalls;
14091 static void LDKLockableScore_JCalls_free(void* this_arg) {
14092         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
14093         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14094                 JNIEnv *env;
14095                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14096                 if (get_jenv_res == JNI_EDETACHED) {
14097                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14098                 } else {
14099                         DO_ASSERT(get_jenv_res == JNI_OK);
14100                 }
14101                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14102                 if (get_jenv_res == JNI_EDETACHED) {
14103                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14104                 }
14105                 FREE(j_calls);
14106         }
14107 }
14108 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
14109         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
14110         JNIEnv *env;
14111         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14112         if (get_jenv_res == JNI_EDETACHED) {
14113                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14114         } else {
14115                 DO_ASSERT(get_jenv_res == JNI_OK);
14116         }
14117         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14118         CHECK(obj != NULL);
14119         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
14120         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14121                 (*env)->ExceptionDescribe(env);
14122                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
14123         }
14124         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14125         CHECK_ACCESS(ret_ptr);
14126         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
14127         if (ret_conv.free == LDKScore_JCalls_free) {
14128                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14129                 LDKScore_JCalls_cloned(&ret_conv);
14130         }// WARNING: we may need a move here but no clone is available for LDKScore
14131         
14132         if (get_jenv_res == JNI_EDETACHED) {
14133                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14134         }
14135         return ret_conv;
14136 }
14137 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
14138         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
14139         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14140 }
14141 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
14142         jclass c = (*env)->GetObjectClass(env, o);
14143         CHECK(c != NULL);
14144         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
14145         atomic_init(&calls->refcnt, 1);
14146         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14147         calls->o = (*env)->NewWeakGlobalRef(env, o);
14148         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
14149         CHECK(calls->lock_meth != NULL);
14150
14151         LDKLockableScore ret = {
14152                 .this_arg = (void*) calls,
14153                 .lock = lock_LDKLockableScore_jcall,
14154                 .free = LDKLockableScore_JCalls_free,
14155         };
14156         return ret;
14157 }
14158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
14159         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
14160         *res_ptr = LDKLockableScore_init(env, clz, o);
14161         return (uint64_t)res_ptr;
14162 }
14163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
14164         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14165         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14166         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
14167         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
14168         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
14169         return (int64_t)ret_ret;
14170 }
14171
14172 static jclass LDKGossipSync_P2P_class = NULL;
14173 static jmethodID LDKGossipSync_P2P_meth = NULL;
14174 static jclass LDKGossipSync_Rapid_class = NULL;
14175 static jmethodID LDKGossipSync_Rapid_meth = NULL;
14176 static jclass LDKGossipSync_None_class = NULL;
14177 static jmethodID LDKGossipSync_None_meth = NULL;
14178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
14179         LDKGossipSync_P2P_class =
14180                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
14181         CHECK(LDKGossipSync_P2P_class != NULL);
14182         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
14183         CHECK(LDKGossipSync_P2P_meth != NULL);
14184         LDKGossipSync_Rapid_class =
14185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
14186         CHECK(LDKGossipSync_Rapid_class != NULL);
14187         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
14188         CHECK(LDKGossipSync_Rapid_meth != NULL);
14189         LDKGossipSync_None_class =
14190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
14191         CHECK(LDKGossipSync_None_class != NULL);
14192         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
14193         CHECK(LDKGossipSync_None_meth != NULL);
14194 }
14195 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14196         LDKGossipSync *obj = (LDKGossipSync*)(ptr & ~1);
14197         switch(obj->tag) {
14198                 case LDKGossipSync_P2P: {
14199                         LDKP2PGossipSync p2p_var = obj->p2p;
14200                         int64_t p2p_ref = 0;
14201                         CHECK((((uintptr_t)p2p_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14202                         CHECK((((uintptr_t)&p2p_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14203                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
14204                         p2p_ref = (uintptr_t)p2p_var.inner & ~1;
14205                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
14206                 }
14207                 case LDKGossipSync_Rapid: {
14208                         LDKRapidGossipSync rapid_var = obj->rapid;
14209                         int64_t rapid_ref = 0;
14210                         CHECK((((uintptr_t)rapid_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14211                         CHECK((((uintptr_t)&rapid_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14212                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
14213                         rapid_ref = (uintptr_t)rapid_var.inner & ~1;
14214                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
14215                 }
14216                 case LDKGossipSync_None: {
14217                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
14218                 }
14219                 default: abort();
14220         }
14221 }
14222 static jclass LDKFallback_SegWitProgram_class = NULL;
14223 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
14224 static jclass LDKFallback_PubKeyHash_class = NULL;
14225 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
14226 static jclass LDKFallback_ScriptHash_class = NULL;
14227 static jmethodID LDKFallback_ScriptHash_meth = NULL;
14228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
14229         LDKFallback_SegWitProgram_class =
14230                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
14231         CHECK(LDKFallback_SegWitProgram_class != NULL);
14232         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
14233         CHECK(LDKFallback_SegWitProgram_meth != NULL);
14234         LDKFallback_PubKeyHash_class =
14235                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
14236         CHECK(LDKFallback_PubKeyHash_class != NULL);
14237         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
14238         CHECK(LDKFallback_PubKeyHash_meth != NULL);
14239         LDKFallback_ScriptHash_class =
14240                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
14241         CHECK(LDKFallback_ScriptHash_class != NULL);
14242         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
14243         CHECK(LDKFallback_ScriptHash_meth != NULL);
14244 }
14245 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14246         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
14247         switch(obj->tag) {
14248                 case LDKFallback_SegWitProgram: {
14249                         uint8_t version_val = obj->seg_wit_program.version._0;
14250                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
14251                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
14252                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
14253                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
14254                 }
14255                 case LDKFallback_PubKeyHash: {
14256                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
14257                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
14258                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
14259                 }
14260                 case LDKFallback_ScriptHash: {
14261                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
14262                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
14263                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
14264                 }
14265                 default: abort();
14266         }
14267 }
14268 typedef struct LDKPayer_JCalls {
14269         atomic_size_t refcnt;
14270         JavaVM *vm;
14271         jweak o;
14272         jmethodID node_id_meth;
14273         jmethodID first_hops_meth;
14274         jmethodID send_payment_meth;
14275         jmethodID send_spontaneous_payment_meth;
14276         jmethodID retry_payment_meth;
14277         jmethodID abandon_payment_meth;
14278 } LDKPayer_JCalls;
14279 static void LDKPayer_JCalls_free(void* this_arg) {
14280         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14281         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14282                 JNIEnv *env;
14283                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14284                 if (get_jenv_res == JNI_EDETACHED) {
14285                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14286                 } else {
14287                         DO_ASSERT(get_jenv_res == JNI_OK);
14288                 }
14289                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14290                 if (get_jenv_res == JNI_EDETACHED) {
14291                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14292                 }
14293                 FREE(j_calls);
14294         }
14295 }
14296 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
14297         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14298         JNIEnv *env;
14299         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14300         if (get_jenv_res == JNI_EDETACHED) {
14301                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14302         } else {
14303                 DO_ASSERT(get_jenv_res == JNI_OK);
14304         }
14305         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14306         CHECK(obj != NULL);
14307         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
14308         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14309                 (*env)->ExceptionDescribe(env);
14310                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
14311         }
14312         LDKPublicKey ret_ref;
14313         CHECK((*env)->GetArrayLength(env, ret) == 33);
14314         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
14315         if (get_jenv_res == JNI_EDETACHED) {
14316                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14317         }
14318         return ret_ref;
14319 }
14320 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
14321         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14322         JNIEnv *env;
14323         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14324         if (get_jenv_res == JNI_EDETACHED) {
14325                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14326         } else {
14327                 DO_ASSERT(get_jenv_res == JNI_OK);
14328         }
14329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14330         CHECK(obj != NULL);
14331         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
14332         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14333                 (*env)->ExceptionDescribe(env);
14334                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
14335         }
14336         LDKCVec_ChannelDetailsZ ret_constr;
14337         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14338         if (ret_constr.datalen > 0)
14339                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14340         else
14341                 ret_constr.data = NULL;
14342         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14343         for (size_t q = 0; q < ret_constr.datalen; q++) {
14344                 int64_t ret_conv_16 = ret_vals[q];
14345                 LDKChannelDetails ret_conv_16_conv;
14346                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
14347                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
14348                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
14349                 ret_constr.data[q] = ret_conv_16_conv;
14350         }
14351         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14352         if (get_jenv_res == JNI_EDETACHED) {
14353                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14354         }
14355         return ret_constr;
14356 }
14357 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
14358         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14359         JNIEnv *env;
14360         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14361         if (get_jenv_res == JNI_EDETACHED) {
14362                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14363         } else {
14364                 DO_ASSERT(get_jenv_res == JNI_OK);
14365         }
14366         LDKRoute route_var = *route;
14367         int64_t route_ref = 0;
14368         route_var = Route_clone(&route_var);
14369         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14370         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14371         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14372         route_ref = (uintptr_t)route_var.inner;
14373         if (route_var.is_owned) {
14374                 route_ref |= 1;
14375         }
14376         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14377         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
14378         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
14379         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
14380         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14381         CHECK(obj != NULL);
14382         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
14383         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14384                 (*env)->ExceptionDescribe(env);
14385                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
14386         }
14387         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14388         CHECK_ACCESS(ret_ptr);
14389         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14390         FREE((void*)ret);
14391         if (get_jenv_res == JNI_EDETACHED) {
14392                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14393         }
14394         return ret_conv;
14395 }
14396 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
14397         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14398         JNIEnv *env;
14399         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14400         if (get_jenv_res == JNI_EDETACHED) {
14401                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14402         } else {
14403                 DO_ASSERT(get_jenv_res == JNI_OK);
14404         }
14405         LDKRoute route_var = *route;
14406         int64_t route_ref = 0;
14407         route_var = Route_clone(&route_var);
14408         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14409         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14410         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14411         route_ref = (uintptr_t)route_var.inner;
14412         if (route_var.is_owned) {
14413                 route_ref |= 1;
14414         }
14415         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
14416         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
14417         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14418         CHECK(obj != NULL);
14419         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
14420         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14421                 (*env)->ExceptionDescribe(env);
14422                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
14423         }
14424         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14425         CHECK_ACCESS(ret_ptr);
14426         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14427         FREE((void*)ret);
14428         if (get_jenv_res == JNI_EDETACHED) {
14429                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14430         }
14431         return ret_conv;
14432 }
14433 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
14434         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14435         JNIEnv *env;
14436         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14437         if (get_jenv_res == JNI_EDETACHED) {
14438                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14439         } else {
14440                 DO_ASSERT(get_jenv_res == JNI_OK);
14441         }
14442         LDKRoute route_var = *route;
14443         int64_t route_ref = 0;
14444         route_var = Route_clone(&route_var);
14445         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14446         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14447         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14448         route_ref = (uintptr_t)route_var.inner;
14449         if (route_var.is_owned) {
14450                 route_ref |= 1;
14451         }
14452         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14453         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14454         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14455         CHECK(obj != NULL);
14456         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
14457         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14458                 (*env)->ExceptionDescribe(env);
14459                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
14460         }
14461         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14462         CHECK_ACCESS(ret_ptr);
14463         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
14464         FREE((void*)ret);
14465         if (get_jenv_res == JNI_EDETACHED) {
14466                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14467         }
14468         return ret_conv;
14469 }
14470 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
14471         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14472         JNIEnv *env;
14473         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14474         if (get_jenv_res == JNI_EDETACHED) {
14475                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14476         } else {
14477                 DO_ASSERT(get_jenv_res == JNI_OK);
14478         }
14479         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14480         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14481         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14482         CHECK(obj != NULL);
14483         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
14484         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14485                 (*env)->ExceptionDescribe(env);
14486                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
14487         }
14488         if (get_jenv_res == JNI_EDETACHED) {
14489                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14490         }
14491 }
14492 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
14493         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
14494         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14495 }
14496 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
14497         jclass c = (*env)->GetObjectClass(env, o);
14498         CHECK(c != NULL);
14499         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
14500         atomic_init(&calls->refcnt, 1);
14501         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14502         calls->o = (*env)->NewWeakGlobalRef(env, o);
14503         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
14504         CHECK(calls->node_id_meth != NULL);
14505         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
14506         CHECK(calls->first_hops_meth != NULL);
14507         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
14508         CHECK(calls->send_payment_meth != NULL);
14509         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
14510         CHECK(calls->send_spontaneous_payment_meth != NULL);
14511         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
14512         CHECK(calls->retry_payment_meth != NULL);
14513         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
14514         CHECK(calls->abandon_payment_meth != NULL);
14515
14516         LDKPayer ret = {
14517                 .this_arg = (void*) calls,
14518                 .node_id = node_id_LDKPayer_jcall,
14519                 .first_hops = first_hops_LDKPayer_jcall,
14520                 .send_payment = send_payment_LDKPayer_jcall,
14521                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
14522                 .retry_payment = retry_payment_LDKPayer_jcall,
14523                 .abandon_payment = abandon_payment_LDKPayer_jcall,
14524                 .free = LDKPayer_JCalls_free,
14525         };
14526         return ret;
14527 }
14528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
14529         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
14530         *res_ptr = LDKPayer_init(env, clz, o);
14531         return (uint64_t)res_ptr;
14532 }
14533 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14534         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14535         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14536         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14537         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
14539         return ret_arr;
14540 }
14541
14542 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
14543         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14544         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14545         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14546         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
14547         int64_tArray ret_arr = NULL;
14548         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14549         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14550         for (size_t q = 0; q < ret_var.datalen; q++) {
14551                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14552                 int64_t ret_conv_16_ref = 0;
14553                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14554                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14555                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
14556                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
14557                 if (ret_conv_16_var.is_owned) {
14558                         ret_conv_16_ref |= 1;
14559                 }
14560                 ret_arr_ptr[q] = ret_conv_16_ref;
14561         }
14562         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14563         FREE(ret_var.data);
14564         return ret_arr;
14565 }
14566
14567 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) {
14568         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14569         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14570         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14571         LDKRoute route_conv;
14572         route_conv.inner = (void*)(route & (~1));
14573         route_conv.is_owned = false;
14574         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14575         LDKThirtyTwoBytes payment_hash_ref;
14576         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14577         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14578         LDKThirtyTwoBytes payment_secret_ref;
14579         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14580         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14581         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14582         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
14583         return (int64_t)ret_conv;
14584 }
14585
14586 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) {
14587         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14588         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14589         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14590         LDKRoute route_conv;
14591         route_conv.inner = (void*)(route & (~1));
14592         route_conv.is_owned = false;
14593         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14594         LDKThirtyTwoBytes payment_preimage_ref;
14595         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14596         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14597         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14598         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
14599         return (int64_t)ret_conv;
14600 }
14601
14602 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) {
14603         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14604         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14605         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14606         LDKRoute route_conv;
14607         route_conv.inner = (void*)(route & (~1));
14608         route_conv.is_owned = false;
14609         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14610         LDKThirtyTwoBytes payment_id_ref;
14611         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14612         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14613         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14614         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
14615         return (int64_t)ret_conv;
14616 }
14617
14618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
14619         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14620         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14621         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14622         LDKThirtyTwoBytes payment_id_ref;
14623         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14624         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14625         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
14626 }
14627
14628 typedef struct LDKRouter_JCalls {
14629         atomic_size_t refcnt;
14630         JavaVM *vm;
14631         jweak o;
14632         jmethodID find_route_meth;
14633 } LDKRouter_JCalls;
14634 static void LDKRouter_JCalls_free(void* this_arg) {
14635         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14636         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14637                 JNIEnv *env;
14638                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14639                 if (get_jenv_res == JNI_EDETACHED) {
14640                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14641                 } else {
14642                         DO_ASSERT(get_jenv_res == JNI_OK);
14643                 }
14644                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14645                 if (get_jenv_res == JNI_EDETACHED) {
14646                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14647                 }
14648                 FREE(j_calls);
14649         }
14650 }
14651 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) {
14652         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14653         JNIEnv *env;
14654         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14655         if (get_jenv_res == JNI_EDETACHED) {
14656                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14657         } else {
14658                 DO_ASSERT(get_jenv_res == JNI_OK);
14659         }
14660         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14661         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14662         LDKRouteParameters route_params_var = *route_params;
14663         int64_t route_params_ref = 0;
14664         route_params_var = RouteParameters_clone(&route_params_var);
14665         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14666         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14667         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14668         route_params_ref = (uintptr_t)route_params_var.inner;
14669         if (route_params_var.is_owned) {
14670                 route_params_ref |= 1;
14671         }
14672         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14673         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
14674         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14675         int64_tArray first_hops_arr = NULL;
14676         if (first_hops != NULL) {
14677                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14678                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14679                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14680                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14681                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14682                         int64_t first_hops_conv_16_ref = 0;
14683                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14684                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14685                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14686                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
14687                         if (first_hops_conv_16_var.is_owned) {
14688                                 first_hops_conv_16_ref |= 1;
14689                         }
14690                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14691                 }
14692                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14693         }
14694         // WARNING: This object doesn't live past this scope, needs clone!
14695         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
14696         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14697         CHECK(obj != NULL);
14698         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);
14699         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14700                 (*env)->ExceptionDescribe(env);
14701                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14702         }
14703         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14704         CHECK_ACCESS(ret_ptr);
14705         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14706         FREE((void*)ret);
14707         if (get_jenv_res == JNI_EDETACHED) {
14708                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14709         }
14710         return ret_conv;
14711 }
14712 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14713         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14714         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14715 }
14716 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14717         jclass c = (*env)->GetObjectClass(env, o);
14718         CHECK(c != NULL);
14719         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14720         atomic_init(&calls->refcnt, 1);
14721         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14722         calls->o = (*env)->NewWeakGlobalRef(env, o);
14723         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
14724         CHECK(calls->find_route_meth != NULL);
14725
14726         LDKRouter ret = {
14727                 .this_arg = (void*) calls,
14728                 .find_route = find_route_LDKRouter_jcall,
14729                 .free = LDKRouter_JCalls_free,
14730         };
14731         return ret;
14732 }
14733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
14734         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
14735         *res_ptr = LDKRouter_init(env, clz, o);
14736         return (uint64_t)res_ptr;
14737 }
14738 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) {
14739         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14740         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14741         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14742         LDKPublicKey payer_ref;
14743         CHECK((*env)->GetArrayLength(env, payer) == 33);
14744         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
14745         LDKRouteParameters route_params_conv;
14746         route_params_conv.inner = (void*)(route_params & (~1));
14747         route_params_conv.is_owned = false;
14748         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
14749         unsigned char payment_hash_arr[32];
14750         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14751         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
14752         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14753         LDKCVec_ChannelDetailsZ first_hops_constr;
14754         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
14755         if (first_hops != NULL) {
14756                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
14757                 if (first_hops_constr.datalen > 0)
14758                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14759                 else
14760                         first_hops_constr.data = NULL;
14761                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
14762                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14763                         int64_t first_hops_conv_16 = first_hops_vals[q];
14764                         LDKChannelDetails first_hops_conv_16_conv;
14765                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
14766                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
14767                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
14768                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14769                 }
14770                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14771                 first_hops_ptr = &first_hops_constr;
14772         }
14773         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
14774         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
14775         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
14776         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14777         *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);
14778         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14779         return (int64_t)ret_conv;
14780 }
14781
14782 static jclass LDKRetry_Attempts_class = NULL;
14783 static jmethodID LDKRetry_Attempts_meth = NULL;
14784 static jclass LDKRetry_Timeout_class = NULL;
14785 static jmethodID LDKRetry_Timeout_meth = NULL;
14786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
14787         LDKRetry_Attempts_class =
14788                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
14789         CHECK(LDKRetry_Attempts_class != NULL);
14790         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
14791         CHECK(LDKRetry_Attempts_meth != NULL);
14792         LDKRetry_Timeout_class =
14793                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
14794         CHECK(LDKRetry_Timeout_class != NULL);
14795         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
14796         CHECK(LDKRetry_Timeout_meth != NULL);
14797 }
14798 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14799         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
14800         switch(obj->tag) {
14801                 case LDKRetry_Attempts: {
14802                         int64_t attempts_conv = obj->attempts;
14803                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
14804                 }
14805                 case LDKRetry_Timeout: {
14806                         int64_t timeout_conv = obj->timeout;
14807                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
14808                 }
14809                 default: abort();
14810         }
14811 }
14812 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14813         LDKStr ret_str = _ldk_get_compiled_version();
14814         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14815         Str_free(ret_str);
14816         return ret_conv;
14817 }
14818
14819 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14820         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
14821         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14822         Str_free(ret_str);
14823         return ret_conv;
14824 }
14825
14826 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
14827         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14828         *ret_copy = Bech32Error_clone(arg);
14829 int64_t ret_ref = (uintptr_t)ret_copy;
14830         return ret_ref;
14831 }
14832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14833         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
14834         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
14835         return ret_conv;
14836 }
14837
14838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14839         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
14840         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14841         *ret_copy = Bech32Error_clone(orig_conv);
14842         int64_t ret_ref = (uintptr_t)ret_copy;
14843         return ret_ref;
14844 }
14845
14846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
14847         if ((o & 1) != 0) return;
14848         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14849         CHECK_ACCESS(o_ptr);
14850         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
14851         FREE((void*)o);
14852         Bech32Error_free(o_conv);
14853 }
14854
14855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14856         LDKTransaction _res_ref;
14857         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14858         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
14859         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14860         _res_ref.data_is_owned = true;
14861         Transaction_free(_res_ref);
14862 }
14863
14864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
14865         LDKCVec_u8Z script_pubkey_ref;
14866         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
14867         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
14868         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
14869         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14870         *ret_ref = TxOut_new(script_pubkey_ref, value);
14871         return (int64_t)ret_ref;
14872 }
14873
14874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
14875         if ((_res & 1) != 0) return;
14876         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14877         CHECK_ACCESS(_res_ptr);
14878         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
14879         FREE((void*)_res);
14880         TxOut_free(_res_conv);
14881 }
14882
14883 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
14884         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14885         *ret_ref = TxOut_clone(arg);
14886         return (int64_t)ret_ref;
14887 }
14888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14889         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
14890         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
14891         return ret_conv;
14892 }
14893
14894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14895         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
14896         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14897         *ret_ref = TxOut_clone(orig_conv);
14898         return (int64_t)ret_ref;
14899 }
14900
14901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
14902         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
14903         Str_free(dummy);
14904 }
14905
14906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14907         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14908         *ret_conv = CResult_NoneNoneZ_ok();
14909         return (int64_t)ret_conv;
14910 }
14911
14912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14913         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14914         *ret_conv = CResult_NoneNoneZ_err();
14915         return (int64_t)ret_conv;
14916 }
14917
14918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14919         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14920         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
14921         return ret_conv;
14922 }
14923
14924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14925         if ((_res & 1) != 0) return;
14926         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14927         CHECK_ACCESS(_res_ptr);
14928         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14929         FREE((void*)_res);
14930         CResult_NoneNoneZ_free(_res_conv);
14931 }
14932
14933 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14934         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14935         *ret_conv = CResult_NoneNoneZ_clone(arg);
14936         return (int64_t)ret_conv;
14937 }
14938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14939         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14940         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
14941         return ret_conv;
14942 }
14943
14944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14945         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14946         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14947         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14948         return (int64_t)ret_conv;
14949 }
14950
14951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14952         LDKCounterpartyCommitmentSecrets o_conv;
14953         o_conv.inner = (void*)(o & (~1));
14954         o_conv.is_owned = (o & 1) || (o == 0);
14955         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14956         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
14957         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14958         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
14959         return (int64_t)ret_conv;
14960 }
14961
14962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14963         LDKDecodeError e_conv;
14964         e_conv.inner = (void*)(e & (~1));
14965         e_conv.is_owned = (e & 1) || (e == 0);
14966         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14967         e_conv = DecodeError_clone(&e_conv);
14968         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14969         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
14970         return (int64_t)ret_conv;
14971 }
14972
14973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14974         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
14975         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
14976         return ret_conv;
14977 }
14978
14979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14980         if ((_res & 1) != 0) return;
14981         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14982         CHECK_ACCESS(_res_ptr);
14983         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
14984         FREE((void*)_res);
14985         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
14986 }
14987
14988 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
14989         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14990         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
14991         return (int64_t)ret_conv;
14992 }
14993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14994         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
14995         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
14996         return ret_conv;
14997 }
14998
14999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15000         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
15001         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15002         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
15003         return (int64_t)ret_conv;
15004 }
15005
15006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15007         LDKSecretKey o_ref;
15008         CHECK((*env)->GetArrayLength(env, o) == 32);
15009         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
15010         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15011         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
15012         return (int64_t)ret_conv;
15013 }
15014
15015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15016         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15017         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15018         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
15019         return (int64_t)ret_conv;
15020 }
15021
15022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15023         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
15024         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
15025         return ret_conv;
15026 }
15027
15028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15029         if ((_res & 1) != 0) return;
15030         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15031         CHECK_ACCESS(_res_ptr);
15032         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
15033         FREE((void*)_res);
15034         CResult_SecretKeyErrorZ_free(_res_conv);
15035 }
15036
15037 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
15038         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15039         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
15040         return (int64_t)ret_conv;
15041 }
15042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15043         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
15044         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
15045         return ret_conv;
15046 }
15047
15048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15049         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
15050         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15051         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
15052         return (int64_t)ret_conv;
15053 }
15054
15055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15056         LDKPublicKey o_ref;
15057         CHECK((*env)->GetArrayLength(env, o) == 33);
15058         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
15059         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15060         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
15061         return (int64_t)ret_conv;
15062 }
15063
15064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15065         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15066         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15067         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
15068         return (int64_t)ret_conv;
15069 }
15070
15071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15072         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
15073         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
15074         return ret_conv;
15075 }
15076
15077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15078         if ((_res & 1) != 0) return;
15079         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15080         CHECK_ACCESS(_res_ptr);
15081         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
15082         FREE((void*)_res);
15083         CResult_PublicKeyErrorZ_free(_res_conv);
15084 }
15085
15086 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
15087         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15088         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
15089         return (int64_t)ret_conv;
15090 }
15091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15092         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
15093         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
15094         return ret_conv;
15095 }
15096
15097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15098         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
15099         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15100         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
15101         return (int64_t)ret_conv;
15102 }
15103
15104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15105         LDKTxCreationKeys o_conv;
15106         o_conv.inner = (void*)(o & (~1));
15107         o_conv.is_owned = (o & 1) || (o == 0);
15108         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15109         o_conv = TxCreationKeys_clone(&o_conv);
15110         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15111         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
15112         return (int64_t)ret_conv;
15113 }
15114
15115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15116         LDKDecodeError e_conv;
15117         e_conv.inner = (void*)(e & (~1));
15118         e_conv.is_owned = (e & 1) || (e == 0);
15119         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15120         e_conv = DecodeError_clone(&e_conv);
15121         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15122         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
15123         return (int64_t)ret_conv;
15124 }
15125
15126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15127         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
15128         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
15129         return ret_conv;
15130 }
15131
15132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15133         if ((_res & 1) != 0) return;
15134         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15135         CHECK_ACCESS(_res_ptr);
15136         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
15137         FREE((void*)_res);
15138         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
15139 }
15140
15141 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
15142         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15143         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
15144         return (int64_t)ret_conv;
15145 }
15146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15147         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
15148         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
15149         return ret_conv;
15150 }
15151
15152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15153         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
15154         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15155         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
15156         return (int64_t)ret_conv;
15157 }
15158
15159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15160         LDKChannelPublicKeys o_conv;
15161         o_conv.inner = (void*)(o & (~1));
15162         o_conv.is_owned = (o & 1) || (o == 0);
15163         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15164         o_conv = ChannelPublicKeys_clone(&o_conv);
15165         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15166         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
15167         return (int64_t)ret_conv;
15168 }
15169
15170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15171         LDKDecodeError e_conv;
15172         e_conv.inner = (void*)(e & (~1));
15173         e_conv.is_owned = (e & 1) || (e == 0);
15174         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15175         e_conv = DecodeError_clone(&e_conv);
15176         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15177         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
15178         return (int64_t)ret_conv;
15179 }
15180
15181 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15182         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
15183         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
15184         return ret_conv;
15185 }
15186
15187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15188         if ((_res & 1) != 0) return;
15189         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15190         CHECK_ACCESS(_res_ptr);
15191         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
15192         FREE((void*)_res);
15193         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
15194 }
15195
15196 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
15197         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15198         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
15199         return (int64_t)ret_conv;
15200 }
15201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15202         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
15203         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
15204         return ret_conv;
15205 }
15206
15207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15208         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
15209         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15210         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
15211         return (int64_t)ret_conv;
15212 }
15213
15214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15215         LDKTxCreationKeys o_conv;
15216         o_conv.inner = (void*)(o & (~1));
15217         o_conv.is_owned = (o & 1) || (o == 0);
15218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15219         o_conv = TxCreationKeys_clone(&o_conv);
15220         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15221         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
15222         return (int64_t)ret_conv;
15223 }
15224
15225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15226         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15227         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15228         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
15229         return (int64_t)ret_conv;
15230 }
15231
15232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15233         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
15234         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
15235         return ret_conv;
15236 }
15237
15238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15239         if ((_res & 1) != 0) return;
15240         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15241         CHECK_ACCESS(_res_ptr);
15242         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
15243         FREE((void*)_res);
15244         CResult_TxCreationKeysErrorZ_free(_res_conv);
15245 }
15246
15247 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
15248         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15249         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
15250         return (int64_t)ret_conv;
15251 }
15252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15253         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
15254         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
15255         return ret_conv;
15256 }
15257
15258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15259         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
15260         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15261         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
15262         return (int64_t)ret_conv;
15263 }
15264
15265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
15266         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15267         *ret_copy = COption_u32Z_some(o);
15268         int64_t ret_ref = (uintptr_t)ret_copy;
15269         return ret_ref;
15270 }
15271
15272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
15273         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15274         *ret_copy = COption_u32Z_none();
15275         int64_t ret_ref = (uintptr_t)ret_copy;
15276         return ret_ref;
15277 }
15278
15279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15280         if ((_res & 1) != 0) return;
15281         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15282         CHECK_ACCESS(_res_ptr);
15283         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
15284         FREE((void*)_res);
15285         COption_u32Z_free(_res_conv);
15286 }
15287
15288 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
15289         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15290         *ret_copy = COption_u32Z_clone(arg);
15291 int64_t ret_ref = (uintptr_t)ret_copy;
15292         return ret_ref;
15293 }
15294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15295         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
15296         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
15297         return ret_conv;
15298 }
15299
15300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15301         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
15302         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15303         *ret_copy = COption_u32Z_clone(orig_conv);
15304         int64_t ret_ref = (uintptr_t)ret_copy;
15305         return ret_ref;
15306 }
15307
15308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15309         LDKHTLCOutputInCommitment o_conv;
15310         o_conv.inner = (void*)(o & (~1));
15311         o_conv.is_owned = (o & 1) || (o == 0);
15312         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15313         o_conv = HTLCOutputInCommitment_clone(&o_conv);
15314         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15315         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
15316         return (int64_t)ret_conv;
15317 }
15318
15319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15320         LDKDecodeError e_conv;
15321         e_conv.inner = (void*)(e & (~1));
15322         e_conv.is_owned = (e & 1) || (e == 0);
15323         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15324         e_conv = DecodeError_clone(&e_conv);
15325         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15326         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
15327         return (int64_t)ret_conv;
15328 }
15329
15330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15331         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
15332         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
15333         return ret_conv;
15334 }
15335
15336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15337         if ((_res & 1) != 0) return;
15338         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15339         CHECK_ACCESS(_res_ptr);
15340         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
15341         FREE((void*)_res);
15342         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
15343 }
15344
15345 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
15346         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15347         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
15348         return (int64_t)ret_conv;
15349 }
15350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15351         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
15352         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
15353         return ret_conv;
15354 }
15355
15356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15357         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
15358         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15359         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
15360         return (int64_t)ret_conv;
15361 }
15362
15363 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
15364         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
15365         return ret_conv;
15366 }
15367
15368 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
15369         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
15370         return ret_conv;
15371 }
15372
15373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
15374         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
15375         COption_NoneZ_free(_res_conv);
15376 }
15377
15378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15379         LDKCounterpartyChannelTransactionParameters o_conv;
15380         o_conv.inner = (void*)(o & (~1));
15381         o_conv.is_owned = (o & 1) || (o == 0);
15382         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15383         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
15384         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15385         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15386         return (int64_t)ret_conv;
15387 }
15388
15389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15390         LDKDecodeError e_conv;
15391         e_conv.inner = (void*)(e & (~1));
15392         e_conv.is_owned = (e & 1) || (e == 0);
15393         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15394         e_conv = DecodeError_clone(&e_conv);
15395         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15396         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
15397         return (int64_t)ret_conv;
15398 }
15399
15400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15401         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15402         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15403         return ret_conv;
15404 }
15405
15406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15407         if ((_res & 1) != 0) return;
15408         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15409         CHECK_ACCESS(_res_ptr);
15410         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15411         FREE((void*)_res);
15412         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15413 }
15414
15415 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15416         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15417         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
15418         return (int64_t)ret_conv;
15419 }
15420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15421         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15422         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15423         return ret_conv;
15424 }
15425
15426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15427         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15428         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15429         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15430         return (int64_t)ret_conv;
15431 }
15432
15433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15434         LDKChannelTransactionParameters o_conv;
15435         o_conv.inner = (void*)(o & (~1));
15436         o_conv.is_owned = (o & 1) || (o == 0);
15437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15438         o_conv = ChannelTransactionParameters_clone(&o_conv);
15439         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15440         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15441         return (int64_t)ret_conv;
15442 }
15443
15444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15445         LDKDecodeError e_conv;
15446         e_conv.inner = (void*)(e & (~1));
15447         e_conv.is_owned = (e & 1) || (e == 0);
15448         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15449         e_conv = DecodeError_clone(&e_conv);
15450         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15451         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
15452         return (int64_t)ret_conv;
15453 }
15454
15455 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15456         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15457         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15458         return ret_conv;
15459 }
15460
15461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15462         if ((_res & 1) != 0) return;
15463         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15464         CHECK_ACCESS(_res_ptr);
15465         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15466         FREE((void*)_res);
15467         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15468 }
15469
15470 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15471         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15472         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
15473         return (int64_t)ret_conv;
15474 }
15475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15476         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15477         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15478         return ret_conv;
15479 }
15480
15481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15482         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15483         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15484         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15485         return (int64_t)ret_conv;
15486 }
15487
15488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15489         LDKCVec_SignatureZ _res_constr;
15490         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15491         if (_res_constr.datalen > 0)
15492                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15493         else
15494                 _res_constr.data = NULL;
15495         for (size_t i = 0; i < _res_constr.datalen; i++) {
15496                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15497                 LDKSignature _res_conv_8_ref;
15498                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
15499                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
15500                 _res_constr.data[i] = _res_conv_8_ref;
15501         }
15502         CVec_SignatureZ_free(_res_constr);
15503 }
15504
15505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15506         LDKHolderCommitmentTransaction o_conv;
15507         o_conv.inner = (void*)(o & (~1));
15508         o_conv.is_owned = (o & 1) || (o == 0);
15509         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15510         o_conv = HolderCommitmentTransaction_clone(&o_conv);
15511         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15512         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
15513         return (int64_t)ret_conv;
15514 }
15515
15516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15517         LDKDecodeError e_conv;
15518         e_conv.inner = (void*)(e & (~1));
15519         e_conv.is_owned = (e & 1) || (e == 0);
15520         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15521         e_conv = DecodeError_clone(&e_conv);
15522         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15523         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
15524         return (int64_t)ret_conv;
15525 }
15526
15527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15528         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
15529         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15530         return ret_conv;
15531 }
15532
15533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15534         if ((_res & 1) != 0) return;
15535         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15536         CHECK_ACCESS(_res_ptr);
15537         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15538         FREE((void*)_res);
15539         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
15540 }
15541
15542 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15543         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15544         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
15545         return (int64_t)ret_conv;
15546 }
15547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15548         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15549         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15550         return ret_conv;
15551 }
15552
15553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15554         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15555         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15556         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15557         return (int64_t)ret_conv;
15558 }
15559
15560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15561         LDKBuiltCommitmentTransaction o_conv;
15562         o_conv.inner = (void*)(o & (~1));
15563         o_conv.is_owned = (o & 1) || (o == 0);
15564         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15565         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
15566         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15567         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
15568         return (int64_t)ret_conv;
15569 }
15570
15571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15572         LDKDecodeError e_conv;
15573         e_conv.inner = (void*)(e & (~1));
15574         e_conv.is_owned = (e & 1) || (e == 0);
15575         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15576         e_conv = DecodeError_clone(&e_conv);
15577         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15578         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
15579         return (int64_t)ret_conv;
15580 }
15581
15582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15583         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
15584         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15585         return ret_conv;
15586 }
15587
15588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15589         if ((_res & 1) != 0) return;
15590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15591         CHECK_ACCESS(_res_ptr);
15592         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15593         FREE((void*)_res);
15594         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
15595 }
15596
15597 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15598         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15599         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
15600         return (int64_t)ret_conv;
15601 }
15602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15603         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15604         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15605         return ret_conv;
15606 }
15607
15608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15609         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15610         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15611         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15612         return (int64_t)ret_conv;
15613 }
15614
15615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15616         LDKTrustedClosingTransaction o_conv;
15617         o_conv.inner = (void*)(o & (~1));
15618         o_conv.is_owned = (o & 1) || (o == 0);
15619         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15620         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
15621         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15622         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
15623         return (int64_t)ret_conv;
15624 }
15625
15626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15627         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15628         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
15629         return (int64_t)ret_conv;
15630 }
15631
15632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15633         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
15634         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
15635         return ret_conv;
15636 }
15637
15638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15639         if ((_res & 1) != 0) return;
15640         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15641         CHECK_ACCESS(_res_ptr);
15642         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
15643         FREE((void*)_res);
15644         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
15645 }
15646
15647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15648         LDKCommitmentTransaction o_conv;
15649         o_conv.inner = (void*)(o & (~1));
15650         o_conv.is_owned = (o & 1) || (o == 0);
15651         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15652         o_conv = CommitmentTransaction_clone(&o_conv);
15653         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15654         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
15655         return (int64_t)ret_conv;
15656 }
15657
15658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15659         LDKDecodeError e_conv;
15660         e_conv.inner = (void*)(e & (~1));
15661         e_conv.is_owned = (e & 1) || (e == 0);
15662         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15663         e_conv = DecodeError_clone(&e_conv);
15664         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15665         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
15666         return (int64_t)ret_conv;
15667 }
15668
15669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15670         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
15671         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15672         return ret_conv;
15673 }
15674
15675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15676         if ((_res & 1) != 0) return;
15677         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15678         CHECK_ACCESS(_res_ptr);
15679         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
15680         FREE((void*)_res);
15681         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
15682 }
15683
15684 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15685         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15686         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
15687         return (int64_t)ret_conv;
15688 }
15689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15690         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
15691         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15692         return ret_conv;
15693 }
15694
15695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15696         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
15697         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15698         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
15699         return (int64_t)ret_conv;
15700 }
15701
15702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15703         LDKTrustedCommitmentTransaction o_conv;
15704         o_conv.inner = (void*)(o & (~1));
15705         o_conv.is_owned = (o & 1) || (o == 0);
15706         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15707         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
15708         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15709         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
15710         return (int64_t)ret_conv;
15711 }
15712
15713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15714         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15715         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
15716         return (int64_t)ret_conv;
15717 }
15718
15719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15720         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
15721         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
15722         return ret_conv;
15723 }
15724
15725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15726         if ((_res & 1) != 0) return;
15727         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15728         CHECK_ACCESS(_res_ptr);
15729         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
15730         FREE((void*)_res);
15731         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
15732 }
15733
15734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
15735         LDKCVec_SignatureZ o_constr;
15736         o_constr.datalen = (*env)->GetArrayLength(env, o);
15737         if (o_constr.datalen > 0)
15738                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15739         else
15740                 o_constr.data = NULL;
15741         for (size_t i = 0; i < o_constr.datalen; i++) {
15742                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
15743                 LDKSignature o_conv_8_ref;
15744                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
15745                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
15746                 o_constr.data[i] = o_conv_8_ref;
15747         }
15748         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15749         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
15750         return (int64_t)ret_conv;
15751 }
15752
15753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
15754         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15755         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
15756         return (int64_t)ret_conv;
15757 }
15758
15759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15760         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
15761         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
15762         return ret_conv;
15763 }
15764
15765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15766         if ((_res & 1) != 0) return;
15767         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15768         CHECK_ACCESS(_res_ptr);
15769         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
15770         FREE((void*)_res);
15771         CResult_CVec_SignatureZNoneZ_free(_res_conv);
15772 }
15773
15774 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
15775         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15776         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
15777         return (int64_t)ret_conv;
15778 }
15779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15780         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
15781         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
15782         return ret_conv;
15783 }
15784
15785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15786         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
15787         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15788         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
15789         return (int64_t)ret_conv;
15790 }
15791
15792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15793         LDKShutdownScript o_conv;
15794         o_conv.inner = (void*)(o & (~1));
15795         o_conv.is_owned = (o & 1) || (o == 0);
15796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15797         o_conv = ShutdownScript_clone(&o_conv);
15798         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15799         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
15800         return (int64_t)ret_conv;
15801 }
15802
15803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15804         LDKDecodeError e_conv;
15805         e_conv.inner = (void*)(e & (~1));
15806         e_conv.is_owned = (e & 1) || (e == 0);
15807         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15808         e_conv = DecodeError_clone(&e_conv);
15809         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15810         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
15811         return (int64_t)ret_conv;
15812 }
15813
15814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15815         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
15816         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
15817         return ret_conv;
15818 }
15819
15820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15821         if ((_res & 1) != 0) return;
15822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15823         CHECK_ACCESS(_res_ptr);
15824         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
15825         FREE((void*)_res);
15826         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
15827 }
15828
15829 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
15830         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15831         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
15832         return (int64_t)ret_conv;
15833 }
15834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15835         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
15836         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
15837         return ret_conv;
15838 }
15839
15840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15841         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
15842         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15843         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
15844         return (int64_t)ret_conv;
15845 }
15846
15847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15848         LDKShutdownScript o_conv;
15849         o_conv.inner = (void*)(o & (~1));
15850         o_conv.is_owned = (o & 1) || (o == 0);
15851         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15852         o_conv = ShutdownScript_clone(&o_conv);
15853         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15854         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
15855         return (int64_t)ret_conv;
15856 }
15857
15858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15859         LDKInvalidShutdownScript e_conv;
15860         e_conv.inner = (void*)(e & (~1));
15861         e_conv.is_owned = (e & 1) || (e == 0);
15862         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15863         e_conv = InvalidShutdownScript_clone(&e_conv);
15864         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15865         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
15866         return (int64_t)ret_conv;
15867 }
15868
15869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15870         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
15871         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
15872         return ret_conv;
15873 }
15874
15875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15876         if ((_res & 1) != 0) return;
15877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15878         CHECK_ACCESS(_res_ptr);
15879         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
15880         FREE((void*)_res);
15881         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
15882 }
15883
15884 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
15885         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15886         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
15887         return (int64_t)ret_conv;
15888 }
15889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15890         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
15891         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
15892         return ret_conv;
15893 }
15894
15895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15896         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
15897         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15898         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
15899         return (int64_t)ret_conv;
15900 }
15901
15902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
15903         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15904         *ret_conv = CResult_NoneErrorZ_ok();
15905         return (int64_t)ret_conv;
15906 }
15907
15908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15909         LDKIOError e_conv = LDKIOError_from_java(env, e);
15910         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15911         *ret_conv = CResult_NoneErrorZ_err(e_conv);
15912         return (int64_t)ret_conv;
15913 }
15914
15915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15916         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
15917         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
15918         return ret_conv;
15919 }
15920
15921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15922         if ((_res & 1) != 0) return;
15923         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15924         CHECK_ACCESS(_res_ptr);
15925         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
15926         FREE((void*)_res);
15927         CResult_NoneErrorZ_free(_res_conv);
15928 }
15929
15930 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
15931         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15932         *ret_conv = CResult_NoneErrorZ_clone(arg);
15933         return (int64_t)ret_conv;
15934 }
15935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15936         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
15937         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
15938         return ret_conv;
15939 }
15940
15941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15942         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
15943         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15944         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
15945         return (int64_t)ret_conv;
15946 }
15947
15948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15949         LDKRouteHop o_conv;
15950         o_conv.inner = (void*)(o & (~1));
15951         o_conv.is_owned = (o & 1) || (o == 0);
15952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15953         o_conv = RouteHop_clone(&o_conv);
15954         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15955         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
15956         return (int64_t)ret_conv;
15957 }
15958
15959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15960         LDKDecodeError e_conv;
15961         e_conv.inner = (void*)(e & (~1));
15962         e_conv.is_owned = (e & 1) || (e == 0);
15963         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15964         e_conv = DecodeError_clone(&e_conv);
15965         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15966         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
15967         return (int64_t)ret_conv;
15968 }
15969
15970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15971         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
15972         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
15973         return ret_conv;
15974 }
15975
15976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15977         if ((_res & 1) != 0) return;
15978         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15979         CHECK_ACCESS(_res_ptr);
15980         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
15981         FREE((void*)_res);
15982         CResult_RouteHopDecodeErrorZ_free(_res_conv);
15983 }
15984
15985 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
15986         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15987         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
15988         return (int64_t)ret_conv;
15989 }
15990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15991         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
15992         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
15993         return ret_conv;
15994 }
15995
15996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15997         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
15998         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15999         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
16000         return (int64_t)ret_conv;
16001 }
16002
16003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16004         LDKCVec_RouteHopZ _res_constr;
16005         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16006         if (_res_constr.datalen > 0)
16007                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16008         else
16009                 _res_constr.data = NULL;
16010         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16011         for (size_t k = 0; k < _res_constr.datalen; k++) {
16012                 int64_t _res_conv_10 = _res_vals[k];
16013                 LDKRouteHop _res_conv_10_conv;
16014                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
16015                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
16016                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
16017                 _res_constr.data[k] = _res_conv_10_conv;
16018         }
16019         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16020         CVec_RouteHopZ_free(_res_constr);
16021 }
16022
16023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16024         LDKCVec_CVec_RouteHopZZ _res_constr;
16025         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16026         if (_res_constr.datalen > 0)
16027                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
16028         else
16029                 _res_constr.data = NULL;
16030         for (size_t m = 0; m < _res_constr.datalen; m++) {
16031                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
16032                 LDKCVec_RouteHopZ _res_conv_12_constr;
16033                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
16034                 if (_res_conv_12_constr.datalen > 0)
16035                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16036                 else
16037                         _res_conv_12_constr.data = NULL;
16038                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
16039                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
16040                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
16041                         LDKRouteHop _res_conv_12_conv_10_conv;
16042                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
16043                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
16044                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
16045                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
16046                 }
16047                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
16048                 _res_constr.data[m] = _res_conv_12_constr;
16049         }
16050         CVec_CVec_RouteHopZZ_free(_res_constr);
16051 }
16052
16053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16054         LDKRoute o_conv;
16055         o_conv.inner = (void*)(o & (~1));
16056         o_conv.is_owned = (o & 1) || (o == 0);
16057         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16058         o_conv = Route_clone(&o_conv);
16059         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16060         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
16061         return (int64_t)ret_conv;
16062 }
16063
16064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16065         LDKDecodeError e_conv;
16066         e_conv.inner = (void*)(e & (~1));
16067         e_conv.is_owned = (e & 1) || (e == 0);
16068         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16069         e_conv = DecodeError_clone(&e_conv);
16070         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16071         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
16072         return (int64_t)ret_conv;
16073 }
16074
16075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16076         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
16077         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
16078         return ret_conv;
16079 }
16080
16081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16082         if ((_res & 1) != 0) return;
16083         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16084         CHECK_ACCESS(_res_ptr);
16085         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
16086         FREE((void*)_res);
16087         CResult_RouteDecodeErrorZ_free(_res_conv);
16088 }
16089
16090 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
16091         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16092         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
16093         return (int64_t)ret_conv;
16094 }
16095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16096         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
16097         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
16098         return ret_conv;
16099 }
16100
16101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16102         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
16103         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16104         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
16105         return (int64_t)ret_conv;
16106 }
16107
16108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16109         LDKRouteParameters o_conv;
16110         o_conv.inner = (void*)(o & (~1));
16111         o_conv.is_owned = (o & 1) || (o == 0);
16112         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16113         o_conv = RouteParameters_clone(&o_conv);
16114         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16115         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
16116         return (int64_t)ret_conv;
16117 }
16118
16119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16120         LDKDecodeError e_conv;
16121         e_conv.inner = (void*)(e & (~1));
16122         e_conv.is_owned = (e & 1) || (e == 0);
16123         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16124         e_conv = DecodeError_clone(&e_conv);
16125         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16126         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
16127         return (int64_t)ret_conv;
16128 }
16129
16130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16131         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
16132         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
16133         return ret_conv;
16134 }
16135
16136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16137         if ((_res & 1) != 0) return;
16138         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16139         CHECK_ACCESS(_res_ptr);
16140         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
16141         FREE((void*)_res);
16142         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
16143 }
16144
16145 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
16146         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16147         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
16148         return (int64_t)ret_conv;
16149 }
16150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16151         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
16152         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
16153         return ret_conv;
16154 }
16155
16156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16157         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
16158         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16159         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
16160         return (int64_t)ret_conv;
16161 }
16162
16163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16164         LDKCVec_RouteHintZ _res_constr;
16165         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16166         if (_res_constr.datalen > 0)
16167                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
16168         else
16169                 _res_constr.data = NULL;
16170         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16171         for (size_t l = 0; l < _res_constr.datalen; l++) {
16172                 int64_t _res_conv_11 = _res_vals[l];
16173                 LDKRouteHint _res_conv_11_conv;
16174                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
16175                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
16176                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
16177                 _res_constr.data[l] = _res_conv_11_conv;
16178         }
16179         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16180         CVec_RouteHintZ_free(_res_constr);
16181 }
16182
16183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
16184         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16185         *ret_copy = COption_u64Z_some(o);
16186         int64_t ret_ref = (uintptr_t)ret_copy;
16187         return ret_ref;
16188 }
16189
16190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
16191         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16192         *ret_copy = COption_u64Z_none();
16193         int64_t ret_ref = (uintptr_t)ret_copy;
16194         return ret_ref;
16195 }
16196
16197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16198         if ((_res & 1) != 0) return;
16199         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16200         CHECK_ACCESS(_res_ptr);
16201         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
16202         FREE((void*)_res);
16203         COption_u64Z_free(_res_conv);
16204 }
16205
16206 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
16207         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16208         *ret_copy = COption_u64Z_clone(arg);
16209 int64_t ret_ref = (uintptr_t)ret_copy;
16210         return ret_ref;
16211 }
16212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16213         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
16214         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
16215         return ret_conv;
16216 }
16217
16218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16219         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
16220         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16221         *ret_copy = COption_u64Z_clone(orig_conv);
16222         int64_t ret_ref = (uintptr_t)ret_copy;
16223         return ret_ref;
16224 }
16225
16226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16227         LDKCVec_u64Z _res_constr;
16228         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16229         if (_res_constr.datalen > 0)
16230                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16231         else
16232                 _res_constr.data = NULL;
16233         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16234         for (size_t g = 0; g < _res_constr.datalen; g++) {
16235                 int64_t _res_conv_6 = _res_vals[g];
16236                 _res_constr.data[g] = _res_conv_6;
16237         }
16238         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16239         CVec_u64Z_free(_res_constr);
16240 }
16241
16242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16243         LDKPaymentParameters o_conv;
16244         o_conv.inner = (void*)(o & (~1));
16245         o_conv.is_owned = (o & 1) || (o == 0);
16246         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16247         o_conv = PaymentParameters_clone(&o_conv);
16248         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16249         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
16250         return (int64_t)ret_conv;
16251 }
16252
16253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16254         LDKDecodeError e_conv;
16255         e_conv.inner = (void*)(e & (~1));
16256         e_conv.is_owned = (e & 1) || (e == 0);
16257         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16258         e_conv = DecodeError_clone(&e_conv);
16259         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16260         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
16261         return (int64_t)ret_conv;
16262 }
16263
16264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16265         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
16266         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
16267         return ret_conv;
16268 }
16269
16270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16271         if ((_res & 1) != 0) return;
16272         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16273         CHECK_ACCESS(_res_ptr);
16274         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
16275         FREE((void*)_res);
16276         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
16277 }
16278
16279 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
16280         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16281         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
16282         return (int64_t)ret_conv;
16283 }
16284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16285         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
16286         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
16287         return ret_conv;
16288 }
16289
16290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16291         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
16292         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16293         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
16294         return (int64_t)ret_conv;
16295 }
16296
16297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16298         LDKCVec_RouteHintHopZ _res_constr;
16299         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16300         if (_res_constr.datalen > 0)
16301                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
16302         else
16303                 _res_constr.data = NULL;
16304         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16305         for (size_t o = 0; o < _res_constr.datalen; o++) {
16306                 int64_t _res_conv_14 = _res_vals[o];
16307                 LDKRouteHintHop _res_conv_14_conv;
16308                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
16309                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
16310                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
16311                 _res_constr.data[o] = _res_conv_14_conv;
16312         }
16313         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16314         CVec_RouteHintHopZ_free(_res_constr);
16315 }
16316
16317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16318         LDKRouteHint o_conv;
16319         o_conv.inner = (void*)(o & (~1));
16320         o_conv.is_owned = (o & 1) || (o == 0);
16321         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16322         o_conv = RouteHint_clone(&o_conv);
16323         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16324         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
16325         return (int64_t)ret_conv;
16326 }
16327
16328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16329         LDKDecodeError e_conv;
16330         e_conv.inner = (void*)(e & (~1));
16331         e_conv.is_owned = (e & 1) || (e == 0);
16332         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16333         e_conv = DecodeError_clone(&e_conv);
16334         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16335         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
16336         return (int64_t)ret_conv;
16337 }
16338
16339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16340         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
16341         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
16342         return ret_conv;
16343 }
16344
16345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16346         if ((_res & 1) != 0) return;
16347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16348         CHECK_ACCESS(_res_ptr);
16349         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
16350         FREE((void*)_res);
16351         CResult_RouteHintDecodeErrorZ_free(_res_conv);
16352 }
16353
16354 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
16355         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16356         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
16357         return (int64_t)ret_conv;
16358 }
16359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16360         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
16361         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
16362         return ret_conv;
16363 }
16364
16365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16366         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
16367         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16368         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
16369         return (int64_t)ret_conv;
16370 }
16371
16372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16373         LDKRouteHintHop o_conv;
16374         o_conv.inner = (void*)(o & (~1));
16375         o_conv.is_owned = (o & 1) || (o == 0);
16376         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16377         o_conv = RouteHintHop_clone(&o_conv);
16378         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16379         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
16380         return (int64_t)ret_conv;
16381 }
16382
16383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16384         LDKDecodeError e_conv;
16385         e_conv.inner = (void*)(e & (~1));
16386         e_conv.is_owned = (e & 1) || (e == 0);
16387         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16388         e_conv = DecodeError_clone(&e_conv);
16389         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16390         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
16391         return (int64_t)ret_conv;
16392 }
16393
16394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16395         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
16396         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
16397         return ret_conv;
16398 }
16399
16400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16401         if ((_res & 1) != 0) return;
16402         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16403         CHECK_ACCESS(_res_ptr);
16404         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
16405         FREE((void*)_res);
16406         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
16407 }
16408
16409 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
16410         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16411         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
16412         return (int64_t)ret_conv;
16413 }
16414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16415         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
16416         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
16417         return ret_conv;
16418 }
16419
16420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16421         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
16422         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16423         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
16424         return (int64_t)ret_conv;
16425 }
16426
16427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16428         LDKCVec_ChannelDetailsZ _res_constr;
16429         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16430         if (_res_constr.datalen > 0)
16431                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
16432         else
16433                 _res_constr.data = NULL;
16434         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16435         for (size_t q = 0; q < _res_constr.datalen; q++) {
16436                 int64_t _res_conv_16 = _res_vals[q];
16437                 LDKChannelDetails _res_conv_16_conv;
16438                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16439                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16440                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16441                 _res_constr.data[q] = _res_conv_16_conv;
16442         }
16443         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16444         CVec_ChannelDetailsZ_free(_res_constr);
16445 }
16446
16447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16448         LDKRoute o_conv;
16449         o_conv.inner = (void*)(o & (~1));
16450         o_conv.is_owned = (o & 1) || (o == 0);
16451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16452         o_conv = Route_clone(&o_conv);
16453         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16454         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
16455         return (int64_t)ret_conv;
16456 }
16457
16458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16459         LDKLightningError e_conv;
16460         e_conv.inner = (void*)(e & (~1));
16461         e_conv.is_owned = (e & 1) || (e == 0);
16462         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16463         e_conv = LightningError_clone(&e_conv);
16464         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16465         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
16466         return (int64_t)ret_conv;
16467 }
16468
16469 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16470         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
16471         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
16472         return ret_conv;
16473 }
16474
16475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16476         if ((_res & 1) != 0) return;
16477         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16478         CHECK_ACCESS(_res_ptr);
16479         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
16480         FREE((void*)_res);
16481         CResult_RouteLightningErrorZ_free(_res_conv);
16482 }
16483
16484 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
16485         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16486         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
16487         return (int64_t)ret_conv;
16488 }
16489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16490         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
16491         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
16492         return ret_conv;
16493 }
16494
16495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16496         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
16497         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16498         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
16499         return (int64_t)ret_conv;
16500 }
16501
16502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16503         LDKCVec_PublicKeyZ _res_constr;
16504         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16505         if (_res_constr.datalen > 0)
16506                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16507         else
16508                 _res_constr.data = NULL;
16509         for (size_t i = 0; i < _res_constr.datalen; i++) {
16510                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16511                 LDKPublicKey _res_conv_8_ref;
16512                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16513                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16514                 _res_constr.data[i] = _res_conv_8_ref;
16515         }
16516         CVec_PublicKeyZ_free(_res_constr);
16517 }
16518
16519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16520         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16521         CHECK_ACCESS(o_ptr);
16522         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
16523         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
16524         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16525         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
16526         return (int64_t)ret_conv;
16527 }
16528
16529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16530         LDKDecodeError e_conv;
16531         e_conv.inner = (void*)(e & (~1));
16532         e_conv.is_owned = (e & 1) || (e == 0);
16533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16534         e_conv = DecodeError_clone(&e_conv);
16535         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16536         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
16537         return (int64_t)ret_conv;
16538 }
16539
16540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16541         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
16542         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
16543         return ret_conv;
16544 }
16545
16546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16547         if ((_res & 1) != 0) return;
16548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16549         CHECK_ACCESS(_res_ptr);
16550         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
16551         FREE((void*)_res);
16552         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
16553 }
16554
16555 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
16556         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16557         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
16558         return (int64_t)ret_conv;
16559 }
16560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16561         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
16562         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
16563         return ret_conv;
16564 }
16565
16566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16567         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
16568         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16569         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
16570         return (int64_t)ret_conv;
16571 }
16572
16573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16574         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16575         CHECK_ACCESS(o_ptr);
16576         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
16577         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
16578         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16579         *ret_copy = COption_ClosureReasonZ_some(o_conv);
16580         int64_t ret_ref = (uintptr_t)ret_copy;
16581         return ret_ref;
16582 }
16583
16584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
16585         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16586         *ret_copy = COption_ClosureReasonZ_none();
16587         int64_t ret_ref = (uintptr_t)ret_copy;
16588         return ret_ref;
16589 }
16590
16591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16592         if ((_res & 1) != 0) return;
16593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16594         CHECK_ACCESS(_res_ptr);
16595         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
16596         FREE((void*)_res);
16597         COption_ClosureReasonZ_free(_res_conv);
16598 }
16599
16600 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
16601         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16602         *ret_copy = COption_ClosureReasonZ_clone(arg);
16603 int64_t ret_ref = (uintptr_t)ret_copy;
16604         return ret_ref;
16605 }
16606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16607         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
16608         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
16609         return ret_conv;
16610 }
16611
16612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16613         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
16614         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16615         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
16616         int64_t ret_ref = (uintptr_t)ret_copy;
16617         return ret_ref;
16618 }
16619
16620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16621         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16622         CHECK_ACCESS(o_ptr);
16623         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
16624         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
16625         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16626         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
16627         return (int64_t)ret_conv;
16628 }
16629
16630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16631         LDKDecodeError e_conv;
16632         e_conv.inner = (void*)(e & (~1));
16633         e_conv.is_owned = (e & 1) || (e == 0);
16634         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16635         e_conv = DecodeError_clone(&e_conv);
16636         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16637         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
16638         return (int64_t)ret_conv;
16639 }
16640
16641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16642         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
16643         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
16644         return ret_conv;
16645 }
16646
16647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16648         if ((_res & 1) != 0) return;
16649         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16650         CHECK_ACCESS(_res_ptr);
16651         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
16652         FREE((void*)_res);
16653         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
16654 }
16655
16656 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
16657         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16658         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
16659         return (int64_t)ret_conv;
16660 }
16661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16662         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
16663         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
16664         return ret_conv;
16665 }
16666
16667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16668         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
16669         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16670         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
16671         return (int64_t)ret_conv;
16672 }
16673
16674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16675         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16676         CHECK_ACCESS(o_ptr);
16677         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
16678         o_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)o) & ~1));
16679         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16680         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
16681         int64_t ret_ref = (uintptr_t)ret_copy;
16682         return ret_ref;
16683 }
16684
16685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
16686         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16687         *ret_copy = COption_HTLCDestinationZ_none();
16688         int64_t ret_ref = (uintptr_t)ret_copy;
16689         return ret_ref;
16690 }
16691
16692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16693         if ((_res & 1) != 0) return;
16694         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16695         CHECK_ACCESS(_res_ptr);
16696         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
16697         FREE((void*)_res);
16698         COption_HTLCDestinationZ_free(_res_conv);
16699 }
16700
16701 static inline uintptr_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
16702         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16703         *ret_copy = COption_HTLCDestinationZ_clone(arg);
16704 int64_t ret_ref = (uintptr_t)ret_copy;
16705         return ret_ref;
16706 }
16707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16708         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)arg;
16709         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
16710         return ret_conv;
16711 }
16712
16713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16714         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)orig;
16715         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16716         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
16717         int64_t ret_ref = (uintptr_t)ret_copy;
16718         return ret_ref;
16719 }
16720
16721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16722         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16723         CHECK_ACCESS(o_ptr);
16724         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
16725         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)(((uintptr_t)o) & ~1));
16726         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16727         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
16728         return (int64_t)ret_conv;
16729 }
16730
16731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16732         LDKDecodeError e_conv;
16733         e_conv.inner = (void*)(e & (~1));
16734         e_conv.is_owned = (e & 1) || (e == 0);
16735         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16736         e_conv = DecodeError_clone(&e_conv);
16737         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16738         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
16739         return (int64_t)ret_conv;
16740 }
16741
16742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16743         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(o & ~1);
16744         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
16745         return ret_conv;
16746 }
16747
16748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16749         if ((_res & 1) != 0) return;
16750         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16751         CHECK_ACCESS(_res_ptr);
16752         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
16753         FREE((void*)_res);
16754         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
16755 }
16756
16757 static inline uintptr_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
16758         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16759         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
16760         return (int64_t)ret_conv;
16761 }
16762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16763         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(arg & ~1);
16764         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
16765         return ret_conv;
16766 }
16767
16768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16769         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(orig & ~1);
16770         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16771         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
16772         return (int64_t)ret_conv;
16773 }
16774
16775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16776         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16777         CHECK_ACCESS(o_ptr);
16778         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
16779         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
16780         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16781         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
16782         int64_t ret_ref = (uintptr_t)ret_copy;
16783         return ret_ref;
16784 }
16785
16786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
16787         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16788         *ret_copy = COption_NetworkUpdateZ_none();
16789         int64_t ret_ref = (uintptr_t)ret_copy;
16790         return ret_ref;
16791 }
16792
16793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16794         if ((_res & 1) != 0) return;
16795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16796         CHECK_ACCESS(_res_ptr);
16797         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
16798         FREE((void*)_res);
16799         COption_NetworkUpdateZ_free(_res_conv);
16800 }
16801
16802 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
16803         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16804         *ret_copy = COption_NetworkUpdateZ_clone(arg);
16805 int64_t ret_ref = (uintptr_t)ret_copy;
16806         return ret_ref;
16807 }
16808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16809         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
16810         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
16811         return ret_conv;
16812 }
16813
16814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16815         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
16816         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16817         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
16818         int64_t ret_ref = (uintptr_t)ret_copy;
16819         return ret_ref;
16820 }
16821
16822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16823         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16824         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16825         if (_res_constr.datalen > 0)
16826                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16827         else
16828                 _res_constr.data = NULL;
16829         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16830         for (size_t b = 0; b < _res_constr.datalen; b++) {
16831                 int64_t _res_conv_27 = _res_vals[b];
16832                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
16833                 CHECK_ACCESS(_res_conv_27_ptr);
16834                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16835                 FREE((void*)_res_conv_27);
16836                 _res_constr.data[b] = _res_conv_27_conv;
16837         }
16838         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16839         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16840 }
16841
16842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16843         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16844         CHECK_ACCESS(o_ptr);
16845         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
16846         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
16847         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16848         *ret_copy = COption_EventZ_some(o_conv);
16849         int64_t ret_ref = (uintptr_t)ret_copy;
16850         return ret_ref;
16851 }
16852
16853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
16854         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16855         *ret_copy = COption_EventZ_none();
16856         int64_t ret_ref = (uintptr_t)ret_copy;
16857         return ret_ref;
16858 }
16859
16860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16861         if ((_res & 1) != 0) return;
16862         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16863         CHECK_ACCESS(_res_ptr);
16864         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
16865         FREE((void*)_res);
16866         COption_EventZ_free(_res_conv);
16867 }
16868
16869 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
16870         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16871         *ret_copy = COption_EventZ_clone(arg);
16872 int64_t ret_ref = (uintptr_t)ret_copy;
16873         return ret_ref;
16874 }
16875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16876         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
16877         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
16878         return ret_conv;
16879 }
16880
16881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16882         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
16883         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16884         *ret_copy = COption_EventZ_clone(orig_conv);
16885         int64_t ret_ref = (uintptr_t)ret_copy;
16886         return ret_ref;
16887 }
16888
16889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16890         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16891         CHECK_ACCESS(o_ptr);
16892         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
16893         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
16894         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16895         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
16896         return (int64_t)ret_conv;
16897 }
16898
16899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16900         LDKDecodeError e_conv;
16901         e_conv.inner = (void*)(e & (~1));
16902         e_conv.is_owned = (e & 1) || (e == 0);
16903         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16904         e_conv = DecodeError_clone(&e_conv);
16905         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16906         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
16907         return (int64_t)ret_conv;
16908 }
16909
16910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16911         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
16912         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
16913         return ret_conv;
16914 }
16915
16916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16917         if ((_res & 1) != 0) return;
16918         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16919         CHECK_ACCESS(_res_ptr);
16920         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
16921         FREE((void*)_res);
16922         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
16923 }
16924
16925 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
16926         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16927         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
16928         return (int64_t)ret_conv;
16929 }
16930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16931         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
16932         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
16933         return ret_conv;
16934 }
16935
16936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16937         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
16938         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16939         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
16940         return (int64_t)ret_conv;
16941 }
16942
16943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16944         LDKCVec_MessageSendEventZ _res_constr;
16945         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16946         if (_res_constr.datalen > 0)
16947                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
16948         else
16949                 _res_constr.data = NULL;
16950         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16951         for (size_t s = 0; s < _res_constr.datalen; s++) {
16952                 int64_t _res_conv_18 = _res_vals[s];
16953                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
16954                 CHECK_ACCESS(_res_conv_18_ptr);
16955                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
16956                 FREE((void*)_res_conv_18);
16957                 _res_constr.data[s] = _res_conv_18_conv;
16958         }
16959         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16960         CVec_MessageSendEventZ_free(_res_constr);
16961 }
16962
16963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16964         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16965         CHECK_ACCESS(o_ptr);
16966         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
16967         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
16968         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16969         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
16970         return (int64_t)ret_conv;
16971 }
16972
16973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16974         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
16975         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16976         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
16977         return (int64_t)ret_conv;
16978 }
16979
16980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16981         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
16982         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
16983         return ret_conv;
16984 }
16985
16986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16987         if ((_res & 1) != 0) return;
16988         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16989         CHECK_ACCESS(_res_ptr);
16990         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
16991         FREE((void*)_res);
16992         CResult_TxOutAccessErrorZ_free(_res_conv);
16993 }
16994
16995 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
16996         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16997         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
16998         return (int64_t)ret_conv;
16999 }
17000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17001         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
17002         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
17003         return ret_conv;
17004 }
17005
17006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17007         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
17008         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17009         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
17010         return (int64_t)ret_conv;
17011 }
17012
17013 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
17014         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17015         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
17016         return ((int64_t)ret_conv);
17017 }
17018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17019         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
17020         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
17021         return ret_conv;
17022 }
17023
17024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17025         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
17026         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17027         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
17028         return ((int64_t)ret_conv);
17029 }
17030
17031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
17032         LDKTransaction b_ref;
17033         b_ref.datalen = (*env)->GetArrayLength(env, b);
17034         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
17035         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
17036         b_ref.data_is_owned = true;
17037         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17038         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
17039         return ((int64_t)ret_conv);
17040 }
17041
17042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17043         if ((_res & 1) != 0) return;
17044         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17045         CHECK_ACCESS(_res_ptr);
17046         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
17047         FREE((void*)_res);
17048         C2Tuple_usizeTransactionZ_free(_res_conv);
17049 }
17050
17051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17052         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
17053         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17054         if (_res_constr.datalen > 0)
17055                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
17056         else
17057                 _res_constr.data = NULL;
17058         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17059         for (size_t c = 0; c < _res_constr.datalen; c++) {
17060                 int64_t _res_conv_28 = _res_vals[c];
17061                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
17062                 CHECK_ACCESS(_res_conv_28_ptr);
17063                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
17064                 FREE((void*)_res_conv_28);
17065                 _res_constr.data[c] = _res_conv_28_conv;
17066         }
17067         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17068         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
17069 }
17070
17071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17072         LDKCVec_TxidZ _res_constr;
17073         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17074         if (_res_constr.datalen > 0)
17075                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
17076         else
17077                 _res_constr.data = NULL;
17078         for (size_t i = 0; i < _res_constr.datalen; i++) {
17079                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17080                 LDKThirtyTwoBytes _res_conv_8_ref;
17081                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
17082                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
17083                 _res_constr.data[i] = _res_conv_8_ref;
17084         }
17085         CVec_TxidZ_free(_res_constr);
17086 }
17087
17088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
17089         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17090         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
17091         return (int64_t)ret_conv;
17092 }
17093
17094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
17095         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
17096         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17097         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
17098         return (int64_t)ret_conv;
17099 }
17100
17101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17102         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
17103         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
17104         return ret_conv;
17105 }
17106
17107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17108         if ((_res & 1) != 0) return;
17109         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17110         CHECK_ACCESS(_res_ptr);
17111         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
17112         FREE((void*)_res);
17113         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
17114 }
17115
17116 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
17117         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17118         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
17119         return (int64_t)ret_conv;
17120 }
17121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17122         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
17123         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
17124         return ret_conv;
17125 }
17126
17127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17128         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
17129         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17130         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
17131         return (int64_t)ret_conv;
17132 }
17133
17134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17135         LDKCVec_MonitorEventZ _res_constr;
17136         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17137         if (_res_constr.datalen > 0)
17138                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17139         else
17140                 _res_constr.data = NULL;
17141         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17142         for (size_t o = 0; o < _res_constr.datalen; o++) {
17143                 int64_t _res_conv_14 = _res_vals[o];
17144                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
17145                 CHECK_ACCESS(_res_conv_14_ptr);
17146                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
17147                 FREE((void*)_res_conv_14);
17148                 _res_constr.data[o] = _res_conv_14_conv;
17149         }
17150         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17151         CVec_MonitorEventZ_free(_res_constr);
17152 }
17153
17154 static inline uintptr_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
17155         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17156         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
17157         return ((int64_t)ret_conv);
17158 }
17159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17160         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(arg & ~1);
17161         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
17162         return ret_conv;
17163 }
17164
17165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17166         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(orig & ~1);
17167         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17168         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
17169         return ((int64_t)ret_conv);
17170 }
17171
17172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b, int8_tArray c) {
17173         LDKOutPoint a_conv;
17174         a_conv.inner = (void*)(a & (~1));
17175         a_conv.is_owned = (a & 1) || (a == 0);
17176         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17177         a_conv = OutPoint_clone(&a_conv);
17178         LDKCVec_MonitorEventZ b_constr;
17179         b_constr.datalen = (*env)->GetArrayLength(env, b);
17180         if (b_constr.datalen > 0)
17181                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17182         else
17183                 b_constr.data = NULL;
17184         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
17185         for (size_t o = 0; o < b_constr.datalen; o++) {
17186                 int64_t b_conv_14 = b_vals[o];
17187                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
17188                 CHECK_ACCESS(b_conv_14_ptr);
17189                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
17190                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
17191                 b_constr.data[o] = b_conv_14_conv;
17192         }
17193         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
17194         LDKPublicKey c_ref;
17195         CHECK((*env)->GetArrayLength(env, c) == 33);
17196         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
17197         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17198         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
17199         return ((int64_t)ret_conv);
17200 }
17201
17202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17203         if ((_res & 1) != 0) return;
17204         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17205         CHECK_ACCESS(_res_ptr);
17206         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
17207         FREE((void*)_res);
17208         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
17209 }
17210
17211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17212         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
17213         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17214         if (_res_constr.datalen > 0)
17215                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
17216         else
17217                 _res_constr.data = NULL;
17218         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17219         for (size_t x = 0; x < _res_constr.datalen; x++) {
17220                 int64_t _res_conv_49 = _res_vals[x];
17221                 void* _res_conv_49_ptr = (void*)(((uintptr_t)_res_conv_49) & ~1);
17222                 CHECK_ACCESS(_res_conv_49_ptr);
17223                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
17224                 FREE((void*)_res_conv_49);
17225                 _res_constr.data[x] = _res_conv_49_conv;
17226         }
17227         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17228         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
17229 }
17230
17231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17232         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17233         CHECK_ACCESS(o_ptr);
17234         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
17235         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
17236         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17237         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
17238         int64_t ret_ref = (uintptr_t)ret_copy;
17239         return ret_ref;
17240 }
17241
17242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
17243         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17244         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
17245         int64_t ret_ref = (uintptr_t)ret_copy;
17246         return ret_ref;
17247 }
17248
17249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17250         if ((_res & 1) != 0) return;
17251         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17252         CHECK_ACCESS(_res_ptr);
17253         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
17254         FREE((void*)_res);
17255         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
17256 }
17257
17258 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
17259         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17260         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
17261 int64_t ret_ref = (uintptr_t)ret_copy;
17262         return ret_ref;
17263 }
17264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17265         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
17266         int64_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
17267         return ret_conv;
17268 }
17269
17270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17271         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
17272         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17273         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
17274         int64_t ret_ref = (uintptr_t)ret_copy;
17275         return ret_ref;
17276 }
17277
17278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17279         LDKFixedPenaltyScorer o_conv;
17280         o_conv.inner = (void*)(o & (~1));
17281         o_conv.is_owned = (o & 1) || (o == 0);
17282         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17283         o_conv = FixedPenaltyScorer_clone(&o_conv);
17284         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17285         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
17286         return (int64_t)ret_conv;
17287 }
17288
17289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17290         LDKDecodeError e_conv;
17291         e_conv.inner = (void*)(e & (~1));
17292         e_conv.is_owned = (e & 1) || (e == 0);
17293         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17294         e_conv = DecodeError_clone(&e_conv);
17295         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17296         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
17297         return (int64_t)ret_conv;
17298 }
17299
17300 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17301         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
17302         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
17303         return ret_conv;
17304 }
17305
17306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17307         if ((_res & 1) != 0) return;
17308         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17309         CHECK_ACCESS(_res_ptr);
17310         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
17311         FREE((void*)_res);
17312         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
17313 }
17314
17315 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
17316         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17317         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
17318         return (int64_t)ret_conv;
17319 }
17320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17321         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
17322         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
17323         return ret_conv;
17324 }
17325
17326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17327         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
17328         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17329         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
17330         return (int64_t)ret_conv;
17331 }
17332
17333 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
17334         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17335         *ret_conv = C2Tuple_u64u64Z_clone(arg);
17336         return ((int64_t)ret_conv);
17337 }
17338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17339         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
17340         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
17341         return ret_conv;
17342 }
17343
17344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17345         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
17346         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17347         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
17348         return ((int64_t)ret_conv);
17349 }
17350
17351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17352         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17353         *ret_conv = C2Tuple_u64u64Z_new(a, b);
17354         return ((int64_t)ret_conv);
17355 }
17356
17357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17358         if ((_res & 1) != 0) return;
17359         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17360         CHECK_ACCESS(_res_ptr);
17361         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
17362         FREE((void*)_res);
17363         C2Tuple_u64u64Z_free(_res_conv);
17364 }
17365
17366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17367         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17368         CHECK_ACCESS(o_ptr);
17369         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
17370         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
17371         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17372         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
17373         int64_t ret_ref = (uintptr_t)ret_copy;
17374         return ret_ref;
17375 }
17376
17377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
17378         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17379         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
17380         int64_t ret_ref = (uintptr_t)ret_copy;
17381         return ret_ref;
17382 }
17383
17384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17385         if ((_res & 1) != 0) return;
17386         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17387         CHECK_ACCESS(_res_ptr);
17388         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
17389         FREE((void*)_res);
17390         COption_C2Tuple_u64u64ZZ_free(_res_conv);
17391 }
17392
17393 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
17394         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17395         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
17396 int64_t ret_ref = (uintptr_t)ret_copy;
17397         return ret_ref;
17398 }
17399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17400         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
17401         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
17402         return ret_conv;
17403 }
17404
17405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17406         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
17407         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17408         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
17409         int64_t ret_ref = (uintptr_t)ret_copy;
17410         return ret_ref;
17411 }
17412
17413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17414         LDKCVec_NodeIdZ _res_constr;
17415         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17416         if (_res_constr.datalen > 0)
17417                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
17418         else
17419                 _res_constr.data = NULL;
17420         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17421         for (size_t i = 0; i < _res_constr.datalen; i++) {
17422                 int64_t _res_conv_8 = _res_vals[i];
17423                 LDKNodeId _res_conv_8_conv;
17424                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
17425                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
17426                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
17427                 _res_constr.data[i] = _res_conv_8_conv;
17428         }
17429         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17430         CVec_NodeIdZ_free(_res_constr);
17431 }
17432
17433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17434         LDKProbabilisticScorer o_conv;
17435         o_conv.inner = (void*)(o & (~1));
17436         o_conv.is_owned = (o & 1) || (o == 0);
17437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17438         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
17439         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
17440         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
17441         return (int64_t)ret_conv;
17442 }
17443
17444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17445         LDKDecodeError e_conv;
17446         e_conv.inner = (void*)(e & (~1));
17447         e_conv.is_owned = (e & 1) || (e == 0);
17448         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17449         e_conv = DecodeError_clone(&e_conv);
17450         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
17451         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
17452         return (int64_t)ret_conv;
17453 }
17454
17455 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17456         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
17457         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
17458         return ret_conv;
17459 }
17460
17461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17462         if ((_res & 1) != 0) return;
17463         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17464         CHECK_ACCESS(_res_ptr);
17465         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
17466         FREE((void*)_res);
17467         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
17468 }
17469
17470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17471         LDKInitFeatures o_conv;
17472         o_conv.inner = (void*)(o & (~1));
17473         o_conv.is_owned = (o & 1) || (o == 0);
17474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17475         o_conv = InitFeatures_clone(&o_conv);
17476         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17477         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
17478         return (int64_t)ret_conv;
17479 }
17480
17481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17482         LDKDecodeError e_conv;
17483         e_conv.inner = (void*)(e & (~1));
17484         e_conv.is_owned = (e & 1) || (e == 0);
17485         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17486         e_conv = DecodeError_clone(&e_conv);
17487         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17488         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
17489         return (int64_t)ret_conv;
17490 }
17491
17492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17493         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
17494         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
17495         return ret_conv;
17496 }
17497
17498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17499         if ((_res & 1) != 0) return;
17500         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17501         CHECK_ACCESS(_res_ptr);
17502         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
17503         FREE((void*)_res);
17504         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
17505 }
17506
17507 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17508         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17509         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
17510         return (int64_t)ret_conv;
17511 }
17512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17513         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
17514         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17515         return ret_conv;
17516 }
17517
17518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17519         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
17520         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17521         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
17522         return (int64_t)ret_conv;
17523 }
17524
17525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17526         LDKChannelFeatures o_conv;
17527         o_conv.inner = (void*)(o & (~1));
17528         o_conv.is_owned = (o & 1) || (o == 0);
17529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17530         o_conv = ChannelFeatures_clone(&o_conv);
17531         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17532         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
17533         return (int64_t)ret_conv;
17534 }
17535
17536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17537         LDKDecodeError e_conv;
17538         e_conv.inner = (void*)(e & (~1));
17539         e_conv.is_owned = (e & 1) || (e == 0);
17540         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17541         e_conv = DecodeError_clone(&e_conv);
17542         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17543         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
17544         return (int64_t)ret_conv;
17545 }
17546
17547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17548         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
17549         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
17550         return ret_conv;
17551 }
17552
17553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17554         if ((_res & 1) != 0) return;
17555         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17556         CHECK_ACCESS(_res_ptr);
17557         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
17558         FREE((void*)_res);
17559         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
17560 }
17561
17562 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17563         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17564         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
17565         return (int64_t)ret_conv;
17566 }
17567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17568         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
17569         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17570         return ret_conv;
17571 }
17572
17573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17574         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
17575         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17576         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
17577         return (int64_t)ret_conv;
17578 }
17579
17580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17581         LDKNodeFeatures o_conv;
17582         o_conv.inner = (void*)(o & (~1));
17583         o_conv.is_owned = (o & 1) || (o == 0);
17584         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17585         o_conv = NodeFeatures_clone(&o_conv);
17586         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17587         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
17588         return (int64_t)ret_conv;
17589 }
17590
17591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17592         LDKDecodeError e_conv;
17593         e_conv.inner = (void*)(e & (~1));
17594         e_conv.is_owned = (e & 1) || (e == 0);
17595         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17596         e_conv = DecodeError_clone(&e_conv);
17597         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17598         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
17599         return (int64_t)ret_conv;
17600 }
17601
17602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17603         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
17604         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
17605         return ret_conv;
17606 }
17607
17608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17609         if ((_res & 1) != 0) return;
17610         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17611         CHECK_ACCESS(_res_ptr);
17612         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
17613         FREE((void*)_res);
17614         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
17615 }
17616
17617 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17618         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17619         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
17620         return (int64_t)ret_conv;
17621 }
17622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17623         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
17624         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17625         return ret_conv;
17626 }
17627
17628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17629         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
17630         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17631         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
17632         return (int64_t)ret_conv;
17633 }
17634
17635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17636         LDKInvoiceFeatures o_conv;
17637         o_conv.inner = (void*)(o & (~1));
17638         o_conv.is_owned = (o & 1) || (o == 0);
17639         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17640         o_conv = InvoiceFeatures_clone(&o_conv);
17641         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17642         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
17643         return (int64_t)ret_conv;
17644 }
17645
17646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17647         LDKDecodeError e_conv;
17648         e_conv.inner = (void*)(e & (~1));
17649         e_conv.is_owned = (e & 1) || (e == 0);
17650         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17651         e_conv = DecodeError_clone(&e_conv);
17652         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17653         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
17654         return (int64_t)ret_conv;
17655 }
17656
17657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17658         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
17659         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
17660         return ret_conv;
17661 }
17662
17663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17664         if ((_res & 1) != 0) return;
17665         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17666         CHECK_ACCESS(_res_ptr);
17667         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
17668         FREE((void*)_res);
17669         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
17670 }
17671
17672 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17673         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17674         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
17675         return (int64_t)ret_conv;
17676 }
17677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17678         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
17679         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17680         return ret_conv;
17681 }
17682
17683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17684         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
17685         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17686         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
17687         return (int64_t)ret_conv;
17688 }
17689
17690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17691         LDKChannelTypeFeatures o_conv;
17692         o_conv.inner = (void*)(o & (~1));
17693         o_conv.is_owned = (o & 1) || (o == 0);
17694         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17695         o_conv = ChannelTypeFeatures_clone(&o_conv);
17696         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17697         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
17698         return (int64_t)ret_conv;
17699 }
17700
17701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17702         LDKDecodeError e_conv;
17703         e_conv.inner = (void*)(e & (~1));
17704         e_conv.is_owned = (e & 1) || (e == 0);
17705         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17706         e_conv = DecodeError_clone(&e_conv);
17707         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17708         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
17709         return (int64_t)ret_conv;
17710 }
17711
17712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17713         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
17714         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
17715         return ret_conv;
17716 }
17717
17718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17719         if ((_res & 1) != 0) return;
17720         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17721         CHECK_ACCESS(_res_ptr);
17722         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
17723         FREE((void*)_res);
17724         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
17725 }
17726
17727 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17728         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17729         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
17730         return (int64_t)ret_conv;
17731 }
17732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17733         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
17734         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17735         return ret_conv;
17736 }
17737
17738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17739         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
17740         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17741         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
17742         return (int64_t)ret_conv;
17743 }
17744
17745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17746         LDKNodeId o_conv;
17747         o_conv.inner = (void*)(o & (~1));
17748         o_conv.is_owned = (o & 1) || (o == 0);
17749         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17750         o_conv = NodeId_clone(&o_conv);
17751         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17752         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
17753         return (int64_t)ret_conv;
17754 }
17755
17756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17757         LDKDecodeError e_conv;
17758         e_conv.inner = (void*)(e & (~1));
17759         e_conv.is_owned = (e & 1) || (e == 0);
17760         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17761         e_conv = DecodeError_clone(&e_conv);
17762         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17763         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
17764         return (int64_t)ret_conv;
17765 }
17766
17767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17768         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
17769         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
17770         return ret_conv;
17771 }
17772
17773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17774         if ((_res & 1) != 0) return;
17775         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17776         CHECK_ACCESS(_res_ptr);
17777         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
17778         FREE((void*)_res);
17779         CResult_NodeIdDecodeErrorZ_free(_res_conv);
17780 }
17781
17782 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
17783         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17784         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
17785         return (int64_t)ret_conv;
17786 }
17787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17788         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
17789         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
17790         return ret_conv;
17791 }
17792
17793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17794         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
17795         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17796         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
17797         return (int64_t)ret_conv;
17798 }
17799
17800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17801         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17802         CHECK_ACCESS(o_ptr);
17803         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
17804         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
17805         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17806         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
17807         return (int64_t)ret_conv;
17808 }
17809
17810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17811         LDKDecodeError e_conv;
17812         e_conv.inner = (void*)(e & (~1));
17813         e_conv.is_owned = (e & 1) || (e == 0);
17814         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17815         e_conv = DecodeError_clone(&e_conv);
17816         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17817         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
17818         return (int64_t)ret_conv;
17819 }
17820
17821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17822         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
17823         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
17824         return ret_conv;
17825 }
17826
17827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17828         if ((_res & 1) != 0) return;
17829         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17830         CHECK_ACCESS(_res_ptr);
17831         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
17832         FREE((void*)_res);
17833         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
17834 }
17835
17836 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
17837         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17838         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
17839         return (int64_t)ret_conv;
17840 }
17841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17842         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
17843         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
17844         return ret_conv;
17845 }
17846
17847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17848         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
17849         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17850         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
17851         return (int64_t)ret_conv;
17852 }
17853
17854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17855         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17856         CHECK_ACCESS(o_ptr);
17857         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
17858         if (o_conv.free == LDKAccess_JCalls_free) {
17859                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17860                 LDKAccess_JCalls_cloned(&o_conv);
17861         }
17862         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17863         *ret_copy = COption_AccessZ_some(o_conv);
17864         int64_t ret_ref = (uintptr_t)ret_copy;
17865         return ret_ref;
17866 }
17867
17868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
17869         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17870         *ret_copy = COption_AccessZ_none();
17871         int64_t ret_ref = (uintptr_t)ret_copy;
17872         return ret_ref;
17873 }
17874
17875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_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         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
17880         FREE((void*)_res);
17881         COption_AccessZ_free(_res_conv);
17882 }
17883
17884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
17885         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17886         *ret_conv = CResult_boolLightningErrorZ_ok(o);
17887         return (int64_t)ret_conv;
17888 }
17889
17890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17891         LDKLightningError e_conv;
17892         e_conv.inner = (void*)(e & (~1));
17893         e_conv.is_owned = (e & 1) || (e == 0);
17894         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17895         e_conv = LightningError_clone(&e_conv);
17896         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17897         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
17898         return (int64_t)ret_conv;
17899 }
17900
17901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17902         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
17903         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
17904         return ret_conv;
17905 }
17906
17907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17908         if ((_res & 1) != 0) return;
17909         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17910         CHECK_ACCESS(_res_ptr);
17911         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
17912         FREE((void*)_res);
17913         CResult_boolLightningErrorZ_free(_res_conv);
17914 }
17915
17916 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
17917         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17918         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
17919         return (int64_t)ret_conv;
17920 }
17921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17922         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
17923         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
17924         return ret_conv;
17925 }
17926
17927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17928         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
17929         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17930         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
17931         return (int64_t)ret_conv;
17932 }
17933
17934 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
17935         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17936         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
17937         return ((int64_t)ret_conv);
17938 }
17939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17940         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
17941         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
17942         return ret_conv;
17943 }
17944
17945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17946         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
17947         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17948         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
17949         return ((int64_t)ret_conv);
17950 }
17951
17952 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) {
17953         LDKChannelAnnouncement a_conv;
17954         a_conv.inner = (void*)(a & (~1));
17955         a_conv.is_owned = (a & 1) || (a == 0);
17956         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17957         a_conv = ChannelAnnouncement_clone(&a_conv);
17958         LDKChannelUpdate b_conv;
17959         b_conv.inner = (void*)(b & (~1));
17960         b_conv.is_owned = (b & 1) || (b == 0);
17961         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17962         b_conv = ChannelUpdate_clone(&b_conv);
17963         LDKChannelUpdate c_conv;
17964         c_conv.inner = (void*)(c & (~1));
17965         c_conv.is_owned = (c & 1) || (c == 0);
17966         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17967         c_conv = ChannelUpdate_clone(&c_conv);
17968         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17969         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
17970         return ((int64_t)ret_conv);
17971 }
17972
17973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17974         if ((_res & 1) != 0) return;
17975         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17976         CHECK_ACCESS(_res_ptr);
17977         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
17978         FREE((void*)_res);
17979         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
17980 }
17981
17982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17983         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
17984         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17985         if (_res_constr.datalen > 0)
17986                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
17987         else
17988                 _res_constr.data = NULL;
17989         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17990         for (size_t h = 0; h < _res_constr.datalen; h++) {
17991                 int64_t _res_conv_59 = _res_vals[h];
17992                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
17993                 CHECK_ACCESS(_res_conv_59_ptr);
17994                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
17995                 FREE((void*)_res_conv_59);
17996                 _res_constr.data[h] = _res_conv_59_conv;
17997         }
17998         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17999         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
18000 }
18001
18002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18003         LDKCVec_NodeAnnouncementZ _res_constr;
18004         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18005         if (_res_constr.datalen > 0)
18006                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
18007         else
18008                 _res_constr.data = NULL;
18009         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18010         for (size_t s = 0; s < _res_constr.datalen; s++) {
18011                 int64_t _res_conv_18 = _res_vals[s];
18012                 LDKNodeAnnouncement _res_conv_18_conv;
18013                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
18014                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
18015                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
18016                 _res_constr.data[s] = _res_conv_18_conv;
18017         }
18018         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18019         CVec_NodeAnnouncementZ_free(_res_constr);
18020 }
18021
18022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
18023         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18024         *ret_conv = CResult_NoneLightningErrorZ_ok();
18025         return (int64_t)ret_conv;
18026 }
18027
18028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18029         LDKLightningError e_conv;
18030         e_conv.inner = (void*)(e & (~1));
18031         e_conv.is_owned = (e & 1) || (e == 0);
18032         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18033         e_conv = LightningError_clone(&e_conv);
18034         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18035         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
18036         return (int64_t)ret_conv;
18037 }
18038
18039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18040         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
18041         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
18042         return ret_conv;
18043 }
18044
18045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18046         if ((_res & 1) != 0) return;
18047         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18048         CHECK_ACCESS(_res_ptr);
18049         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
18050         FREE((void*)_res);
18051         CResult_NoneLightningErrorZ_free(_res_conv);
18052 }
18053
18054 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
18055         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18056         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
18057         return (int64_t)ret_conv;
18058 }
18059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18060         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
18061         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
18062         return ret_conv;
18063 }
18064
18065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18066         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
18067         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18068         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
18069         return (int64_t)ret_conv;
18070 }
18071
18072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18073         LDKChannelUpdateInfo o_conv;
18074         o_conv.inner = (void*)(o & (~1));
18075         o_conv.is_owned = (o & 1) || (o == 0);
18076         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18077         o_conv = ChannelUpdateInfo_clone(&o_conv);
18078         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18079         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
18080         return (int64_t)ret_conv;
18081 }
18082
18083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18084         LDKDecodeError e_conv;
18085         e_conv.inner = (void*)(e & (~1));
18086         e_conv.is_owned = (e & 1) || (e == 0);
18087         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18088         e_conv = DecodeError_clone(&e_conv);
18089         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18090         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
18091         return (int64_t)ret_conv;
18092 }
18093
18094 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18095         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
18096         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
18097         return ret_conv;
18098 }
18099
18100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18101         if ((_res & 1) != 0) return;
18102         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18103         CHECK_ACCESS(_res_ptr);
18104         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
18105         FREE((void*)_res);
18106         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
18107 }
18108
18109 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
18110         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18111         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
18112         return (int64_t)ret_conv;
18113 }
18114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18115         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
18116         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
18117         return ret_conv;
18118 }
18119
18120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18121         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
18122         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18123         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
18124         return (int64_t)ret_conv;
18125 }
18126
18127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18128         LDKChannelInfo o_conv;
18129         o_conv.inner = (void*)(o & (~1));
18130         o_conv.is_owned = (o & 1) || (o == 0);
18131         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18132         o_conv = ChannelInfo_clone(&o_conv);
18133         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18134         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
18135         return (int64_t)ret_conv;
18136 }
18137
18138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18139         LDKDecodeError e_conv;
18140         e_conv.inner = (void*)(e & (~1));
18141         e_conv.is_owned = (e & 1) || (e == 0);
18142         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18143         e_conv = DecodeError_clone(&e_conv);
18144         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18145         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
18146         return (int64_t)ret_conv;
18147 }
18148
18149 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18150         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
18151         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
18152         return ret_conv;
18153 }
18154
18155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18156         if ((_res & 1) != 0) return;
18157         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18158         CHECK_ACCESS(_res_ptr);
18159         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
18160         FREE((void*)_res);
18161         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
18162 }
18163
18164 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
18165         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18166         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
18167         return (int64_t)ret_conv;
18168 }
18169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18170         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
18171         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
18172         return ret_conv;
18173 }
18174
18175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18176         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
18177         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18178         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
18179         return (int64_t)ret_conv;
18180 }
18181
18182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18183         LDKRoutingFees o_conv;
18184         o_conv.inner = (void*)(o & (~1));
18185         o_conv.is_owned = (o & 1) || (o == 0);
18186         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18187         o_conv = RoutingFees_clone(&o_conv);
18188         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18189         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
18190         return (int64_t)ret_conv;
18191 }
18192
18193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18194         LDKDecodeError e_conv;
18195         e_conv.inner = (void*)(e & (~1));
18196         e_conv.is_owned = (e & 1) || (e == 0);
18197         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18198         e_conv = DecodeError_clone(&e_conv);
18199         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18200         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
18201         return (int64_t)ret_conv;
18202 }
18203
18204 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18205         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
18206         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
18207         return ret_conv;
18208 }
18209
18210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18211         if ((_res & 1) != 0) return;
18212         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18213         CHECK_ACCESS(_res_ptr);
18214         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
18215         FREE((void*)_res);
18216         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
18217 }
18218
18219 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
18220         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18221         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
18222         return (int64_t)ret_conv;
18223 }
18224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18225         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
18226         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
18227         return ret_conv;
18228 }
18229
18230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18231         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
18232         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18233         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
18234         return (int64_t)ret_conv;
18235 }
18236
18237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18238         LDKCVec_NetAddressZ _res_constr;
18239         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18240         if (_res_constr.datalen > 0)
18241                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18242         else
18243                 _res_constr.data = NULL;
18244         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18245         for (size_t m = 0; m < _res_constr.datalen; m++) {
18246                 int64_t _res_conv_12 = _res_vals[m];
18247                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
18248                 CHECK_ACCESS(_res_conv_12_ptr);
18249                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
18250                 FREE((void*)_res_conv_12);
18251                 _res_constr.data[m] = _res_conv_12_conv;
18252         }
18253         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18254         CVec_NetAddressZ_free(_res_constr);
18255 }
18256
18257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18258         LDKNodeAnnouncementInfo o_conv;
18259         o_conv.inner = (void*)(o & (~1));
18260         o_conv.is_owned = (o & 1) || (o == 0);
18261         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18262         o_conv = NodeAnnouncementInfo_clone(&o_conv);
18263         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18264         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
18265         return (int64_t)ret_conv;
18266 }
18267
18268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18269         LDKDecodeError e_conv;
18270         e_conv.inner = (void*)(e & (~1));
18271         e_conv.is_owned = (e & 1) || (e == 0);
18272         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18273         e_conv = DecodeError_clone(&e_conv);
18274         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18275         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
18276         return (int64_t)ret_conv;
18277 }
18278
18279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18280         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
18281         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
18282         return ret_conv;
18283 }
18284
18285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18286         if ((_res & 1) != 0) return;
18287         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18288         CHECK_ACCESS(_res_ptr);
18289         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
18290         FREE((void*)_res);
18291         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
18292 }
18293
18294 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
18295         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18296         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
18297         return (int64_t)ret_conv;
18298 }
18299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18300         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
18301         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
18302         return ret_conv;
18303 }
18304
18305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18306         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
18307         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18308         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
18309         return (int64_t)ret_conv;
18310 }
18311
18312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18313         LDKNodeAlias o_conv;
18314         o_conv.inner = (void*)(o & (~1));
18315         o_conv.is_owned = (o & 1) || (o == 0);
18316         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18317         o_conv = NodeAlias_clone(&o_conv);
18318         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18319         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
18320         return (int64_t)ret_conv;
18321 }
18322
18323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18324         LDKDecodeError e_conv;
18325         e_conv.inner = (void*)(e & (~1));
18326         e_conv.is_owned = (e & 1) || (e == 0);
18327         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18328         e_conv = DecodeError_clone(&e_conv);
18329         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18330         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
18331         return (int64_t)ret_conv;
18332 }
18333
18334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18335         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
18336         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
18337         return ret_conv;
18338 }
18339
18340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18341         if ((_res & 1) != 0) return;
18342         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18343         CHECK_ACCESS(_res_ptr);
18344         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
18345         FREE((void*)_res);
18346         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
18347 }
18348
18349 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
18350         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18351         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
18352         return (int64_t)ret_conv;
18353 }
18354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18355         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
18356         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
18357         return ret_conv;
18358 }
18359
18360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18361         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
18362         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18363         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
18364         return (int64_t)ret_conv;
18365 }
18366
18367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18368         LDKNodeInfo o_conv;
18369         o_conv.inner = (void*)(o & (~1));
18370         o_conv.is_owned = (o & 1) || (o == 0);
18371         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18372         o_conv = NodeInfo_clone(&o_conv);
18373         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18374         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
18375         return (int64_t)ret_conv;
18376 }
18377
18378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18379         LDKDecodeError e_conv;
18380         e_conv.inner = (void*)(e & (~1));
18381         e_conv.is_owned = (e & 1) || (e == 0);
18382         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18383         e_conv = DecodeError_clone(&e_conv);
18384         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18385         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
18386         return (int64_t)ret_conv;
18387 }
18388
18389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18390         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
18391         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
18392         return ret_conv;
18393 }
18394
18395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18396         if ((_res & 1) != 0) return;
18397         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18398         CHECK_ACCESS(_res_ptr);
18399         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
18400         FREE((void*)_res);
18401         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
18402 }
18403
18404 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
18405         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18406         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
18407         return (int64_t)ret_conv;
18408 }
18409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18410         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
18411         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
18412         return ret_conv;
18413 }
18414
18415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18416         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
18417         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18418         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
18419         return (int64_t)ret_conv;
18420 }
18421
18422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18423         LDKNetworkGraph o_conv;
18424         o_conv.inner = (void*)(o & (~1));
18425         o_conv.is_owned = (o & 1) || (o == 0);
18426         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18427         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
18428         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18429         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
18430         return (int64_t)ret_conv;
18431 }
18432
18433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18434         LDKDecodeError e_conv;
18435         e_conv.inner = (void*)(e & (~1));
18436         e_conv.is_owned = (e & 1) || (e == 0);
18437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18438         e_conv = DecodeError_clone(&e_conv);
18439         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18440         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
18441         return (int64_t)ret_conv;
18442 }
18443
18444 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18445         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
18446         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
18447         return ret_conv;
18448 }
18449
18450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18451         if ((_res & 1) != 0) return;
18452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18453         CHECK_ACCESS(_res_ptr);
18454         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
18455         FREE((void*)_res);
18456         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
18457 }
18458
18459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
18460         LDKCVec_NetAddressZ o_constr;
18461         o_constr.datalen = (*env)->GetArrayLength(env, o);
18462         if (o_constr.datalen > 0)
18463                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18464         else
18465                 o_constr.data = NULL;
18466         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18467         for (size_t m = 0; m < o_constr.datalen; m++) {
18468                 int64_t o_conv_12 = o_vals[m];
18469                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
18470                 CHECK_ACCESS(o_conv_12_ptr);
18471                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
18472                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
18473                 o_constr.data[m] = o_conv_12_conv;
18474         }
18475         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18476         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18477         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
18478         int64_t ret_ref = (uintptr_t)ret_copy;
18479         return ret_ref;
18480 }
18481
18482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
18483         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18484         *ret_copy = COption_CVec_NetAddressZZ_none();
18485         int64_t ret_ref = (uintptr_t)ret_copy;
18486         return ret_ref;
18487 }
18488
18489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18490         if ((_res & 1) != 0) return;
18491         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18492         CHECK_ACCESS(_res_ptr);
18493         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
18494         FREE((void*)_res);
18495         COption_CVec_NetAddressZZ_free(_res_conv);
18496 }
18497
18498 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
18499         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18500         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
18501 int64_t ret_ref = (uintptr_t)ret_copy;
18502         return ret_ref;
18503 }
18504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18505         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
18506         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
18507         return ret_conv;
18508 }
18509
18510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18511         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
18512         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18513         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
18514         int64_t ret_ref = (uintptr_t)ret_copy;
18515         return ret_ref;
18516 }
18517
18518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18519         LDKDelayedPaymentOutputDescriptor o_conv;
18520         o_conv.inner = (void*)(o & (~1));
18521         o_conv.is_owned = (o & 1) || (o == 0);
18522         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18523         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
18524         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18525         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18526         return (int64_t)ret_conv;
18527 }
18528
18529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18530         LDKDecodeError e_conv;
18531         e_conv.inner = (void*)(e & (~1));
18532         e_conv.is_owned = (e & 1) || (e == 0);
18533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18534         e_conv = DecodeError_clone(&e_conv);
18535         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18536         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18537         return (int64_t)ret_conv;
18538 }
18539
18540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18541         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18542         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18543         return ret_conv;
18544 }
18545
18546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18547         if ((_res & 1) != 0) return;
18548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18549         CHECK_ACCESS(_res_ptr);
18550         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18551         FREE((void*)_res);
18552         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18553 }
18554
18555 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18556         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18557         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18558         return (int64_t)ret_conv;
18559 }
18560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18561         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18562         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18563         return ret_conv;
18564 }
18565
18566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18567         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18568         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18569         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18570         return (int64_t)ret_conv;
18571 }
18572
18573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18574         LDKStaticPaymentOutputDescriptor o_conv;
18575         o_conv.inner = (void*)(o & (~1));
18576         o_conv.is_owned = (o & 1) || (o == 0);
18577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18578         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
18579         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18580         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18581         return (int64_t)ret_conv;
18582 }
18583
18584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18585         LDKDecodeError e_conv;
18586         e_conv.inner = (void*)(e & (~1));
18587         e_conv.is_owned = (e & 1) || (e == 0);
18588         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18589         e_conv = DecodeError_clone(&e_conv);
18590         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18591         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18592         return (int64_t)ret_conv;
18593 }
18594
18595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18596         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18597         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18598         return ret_conv;
18599 }
18600
18601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18602         if ((_res & 1) != 0) return;
18603         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18604         CHECK_ACCESS(_res_ptr);
18605         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18606         FREE((void*)_res);
18607         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18608 }
18609
18610 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18611         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18612         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18613         return (int64_t)ret_conv;
18614 }
18615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18616         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18617         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18618         return ret_conv;
18619 }
18620
18621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18622         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18623         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18624         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18625         return (int64_t)ret_conv;
18626 }
18627
18628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18629         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18630         CHECK_ACCESS(o_ptr);
18631         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
18632         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
18633         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18634         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
18635         return (int64_t)ret_conv;
18636 }
18637
18638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18639         LDKDecodeError e_conv;
18640         e_conv.inner = (void*)(e & (~1));
18641         e_conv.is_owned = (e & 1) || (e == 0);
18642         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18643         e_conv = DecodeError_clone(&e_conv);
18644         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18645         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
18646         return (int64_t)ret_conv;
18647 }
18648
18649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18650         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
18651         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18652         return ret_conv;
18653 }
18654
18655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18656         if ((_res & 1) != 0) return;
18657         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18658         CHECK_ACCESS(_res_ptr);
18659         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
18660         FREE((void*)_res);
18661         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
18662 }
18663
18664 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18665         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18666         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
18667         return (int64_t)ret_conv;
18668 }
18669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18670         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
18671         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18672         return ret_conv;
18673 }
18674
18675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18676         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
18677         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18678         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
18679         return (int64_t)ret_conv;
18680 }
18681
18682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18683         LDKCVec_PaymentPreimageZ _res_constr;
18684         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18685         if (_res_constr.datalen > 0)
18686                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
18687         else
18688                 _res_constr.data = NULL;
18689         for (size_t i = 0; i < _res_constr.datalen; i++) {
18690                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18691                 LDKThirtyTwoBytes _res_conv_8_ref;
18692                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
18693                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
18694                 _res_constr.data[i] = _res_conv_8_ref;
18695         }
18696         CVec_PaymentPreimageZ_free(_res_constr);
18697 }
18698
18699 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
18700         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18701         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
18702         return ((int64_t)ret_conv);
18703 }
18704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18705         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
18706         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
18707         return ret_conv;
18708 }
18709
18710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18711         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
18712         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18713         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
18714         return ((int64_t)ret_conv);
18715 }
18716
18717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
18718         LDKSignature a_ref;
18719         CHECK((*env)->GetArrayLength(env, a) == 64);
18720         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18721         LDKCVec_SignatureZ b_constr;
18722         b_constr.datalen = (*env)->GetArrayLength(env, b);
18723         if (b_constr.datalen > 0)
18724                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18725         else
18726                 b_constr.data = NULL;
18727         for (size_t i = 0; i < b_constr.datalen; i++) {
18728                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
18729                 LDKSignature b_conv_8_ref;
18730                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
18731                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
18732                 b_constr.data[i] = b_conv_8_ref;
18733         }
18734         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18735         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
18736         return ((int64_t)ret_conv);
18737 }
18738
18739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18740         if ((_res & 1) != 0) return;
18741         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18742         CHECK_ACCESS(_res_ptr);
18743         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
18744         FREE((void*)_res);
18745         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
18746 }
18747
18748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18749         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18750         CHECK_ACCESS(o_ptr);
18751         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
18752         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
18753         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18754         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
18755         return (int64_t)ret_conv;
18756 }
18757
18758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
18759         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18760         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
18761         return (int64_t)ret_conv;
18762 }
18763
18764 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18765         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
18766         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
18767         return ret_conv;
18768 }
18769
18770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18771         if ((_res & 1) != 0) return;
18772         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18773         CHECK_ACCESS(_res_ptr);
18774         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
18775         FREE((void*)_res);
18776         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
18777 }
18778
18779 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
18780         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18781         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
18782         return (int64_t)ret_conv;
18783 }
18784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18785         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
18786         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
18787         return ret_conv;
18788 }
18789
18790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18791         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
18792         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18793         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
18794         return (int64_t)ret_conv;
18795 }
18796
18797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18798         LDKSignature o_ref;
18799         CHECK((*env)->GetArrayLength(env, o) == 64);
18800         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
18801         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18802         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
18803         return (int64_t)ret_conv;
18804 }
18805
18806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
18807         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18808         *ret_conv = CResult_SignatureNoneZ_err();
18809         return (int64_t)ret_conv;
18810 }
18811
18812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18813         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
18814         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
18815         return ret_conv;
18816 }
18817
18818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18819         if ((_res & 1) != 0) return;
18820         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18821         CHECK_ACCESS(_res_ptr);
18822         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
18823         FREE((void*)_res);
18824         CResult_SignatureNoneZ_free(_res_conv);
18825 }
18826
18827 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
18828         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18829         *ret_conv = CResult_SignatureNoneZ_clone(arg);
18830         return (int64_t)ret_conv;
18831 }
18832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18833         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
18834         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
18835         return ret_conv;
18836 }
18837
18838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18839         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
18840         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18841         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
18842         return (int64_t)ret_conv;
18843 }
18844
18845 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
18846         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18847         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
18848         return ((int64_t)ret_conv);
18849 }
18850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18851         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
18852         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
18853         return ret_conv;
18854 }
18855
18856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18857         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
18858         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18859         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
18860         return ((int64_t)ret_conv);
18861 }
18862
18863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18864         LDKSignature a_ref;
18865         CHECK((*env)->GetArrayLength(env, a) == 64);
18866         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18867         LDKSignature b_ref;
18868         CHECK((*env)->GetArrayLength(env, b) == 64);
18869         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
18870         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18871         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
18872         return ((int64_t)ret_conv);
18873 }
18874
18875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18876         if ((_res & 1) != 0) return;
18877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18878         CHECK_ACCESS(_res_ptr);
18879         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
18880         FREE((void*)_res);
18881         C2Tuple_SignatureSignatureZ_free(_res_conv);
18882 }
18883
18884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18885         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18886         CHECK_ACCESS(o_ptr);
18887         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
18888         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
18889         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18890         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
18891         return (int64_t)ret_conv;
18892 }
18893
18894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
18895         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18896         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
18897         return (int64_t)ret_conv;
18898 }
18899
18900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18901         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
18902         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
18903         return ret_conv;
18904 }
18905
18906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18907         if ((_res & 1) != 0) return;
18908         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18909         CHECK_ACCESS(_res_ptr);
18910         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
18911         FREE((void*)_res);
18912         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
18913 }
18914
18915 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
18916         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18917         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
18918         return (int64_t)ret_conv;
18919 }
18920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18921         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
18922         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
18923         return ret_conv;
18924 }
18925
18926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18927         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
18928         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18929         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
18930         return (int64_t)ret_conv;
18931 }
18932
18933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18934         LDKSecretKey o_ref;
18935         CHECK((*env)->GetArrayLength(env, o) == 32);
18936         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
18937         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18938         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
18939         return (int64_t)ret_conv;
18940 }
18941
18942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
18943         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18944         *ret_conv = CResult_SecretKeyNoneZ_err();
18945         return (int64_t)ret_conv;
18946 }
18947
18948 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18949         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
18950         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
18951         return ret_conv;
18952 }
18953
18954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18955         if ((_res & 1) != 0) return;
18956         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18957         CHECK_ACCESS(_res_ptr);
18958         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
18959         FREE((void*)_res);
18960         CResult_SecretKeyNoneZ_free(_res_conv);
18961 }
18962
18963 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
18964         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18965         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
18966         return (int64_t)ret_conv;
18967 }
18968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18969         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
18970         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
18971         return ret_conv;
18972 }
18973
18974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18975         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
18976         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18977         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
18978         return (int64_t)ret_conv;
18979 }
18980
18981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18982         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18983         CHECK_ACCESS(o_ptr);
18984         LDKSign o_conv = *(LDKSign*)(o_ptr);
18985         if (o_conv.free == LDKSign_JCalls_free) {
18986                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18987                 LDKSign_JCalls_cloned(&o_conv);
18988         }
18989         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18990         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
18991         return (int64_t)ret_conv;
18992 }
18993
18994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18995         LDKDecodeError e_conv;
18996         e_conv.inner = (void*)(e & (~1));
18997         e_conv.is_owned = (e & 1) || (e == 0);
18998         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18999         e_conv = DecodeError_clone(&e_conv);
19000         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19001         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
19002         return (int64_t)ret_conv;
19003 }
19004
19005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19006         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
19007         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
19008         return ret_conv;
19009 }
19010
19011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19012         if ((_res & 1) != 0) return;
19013         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19014         CHECK_ACCESS(_res_ptr);
19015         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
19016         FREE((void*)_res);
19017         CResult_SignDecodeErrorZ_free(_res_conv);
19018 }
19019
19020 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
19021         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19022         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
19023         return (int64_t)ret_conv;
19024 }
19025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19026         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
19027         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
19028         return ret_conv;
19029 }
19030
19031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19032         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
19033         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19034         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
19035         return (int64_t)ret_conv;
19036 }
19037
19038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19039         LDKCVec_u5Z _res_constr;
19040         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19041         if (_res_constr.datalen > 0)
19042                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
19043         else
19044                 _res_constr.data = NULL;
19045         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
19046         for (size_t h = 0; h < _res_constr.datalen; h++) {
19047                 int8_t _res_conv_7 = _res_vals[h];
19048                 
19049                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
19050         }
19051         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
19052         CVec_u5Z_free(_res_constr);
19053 }
19054
19055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19056         LDKRecoverableSignature o_ref;
19057         CHECK((*env)->GetArrayLength(env, o) == 68);
19058         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
19059         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19060         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
19061         return (int64_t)ret_conv;
19062 }
19063
19064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
19065         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19066         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
19067         return (int64_t)ret_conv;
19068 }
19069
19070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19071         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
19072         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
19073         return ret_conv;
19074 }
19075
19076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19077         if ((_res & 1) != 0) return;
19078         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19079         CHECK_ACCESS(_res_ptr);
19080         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
19081         FREE((void*)_res);
19082         CResult_RecoverableSignatureNoneZ_free(_res_conv);
19083 }
19084
19085 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
19086         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19087         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
19088         return (int64_t)ret_conv;
19089 }
19090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19091         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
19092         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
19093         return ret_conv;
19094 }
19095
19096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19097         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
19098         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19099         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
19100         return (int64_t)ret_conv;
19101 }
19102
19103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
19104         LDKCVec_u8Z _res_ref;
19105         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
19106         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
19107         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
19108         CVec_u8Z_free(_res_ref);
19109 }
19110
19111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19112         LDKCVec_CVec_u8ZZ _res_constr;
19113         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19114         if (_res_constr.datalen > 0)
19115                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19116         else
19117                 _res_constr.data = NULL;
19118         for (size_t i = 0; i < _res_constr.datalen; i++) {
19119                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19120                 LDKCVec_u8Z _res_conv_8_ref;
19121                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19122                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19123                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19124                 _res_constr.data[i] = _res_conv_8_ref;
19125         }
19126         CVec_CVec_u8ZZ_free(_res_constr);
19127 }
19128
19129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
19130         LDKCVec_CVec_u8ZZ o_constr;
19131         o_constr.datalen = (*env)->GetArrayLength(env, o);
19132         if (o_constr.datalen > 0)
19133                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19134         else
19135                 o_constr.data = NULL;
19136         for (size_t i = 0; i < o_constr.datalen; i++) {
19137                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
19138                 LDKCVec_u8Z o_conv_8_ref;
19139                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
19140                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19141                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
19142                 o_constr.data[i] = o_conv_8_ref;
19143         }
19144         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19145         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
19146         return (int64_t)ret_conv;
19147 }
19148
19149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
19150         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19151         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
19152         return (int64_t)ret_conv;
19153 }
19154
19155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19156         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
19157         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
19158         return ret_conv;
19159 }
19160
19161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19162         if ((_res & 1) != 0) return;
19163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19164         CHECK_ACCESS(_res_ptr);
19165         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
19166         FREE((void*)_res);
19167         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
19168 }
19169
19170 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
19171         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19172         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
19173         return (int64_t)ret_conv;
19174 }
19175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19176         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
19177         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
19178         return ret_conv;
19179 }
19180
19181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19182         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
19183         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19184         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
19185         return (int64_t)ret_conv;
19186 }
19187
19188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19189         LDKInMemorySigner o_conv;
19190         o_conv.inner = (void*)(o & (~1));
19191         o_conv.is_owned = (o & 1) || (o == 0);
19192         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19193         o_conv = InMemorySigner_clone(&o_conv);
19194         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19195         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
19196         return (int64_t)ret_conv;
19197 }
19198
19199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19200         LDKDecodeError e_conv;
19201         e_conv.inner = (void*)(e & (~1));
19202         e_conv.is_owned = (e & 1) || (e == 0);
19203         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19204         e_conv = DecodeError_clone(&e_conv);
19205         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19206         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
19207         return (int64_t)ret_conv;
19208 }
19209
19210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19211         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
19212         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
19213         return ret_conv;
19214 }
19215
19216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19217         if ((_res & 1) != 0) return;
19218         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19219         CHECK_ACCESS(_res_ptr);
19220         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
19221         FREE((void*)_res);
19222         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
19223 }
19224
19225 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
19226         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19227         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
19228         return (int64_t)ret_conv;
19229 }
19230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19231         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
19232         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
19233         return ret_conv;
19234 }
19235
19236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19237         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
19238         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19239         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
19240         return (int64_t)ret_conv;
19241 }
19242
19243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19244         LDKCVec_TxOutZ _res_constr;
19245         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19246         if (_res_constr.datalen > 0)
19247                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
19248         else
19249                 _res_constr.data = NULL;
19250         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19251         for (size_t h = 0; h < _res_constr.datalen; h++) {
19252                 int64_t _res_conv_7 = _res_vals[h];
19253                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
19254                 CHECK_ACCESS(_res_conv_7_ptr);
19255                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
19256                 FREE((void*)_res_conv_7);
19257                 _res_constr.data[h] = _res_conv_7_conv;
19258         }
19259         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19260         CVec_TxOutZ_free(_res_constr);
19261 }
19262
19263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19264         LDKTransaction o_ref;
19265         o_ref.datalen = (*env)->GetArrayLength(env, o);
19266         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
19267         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
19268         o_ref.data_is_owned = true;
19269         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19270         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
19271         return (int64_t)ret_conv;
19272 }
19273
19274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
19275         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19276         *ret_conv = CResult_TransactionNoneZ_err();
19277         return (int64_t)ret_conv;
19278 }
19279
19280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19281         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
19282         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
19283         return ret_conv;
19284 }
19285
19286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19287         if ((_res & 1) != 0) return;
19288         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19289         CHECK_ACCESS(_res_ptr);
19290         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
19291         FREE((void*)_res);
19292         CResult_TransactionNoneZ_free(_res_conv);
19293 }
19294
19295 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
19296         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19297         *ret_conv = CResult_TransactionNoneZ_clone(arg);
19298         return (int64_t)ret_conv;
19299 }
19300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19301         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
19302         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
19303         return ret_conv;
19304 }
19305
19306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19307         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
19308         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19309         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
19310         return (int64_t)ret_conv;
19311 }
19312
19313 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
19314         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19315         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
19316         return ((int64_t)ret_conv);
19317 }
19318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19319         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
19320         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
19321         return ret_conv;
19322 }
19323
19324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19325         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
19326         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19327         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
19328         return ((int64_t)ret_conv);
19329 }
19330
19331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19332         LDKThirtyTwoBytes a_ref;
19333         CHECK((*env)->GetArrayLength(env, a) == 32);
19334         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19335         LDKChannelMonitor b_conv;
19336         b_conv.inner = (void*)(b & (~1));
19337         b_conv.is_owned = (b & 1) || (b == 0);
19338         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19339         b_conv = ChannelMonitor_clone(&b_conv);
19340         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19341         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
19342         return ((int64_t)ret_conv);
19343 }
19344
19345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19346         if ((_res & 1) != 0) return;
19347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19348         CHECK_ACCESS(_res_ptr);
19349         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
19350         FREE((void*)_res);
19351         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
19352 }
19353
19354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19355         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
19356         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19357         if (_res_constr.datalen > 0)
19358                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
19359         else
19360                 _res_constr.data = NULL;
19361         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19362         for (size_t j = 0; j < _res_constr.datalen; j++) {
19363                 int64_t _res_conv_35 = _res_vals[j];
19364                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
19365                 CHECK_ACCESS(_res_conv_35_ptr);
19366                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
19367                 FREE((void*)_res_conv_35);
19368                 _res_constr.data[j] = _res_conv_35_conv;
19369         }
19370         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19371         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
19372 }
19373
19374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
19375         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
19376         o_constr.datalen = (*env)->GetArrayLength(env, o);
19377         if (o_constr.datalen > 0)
19378                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
19379         else
19380                 o_constr.data = NULL;
19381         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19382         for (size_t j = 0; j < o_constr.datalen; j++) {
19383                 int64_t o_conv_35 = o_vals[j];
19384                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
19385                 CHECK_ACCESS(o_conv_35_ptr);
19386                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
19387                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
19388                 o_constr.data[j] = o_conv_35_conv;
19389         }
19390         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19391         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19392         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
19393         return (int64_t)ret_conv;
19394 }
19395
19396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19397         LDKIOError e_conv = LDKIOError_from_java(env, e);
19398         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19399         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
19400         return (int64_t)ret_conv;
19401 }
19402
19403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19404         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
19405         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
19406         return ret_conv;
19407 }
19408
19409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19410         if ((_res & 1) != 0) return;
19411         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19412         CHECK_ACCESS(_res_ptr);
19413         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
19414         FREE((void*)_res);
19415         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
19416 }
19417
19418 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
19419         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19420         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
19421         return (int64_t)ret_conv;
19422 }
19423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19424         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
19425         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
19426         return ret_conv;
19427 }
19428
19429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19430         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
19431         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19432         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
19433         return (int64_t)ret_conv;
19434 }
19435
19436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
19437         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19438         *ret_copy = COption_u16Z_some(o);
19439         int64_t ret_ref = (uintptr_t)ret_copy;
19440         return ret_ref;
19441 }
19442
19443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
19444         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19445         *ret_copy = COption_u16Z_none();
19446         int64_t ret_ref = (uintptr_t)ret_copy;
19447         return ret_ref;
19448 }
19449
19450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
19451         if ((_res & 1) != 0) return;
19452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19453         CHECK_ACCESS(_res_ptr);
19454         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
19455         FREE((void*)_res);
19456         COption_u16Z_free(_res_conv);
19457 }
19458
19459 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
19460         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19461         *ret_copy = COption_u16Z_clone(arg);
19462 int64_t ret_ref = (uintptr_t)ret_copy;
19463         return ret_ref;
19464 }
19465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19466         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
19467         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
19468         return ret_conv;
19469 }
19470
19471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19472         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
19473         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19474         *ret_copy = COption_u16Z_clone(orig_conv);
19475         int64_t ret_ref = (uintptr_t)ret_copy;
19476         return ret_ref;
19477 }
19478
19479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
19480         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19481         *ret_conv = CResult_NoneAPIErrorZ_ok();
19482         return (int64_t)ret_conv;
19483 }
19484
19485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19486         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19487         CHECK_ACCESS(e_ptr);
19488         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19489         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19490         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19491         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
19492         return (int64_t)ret_conv;
19493 }
19494
19495 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19496         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
19497         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
19498         return ret_conv;
19499 }
19500
19501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19502         if ((_res & 1) != 0) return;
19503         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19504         CHECK_ACCESS(_res_ptr);
19505         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
19506         FREE((void*)_res);
19507         CResult_NoneAPIErrorZ_free(_res_conv);
19508 }
19509
19510 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
19511         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19512         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
19513         return (int64_t)ret_conv;
19514 }
19515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19516         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
19517         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
19518         return ret_conv;
19519 }
19520
19521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19522         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
19523         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19524         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
19525         return (int64_t)ret_conv;
19526 }
19527
19528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19529         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
19530         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19531         if (_res_constr.datalen > 0)
19532                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19533         else
19534                 _res_constr.data = NULL;
19535         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19536         for (size_t w = 0; w < _res_constr.datalen; w++) {
19537                 int64_t _res_conv_22 = _res_vals[w];
19538                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
19539                 CHECK_ACCESS(_res_conv_22_ptr);
19540                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
19541                 FREE((void*)_res_conv_22);
19542                 _res_constr.data[w] = _res_conv_22_conv;
19543         }
19544         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19545         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
19546 }
19547
19548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19549         LDKCVec_APIErrorZ _res_constr;
19550         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19551         if (_res_constr.datalen > 0)
19552                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
19553         else
19554                 _res_constr.data = NULL;
19555         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19556         for (size_t k = 0; k < _res_constr.datalen; k++) {
19557                 int64_t _res_conv_10 = _res_vals[k];
19558                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
19559                 CHECK_ACCESS(_res_conv_10_ptr);
19560                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
19561                 FREE((void*)_res_conv_10);
19562                 _res_constr.data[k] = _res_conv_10_conv;
19563         }
19564         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19565         CVec_APIErrorZ_free(_res_constr);
19566 }
19567
19568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19569         LDKThirtyTwoBytes o_ref;
19570         CHECK((*env)->GetArrayLength(env, o) == 32);
19571         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19572         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19573         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
19574         return (int64_t)ret_conv;
19575 }
19576
19577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19578         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19579         CHECK_ACCESS(e_ptr);
19580         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19581         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19582         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19583         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
19584         return (int64_t)ret_conv;
19585 }
19586
19587 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19588         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
19589         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
19590         return ret_conv;
19591 }
19592
19593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19594         if ((_res & 1) != 0) return;
19595         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19596         CHECK_ACCESS(_res_ptr);
19597         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
19598         FREE((void*)_res);
19599         CResult__u832APIErrorZ_free(_res_conv);
19600 }
19601
19602 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
19603         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19604         *ret_conv = CResult__u832APIErrorZ_clone(arg);
19605         return (int64_t)ret_conv;
19606 }
19607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19608         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
19609         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
19610         return ret_conv;
19611 }
19612
19613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19614         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
19615         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19616         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
19617         return (int64_t)ret_conv;
19618 }
19619
19620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19621         LDKThirtyTwoBytes o_ref;
19622         CHECK((*env)->GetArrayLength(env, o) == 32);
19623         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19624         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19625         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
19626         return (int64_t)ret_conv;
19627 }
19628
19629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19630         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19631         CHECK_ACCESS(e_ptr);
19632         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19633         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19634         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19635         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
19636         return (int64_t)ret_conv;
19637 }
19638
19639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19640         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
19641         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
19642         return ret_conv;
19643 }
19644
19645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19646         if ((_res & 1) != 0) return;
19647         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19648         CHECK_ACCESS(_res_ptr);
19649         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
19650         FREE((void*)_res);
19651         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
19652 }
19653
19654 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
19655         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19656         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
19657         return (int64_t)ret_conv;
19658 }
19659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19660         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
19661         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
19662         return ret_conv;
19663 }
19664
19665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19666         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
19667         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19668         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
19669         return (int64_t)ret_conv;
19670 }
19671
19672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
19673         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19674         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
19675         return (int64_t)ret_conv;
19676 }
19677
19678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19679         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19680         CHECK_ACCESS(e_ptr);
19681         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19682         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19683         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19684         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
19685         return (int64_t)ret_conv;
19686 }
19687
19688 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19689         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
19690         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
19691         return ret_conv;
19692 }
19693
19694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19695         if ((_res & 1) != 0) return;
19696         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19697         CHECK_ACCESS(_res_ptr);
19698         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
19699         FREE((void*)_res);
19700         CResult_NonePaymentSendFailureZ_free(_res_conv);
19701 }
19702
19703 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
19704         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19705         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
19706         return (int64_t)ret_conv;
19707 }
19708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19709         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
19710         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
19711         return ret_conv;
19712 }
19713
19714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19715         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
19716         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19717         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
19718         return (int64_t)ret_conv;
19719 }
19720
19721 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
19722         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19723         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
19724         return ((int64_t)ret_conv);
19725 }
19726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19727         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
19728         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
19729         return ret_conv;
19730 }
19731
19732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19733         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
19734         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19735         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
19736         return ((int64_t)ret_conv);
19737 }
19738
19739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19740         LDKThirtyTwoBytes a_ref;
19741         CHECK((*env)->GetArrayLength(env, a) == 32);
19742         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19743         LDKThirtyTwoBytes b_ref;
19744         CHECK((*env)->GetArrayLength(env, b) == 32);
19745         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19746         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19747         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
19748         return ((int64_t)ret_conv);
19749 }
19750
19751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19752         if ((_res & 1) != 0) return;
19753         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19754         CHECK_ACCESS(_res_ptr);
19755         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
19756         FREE((void*)_res);
19757         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
19758 }
19759
19760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19761         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19762         CHECK_ACCESS(o_ptr);
19763         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
19764         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
19765         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19766         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
19767         return (int64_t)ret_conv;
19768 }
19769
19770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19771         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19772         CHECK_ACCESS(e_ptr);
19773         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19774         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19775         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19776         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
19777         return (int64_t)ret_conv;
19778 }
19779
19780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19781         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
19782         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
19783         return ret_conv;
19784 }
19785
19786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19787         if ((_res & 1) != 0) return;
19788         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19789         CHECK_ACCESS(_res_ptr);
19790         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
19791         FREE((void*)_res);
19792         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
19793 }
19794
19795 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
19796         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19797         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
19798         return (int64_t)ret_conv;
19799 }
19800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19801         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
19802         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
19803         return ret_conv;
19804 }
19805
19806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19807         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
19808         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19809         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
19810         return (int64_t)ret_conv;
19811 }
19812
19813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19814         LDKCVec_ThirtyTwoBytesZ _res_constr;
19815         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19816         if (_res_constr.datalen > 0)
19817                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
19818         else
19819                 _res_constr.data = NULL;
19820         for (size_t i = 0; i < _res_constr.datalen; i++) {
19821                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19822                 LDKThirtyTwoBytes _res_conv_8_ref;
19823                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19824                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19825                 _res_constr.data[i] = _res_conv_8_ref;
19826         }
19827         CVec_ThirtyTwoBytesZ_free(_res_constr);
19828 }
19829
19830 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
19831         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19832         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
19833         return ((int64_t)ret_conv);
19834 }
19835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19836         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
19837         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
19838         return ret_conv;
19839 }
19840
19841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19842         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
19843         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19844         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
19845         return ((int64_t)ret_conv);
19846 }
19847
19848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19849         LDKThirtyTwoBytes a_ref;
19850         CHECK((*env)->GetArrayLength(env, a) == 32);
19851         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19852         LDKThirtyTwoBytes b_ref;
19853         CHECK((*env)->GetArrayLength(env, b) == 32);
19854         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19855         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19856         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
19857         return ((int64_t)ret_conv);
19858 }
19859
19860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19861         if ((_res & 1) != 0) return;
19862         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19863         CHECK_ACCESS(_res_ptr);
19864         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
19865         FREE((void*)_res);
19866         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
19867 }
19868
19869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19870         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19871         CHECK_ACCESS(o_ptr);
19872         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19873         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19874         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19875         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
19876         return (int64_t)ret_conv;
19877 }
19878
19879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
19880         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19881         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
19882         return (int64_t)ret_conv;
19883 }
19884
19885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19886         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
19887         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
19888         return ret_conv;
19889 }
19890
19891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19892         if ((_res & 1) != 0) return;
19893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19894         CHECK_ACCESS(_res_ptr);
19895         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
19896         FREE((void*)_res);
19897         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
19898 }
19899
19900 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
19901         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19902         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
19903         return (int64_t)ret_conv;
19904 }
19905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19906         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
19907         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
19908         return ret_conv;
19909 }
19910
19911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19912         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
19913         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19914         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
19915         return (int64_t)ret_conv;
19916 }
19917
19918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19919         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19920         CHECK_ACCESS(o_ptr);
19921         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19922         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19923         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19924         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
19925         return (int64_t)ret_conv;
19926 }
19927
19928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19929         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19930         CHECK_ACCESS(e_ptr);
19931         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19932         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19933         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19934         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
19935         return (int64_t)ret_conv;
19936 }
19937
19938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19939         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
19940         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
19941         return ret_conv;
19942 }
19943
19944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19945         if ((_res & 1) != 0) return;
19946         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19947         CHECK_ACCESS(_res_ptr);
19948         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
19949         FREE((void*)_res);
19950         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
19951 }
19952
19953 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
19954         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19955         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
19956         return (int64_t)ret_conv;
19957 }
19958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19959         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
19960         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
19961         return ret_conv;
19962 }
19963
19964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19965         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
19966         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19967         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
19968         return (int64_t)ret_conv;
19969 }
19970
19971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19972         LDKThirtyTwoBytes o_ref;
19973         CHECK((*env)->GetArrayLength(env, o) == 32);
19974         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19975         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19976         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
19977         return (int64_t)ret_conv;
19978 }
19979
19980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
19981         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19982         *ret_conv = CResult_PaymentSecretNoneZ_err();
19983         return (int64_t)ret_conv;
19984 }
19985
19986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19987         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
19988         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
19989         return ret_conv;
19990 }
19991
19992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19993         if ((_res & 1) != 0) return;
19994         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19995         CHECK_ACCESS(_res_ptr);
19996         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
19997         FREE((void*)_res);
19998         CResult_PaymentSecretNoneZ_free(_res_conv);
19999 }
20000
20001 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
20002         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20003         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
20004         return (int64_t)ret_conv;
20005 }
20006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20007         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
20008         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
20009         return ret_conv;
20010 }
20011
20012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20013         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
20014         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20015         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
20016         return (int64_t)ret_conv;
20017 }
20018
20019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20020         LDKThirtyTwoBytes o_ref;
20021         CHECK((*env)->GetArrayLength(env, o) == 32);
20022         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20023         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20024         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
20025         return (int64_t)ret_conv;
20026 }
20027
20028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20029         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20030         CHECK_ACCESS(e_ptr);
20031         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20032         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
20033         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20034         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
20035         return (int64_t)ret_conv;
20036 }
20037
20038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20039         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
20040         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
20041         return ret_conv;
20042 }
20043
20044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20045         if ((_res & 1) != 0) return;
20046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20047         CHECK_ACCESS(_res_ptr);
20048         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
20049         FREE((void*)_res);
20050         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
20051 }
20052
20053 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
20054         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20055         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
20056         return (int64_t)ret_conv;
20057 }
20058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20059         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
20060         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
20061         return ret_conv;
20062 }
20063
20064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20065         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
20066         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20067         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
20068         return (int64_t)ret_conv;
20069 }
20070
20071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20072         LDKThirtyTwoBytes o_ref;
20073         CHECK((*env)->GetArrayLength(env, o) == 32);
20074         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20075         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20076         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
20077         return (int64_t)ret_conv;
20078 }
20079
20080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20081         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20082         CHECK_ACCESS(e_ptr);
20083         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20084         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
20085         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20086         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
20087         return (int64_t)ret_conv;
20088 }
20089
20090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20091         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
20092         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
20093         return ret_conv;
20094 }
20095
20096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20097         if ((_res & 1) != 0) return;
20098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20099         CHECK_ACCESS(_res_ptr);
20100         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
20101         FREE((void*)_res);
20102         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
20103 }
20104
20105 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
20106         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20107         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
20108         return (int64_t)ret_conv;
20109 }
20110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20111         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
20112         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
20113         return ret_conv;
20114 }
20115
20116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20117         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
20118         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20119         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
20120         return (int64_t)ret_conv;
20121 }
20122
20123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20124         LDKCounterpartyForwardingInfo o_conv;
20125         o_conv.inner = (void*)(o & (~1));
20126         o_conv.is_owned = (o & 1) || (o == 0);
20127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20128         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
20129         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20130         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
20131         return (int64_t)ret_conv;
20132 }
20133
20134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20135         LDKDecodeError e_conv;
20136         e_conv.inner = (void*)(e & (~1));
20137         e_conv.is_owned = (e & 1) || (e == 0);
20138         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20139         e_conv = DecodeError_clone(&e_conv);
20140         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20141         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
20142         return (int64_t)ret_conv;
20143 }
20144
20145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20146         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
20147         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
20148         return ret_conv;
20149 }
20150
20151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20152         if ((_res & 1) != 0) return;
20153         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20154         CHECK_ACCESS(_res_ptr);
20155         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
20156         FREE((void*)_res);
20157         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
20158 }
20159
20160 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
20161         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20162         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
20163         return (int64_t)ret_conv;
20164 }
20165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20166         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
20167         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
20168         return ret_conv;
20169 }
20170
20171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20172         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
20173         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20174         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
20175         return (int64_t)ret_conv;
20176 }
20177
20178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20179         LDKChannelCounterparty o_conv;
20180         o_conv.inner = (void*)(o & (~1));
20181         o_conv.is_owned = (o & 1) || (o == 0);
20182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20183         o_conv = ChannelCounterparty_clone(&o_conv);
20184         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20185         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
20186         return (int64_t)ret_conv;
20187 }
20188
20189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20190         LDKDecodeError e_conv;
20191         e_conv.inner = (void*)(e & (~1));
20192         e_conv.is_owned = (e & 1) || (e == 0);
20193         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20194         e_conv = DecodeError_clone(&e_conv);
20195         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20196         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
20197         return (int64_t)ret_conv;
20198 }
20199
20200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20201         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
20202         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
20203         return ret_conv;
20204 }
20205
20206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20207         if ((_res & 1) != 0) return;
20208         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20209         CHECK_ACCESS(_res_ptr);
20210         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
20211         FREE((void*)_res);
20212         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
20213 }
20214
20215 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
20216         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20217         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
20218         return (int64_t)ret_conv;
20219 }
20220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20221         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
20222         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
20223         return ret_conv;
20224 }
20225
20226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20227         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
20228         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20229         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
20230         return (int64_t)ret_conv;
20231 }
20232
20233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20234         LDKChannelDetails o_conv;
20235         o_conv.inner = (void*)(o & (~1));
20236         o_conv.is_owned = (o & 1) || (o == 0);
20237         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20238         o_conv = ChannelDetails_clone(&o_conv);
20239         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20240         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
20241         return (int64_t)ret_conv;
20242 }
20243
20244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20245         LDKDecodeError e_conv;
20246         e_conv.inner = (void*)(e & (~1));
20247         e_conv.is_owned = (e & 1) || (e == 0);
20248         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20249         e_conv = DecodeError_clone(&e_conv);
20250         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20251         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
20252         return (int64_t)ret_conv;
20253 }
20254
20255 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20256         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
20257         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
20258         return ret_conv;
20259 }
20260
20261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20262         if ((_res & 1) != 0) return;
20263         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20264         CHECK_ACCESS(_res_ptr);
20265         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
20266         FREE((void*)_res);
20267         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
20268 }
20269
20270 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
20271         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20272         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
20273         return (int64_t)ret_conv;
20274 }
20275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20276         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
20277         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
20278         return ret_conv;
20279 }
20280
20281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20282         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
20283         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20284         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
20285         return (int64_t)ret_conv;
20286 }
20287
20288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20289         LDKPhantomRouteHints o_conv;
20290         o_conv.inner = (void*)(o & (~1));
20291         o_conv.is_owned = (o & 1) || (o == 0);
20292         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20293         o_conv = PhantomRouteHints_clone(&o_conv);
20294         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20295         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
20296         return (int64_t)ret_conv;
20297 }
20298
20299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20300         LDKDecodeError e_conv;
20301         e_conv.inner = (void*)(e & (~1));
20302         e_conv.is_owned = (e & 1) || (e == 0);
20303         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20304         e_conv = DecodeError_clone(&e_conv);
20305         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20306         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
20307         return (int64_t)ret_conv;
20308 }
20309
20310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20311         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
20312         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
20313         return ret_conv;
20314 }
20315
20316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20317         if ((_res & 1) != 0) return;
20318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20319         CHECK_ACCESS(_res_ptr);
20320         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
20321         FREE((void*)_res);
20322         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
20323 }
20324
20325 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
20326         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20327         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
20328         return (int64_t)ret_conv;
20329 }
20330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20331         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
20332         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
20333         return ret_conv;
20334 }
20335
20336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20337         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
20338         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20339         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
20340         return (int64_t)ret_conv;
20341 }
20342
20343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20344         LDKCVec_ChannelMonitorZ _res_constr;
20345         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20346         if (_res_constr.datalen > 0)
20347                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
20348         else
20349                 _res_constr.data = NULL;
20350         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20351         for (size_t q = 0; q < _res_constr.datalen; q++) {
20352                 int64_t _res_conv_16 = _res_vals[q];
20353                 LDKChannelMonitor _res_conv_16_conv;
20354                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
20355                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
20356                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
20357                 _res_constr.data[q] = _res_conv_16_conv;
20358         }
20359         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20360         CVec_ChannelMonitorZ_free(_res_constr);
20361 }
20362
20363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20364         LDKThirtyTwoBytes a_ref;
20365         CHECK((*env)->GetArrayLength(env, a) == 32);
20366         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20367         LDKChannelManager b_conv;
20368         b_conv.inner = (void*)(b & (~1));
20369         b_conv.is_owned = (b & 1) || (b == 0);
20370         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20371         // WARNING: we need a move here but no clone is available for LDKChannelManager
20372         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
20373         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
20374         return ((int64_t)ret_conv);
20375 }
20376
20377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20378         if ((_res & 1) != 0) return;
20379         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20380         CHECK_ACCESS(_res_ptr);
20381         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
20382         FREE((void*)_res);
20383         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
20384 }
20385
20386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20387         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20388         CHECK_ACCESS(o_ptr);
20389         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
20390         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
20391         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20392         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
20393         return (int64_t)ret_conv;
20394 }
20395
20396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20397         LDKDecodeError e_conv;
20398         e_conv.inner = (void*)(e & (~1));
20399         e_conv.is_owned = (e & 1) || (e == 0);
20400         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20401         e_conv = DecodeError_clone(&e_conv);
20402         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20403         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
20404         return (int64_t)ret_conv;
20405 }
20406
20407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20408         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
20409         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
20410         return ret_conv;
20411 }
20412
20413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20414         if ((_res & 1) != 0) return;
20415         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20416         CHECK_ACCESS(_res_ptr);
20417         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
20418         FREE((void*)_res);
20419         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
20420 }
20421
20422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20423         LDKChannelConfig o_conv;
20424         o_conv.inner = (void*)(o & (~1));
20425         o_conv.is_owned = (o & 1) || (o == 0);
20426         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20427         o_conv = ChannelConfig_clone(&o_conv);
20428         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20429         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
20430         return (int64_t)ret_conv;
20431 }
20432
20433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20434         LDKDecodeError e_conv;
20435         e_conv.inner = (void*)(e & (~1));
20436         e_conv.is_owned = (e & 1) || (e == 0);
20437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20438         e_conv = DecodeError_clone(&e_conv);
20439         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20440         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
20441         return (int64_t)ret_conv;
20442 }
20443
20444 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20445         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
20446         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
20447         return ret_conv;
20448 }
20449
20450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20451         if ((_res & 1) != 0) return;
20452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20453         CHECK_ACCESS(_res_ptr);
20454         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
20455         FREE((void*)_res);
20456         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
20457 }
20458
20459 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
20460         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20461         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
20462         return (int64_t)ret_conv;
20463 }
20464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20465         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
20466         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
20467         return ret_conv;
20468 }
20469
20470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20471         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
20472         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20473         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
20474         return (int64_t)ret_conv;
20475 }
20476
20477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20478         LDKOutPoint o_conv;
20479         o_conv.inner = (void*)(o & (~1));
20480         o_conv.is_owned = (o & 1) || (o == 0);
20481         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20482         o_conv = OutPoint_clone(&o_conv);
20483         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20484         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
20485         return (int64_t)ret_conv;
20486 }
20487
20488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20489         LDKDecodeError e_conv;
20490         e_conv.inner = (void*)(e & (~1));
20491         e_conv.is_owned = (e & 1) || (e == 0);
20492         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20493         e_conv = DecodeError_clone(&e_conv);
20494         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20495         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
20496         return (int64_t)ret_conv;
20497 }
20498
20499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20500         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
20501         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
20502         return ret_conv;
20503 }
20504
20505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20506         if ((_res & 1) != 0) return;
20507         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20508         CHECK_ACCESS(_res_ptr);
20509         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
20510         FREE((void*)_res);
20511         CResult_OutPointDecodeErrorZ_free(_res_conv);
20512 }
20513
20514 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
20515         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20516         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
20517         return (int64_t)ret_conv;
20518 }
20519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20520         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
20521         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
20522         return ret_conv;
20523 }
20524
20525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20526         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
20527         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20528         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
20529         return (int64_t)ret_conv;
20530 }
20531
20532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20533         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20534         CHECK_ACCESS(o_ptr);
20535         LDKType o_conv = *(LDKType*)(o_ptr);
20536         if (o_conv.free == LDKType_JCalls_free) {
20537                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20538                 LDKType_JCalls_cloned(&o_conv);
20539         }
20540         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20541         *ret_copy = COption_TypeZ_some(o_conv);
20542         int64_t ret_ref = (uintptr_t)ret_copy;
20543         return ret_ref;
20544 }
20545
20546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
20547         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20548         *ret_copy = COption_TypeZ_none();
20549         int64_t ret_ref = (uintptr_t)ret_copy;
20550         return ret_ref;
20551 }
20552
20553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20554         if ((_res & 1) != 0) return;
20555         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20556         CHECK_ACCESS(_res_ptr);
20557         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
20558         FREE((void*)_res);
20559         COption_TypeZ_free(_res_conv);
20560 }
20561
20562 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
20563         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20564         *ret_copy = COption_TypeZ_clone(arg);
20565 int64_t ret_ref = (uintptr_t)ret_copy;
20566         return ret_ref;
20567 }
20568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20569         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
20570         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
20571         return ret_conv;
20572 }
20573
20574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20575         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
20576         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20577         *ret_copy = COption_TypeZ_clone(orig_conv);
20578         int64_t ret_ref = (uintptr_t)ret_copy;
20579         return ret_ref;
20580 }
20581
20582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20583         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20584         CHECK_ACCESS(o_ptr);
20585         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
20586         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
20587         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20588         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
20589         return (int64_t)ret_conv;
20590 }
20591
20592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20593         LDKDecodeError e_conv;
20594         e_conv.inner = (void*)(e & (~1));
20595         e_conv.is_owned = (e & 1) || (e == 0);
20596         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20597         e_conv = DecodeError_clone(&e_conv);
20598         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20599         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
20600         return (int64_t)ret_conv;
20601 }
20602
20603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20604         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
20605         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
20606         return ret_conv;
20607 }
20608
20609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20610         if ((_res & 1) != 0) return;
20611         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20612         CHECK_ACCESS(_res_ptr);
20613         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
20614         FREE((void*)_res);
20615         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
20616 }
20617
20618 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
20619         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20620         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
20621         return (int64_t)ret_conv;
20622 }
20623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20624         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
20625         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
20626         return ret_conv;
20627 }
20628
20629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20630         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
20631         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20632         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
20633         return (int64_t)ret_conv;
20634 }
20635
20636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20637         LDKThirtyTwoBytes o_ref;
20638         CHECK((*env)->GetArrayLength(env, o) == 32);
20639         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20640         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20641         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
20642         return (int64_t)ret_conv;
20643 }
20644
20645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20646         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20647         CHECK_ACCESS(e_ptr);
20648         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
20649         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
20650         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20651         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
20652         return (int64_t)ret_conv;
20653 }
20654
20655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20656         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
20657         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
20658         return ret_conv;
20659 }
20660
20661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20662         if ((_res & 1) != 0) return;
20663         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20664         CHECK_ACCESS(_res_ptr);
20665         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
20666         FREE((void*)_res);
20667         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
20668 }
20669
20670 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
20671         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20672         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
20673         return (int64_t)ret_conv;
20674 }
20675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20676         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
20677         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
20678         return ret_conv;
20679 }
20680
20681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20682         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
20683         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20684         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
20685         return (int64_t)ret_conv;
20686 }
20687
20688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
20689         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
20690         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20691         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
20692         return (int64_t)ret_conv;
20693 }
20694
20695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20696         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20697         CHECK_ACCESS(e_ptr);
20698         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20699         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20700         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20701         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
20702         return (int64_t)ret_conv;
20703 }
20704
20705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20706         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
20707         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
20708         return ret_conv;
20709 }
20710
20711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20712         if ((_res & 1) != 0) return;
20713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20714         CHECK_ACCESS(_res_ptr);
20715         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
20716         FREE((void*)_res);
20717         CResult_SiPrefixParseErrorZ_free(_res_conv);
20718 }
20719
20720 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
20721         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20722         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
20723         return (int64_t)ret_conv;
20724 }
20725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20726         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
20727         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
20728         return ret_conv;
20729 }
20730
20731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20732         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
20733         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20734         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
20735         return (int64_t)ret_conv;
20736 }
20737
20738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20739         LDKInvoice o_conv;
20740         o_conv.inner = (void*)(o & (~1));
20741         o_conv.is_owned = (o & 1) || (o == 0);
20742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20743         o_conv = Invoice_clone(&o_conv);
20744         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20745         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
20746         return (int64_t)ret_conv;
20747 }
20748
20749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20750         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20751         CHECK_ACCESS(e_ptr);
20752         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
20753         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
20754         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20755         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
20756         return (int64_t)ret_conv;
20757 }
20758
20759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20760         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
20761         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
20762         return ret_conv;
20763 }
20764
20765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20766         if ((_res & 1) != 0) return;
20767         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20768         CHECK_ACCESS(_res_ptr);
20769         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
20770         FREE((void*)_res);
20771         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
20772 }
20773
20774 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
20775         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20776         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
20777         return (int64_t)ret_conv;
20778 }
20779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20780         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
20781         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
20782         return ret_conv;
20783 }
20784
20785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20786         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
20787         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20788         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
20789         return (int64_t)ret_conv;
20790 }
20791
20792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20793         LDKSignedRawInvoice o_conv;
20794         o_conv.inner = (void*)(o & (~1));
20795         o_conv.is_owned = (o & 1) || (o == 0);
20796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20797         o_conv = SignedRawInvoice_clone(&o_conv);
20798         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20799         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
20800         return (int64_t)ret_conv;
20801 }
20802
20803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20804         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20805         CHECK_ACCESS(e_ptr);
20806         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20807         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20808         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20809         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
20810         return (int64_t)ret_conv;
20811 }
20812
20813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20814         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
20815         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
20816         return ret_conv;
20817 }
20818
20819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20820         if ((_res & 1) != 0) return;
20821         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20822         CHECK_ACCESS(_res_ptr);
20823         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
20824         FREE((void*)_res);
20825         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
20826 }
20827
20828 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
20829         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20830         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
20831         return (int64_t)ret_conv;
20832 }
20833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20834         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
20835         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
20836         return ret_conv;
20837 }
20838
20839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20840         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
20841         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20842         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
20843         return (int64_t)ret_conv;
20844 }
20845
20846 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
20847         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20848         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
20849         return ((int64_t)ret_conv);
20850 }
20851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20852         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
20853         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
20854         return ret_conv;
20855 }
20856
20857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20858         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
20859         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20860         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
20861         return ((int64_t)ret_conv);
20862 }
20863
20864 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) {
20865         LDKRawInvoice a_conv;
20866         a_conv.inner = (void*)(a & (~1));
20867         a_conv.is_owned = (a & 1) || (a == 0);
20868         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20869         a_conv = RawInvoice_clone(&a_conv);
20870         LDKThirtyTwoBytes b_ref;
20871         CHECK((*env)->GetArrayLength(env, b) == 32);
20872         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20873         LDKInvoiceSignature c_conv;
20874         c_conv.inner = (void*)(c & (~1));
20875         c_conv.is_owned = (c & 1) || (c == 0);
20876         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
20877         c_conv = InvoiceSignature_clone(&c_conv);
20878         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20879         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
20880         return ((int64_t)ret_conv);
20881 }
20882
20883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20884         if ((_res & 1) != 0) return;
20885         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20886         CHECK_ACCESS(_res_ptr);
20887         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
20888         FREE((void*)_res);
20889         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
20890 }
20891
20892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20893         LDKPayeePubKey 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 = PayeePubKey_clone(&o_conv);
20898         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20899         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
20900         return (int64_t)ret_conv;
20901 }
20902
20903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20904         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
20905         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20906         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
20907         return (int64_t)ret_conv;
20908 }
20909
20910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20911         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
20912         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
20913         return ret_conv;
20914 }
20915
20916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20917         if ((_res & 1) != 0) return;
20918         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20919         CHECK_ACCESS(_res_ptr);
20920         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
20921         FREE((void*)_res);
20922         CResult_PayeePubKeyErrorZ_free(_res_conv);
20923 }
20924
20925 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
20926         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20927         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
20928         return (int64_t)ret_conv;
20929 }
20930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20931         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
20932         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
20933         return ret_conv;
20934 }
20935
20936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20937         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
20938         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20939         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
20940         return (int64_t)ret_conv;
20941 }
20942
20943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20944         LDKCVec_PrivateRouteZ _res_constr;
20945         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20946         if (_res_constr.datalen > 0)
20947                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
20948         else
20949                 _res_constr.data = NULL;
20950         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20951         for (size_t o = 0; o < _res_constr.datalen; o++) {
20952                 int64_t _res_conv_14 = _res_vals[o];
20953                 LDKPrivateRoute _res_conv_14_conv;
20954                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
20955                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
20956                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
20957                 _res_constr.data[o] = _res_conv_14_conv;
20958         }
20959         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20960         CVec_PrivateRouteZ_free(_res_constr);
20961 }
20962
20963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20964         LDKPositiveTimestamp o_conv;
20965         o_conv.inner = (void*)(o & (~1));
20966         o_conv.is_owned = (o & 1) || (o == 0);
20967         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20968         o_conv = PositiveTimestamp_clone(&o_conv);
20969         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20970         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
20971         return (int64_t)ret_conv;
20972 }
20973
20974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20975         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20976         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20977         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
20978         return (int64_t)ret_conv;
20979 }
20980
20981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20982         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
20983         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
20984         return ret_conv;
20985 }
20986
20987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20988         if ((_res & 1) != 0) return;
20989         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20990         CHECK_ACCESS(_res_ptr);
20991         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
20992         FREE((void*)_res);
20993         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
20994 }
20995
20996 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
20997         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20998         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
20999         return (int64_t)ret_conv;
21000 }
21001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21002         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
21003         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
21004         return ret_conv;
21005 }
21006
21007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21008         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
21009         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21010         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
21011         return (int64_t)ret_conv;
21012 }
21013
21014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
21015         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21016         *ret_conv = CResult_NoneSemanticErrorZ_ok();
21017         return (int64_t)ret_conv;
21018 }
21019
21020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21021         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21022         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21023         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
21024         return (int64_t)ret_conv;
21025 }
21026
21027 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21028         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
21029         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
21030         return ret_conv;
21031 }
21032
21033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_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_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
21038         FREE((void*)_res);
21039         CResult_NoneSemanticErrorZ_free(_res_conv);
21040 }
21041
21042 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
21043         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21044         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
21045         return (int64_t)ret_conv;
21046 }
21047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21048         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
21049         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
21050         return ret_conv;
21051 }
21052
21053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21054         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
21055         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21056         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
21057         return (int64_t)ret_conv;
21058 }
21059
21060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21061         LDKInvoice o_conv;
21062         o_conv.inner = (void*)(o & (~1));
21063         o_conv.is_owned = (o & 1) || (o == 0);
21064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21065         o_conv = Invoice_clone(&o_conv);
21066         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21067         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
21068         return (int64_t)ret_conv;
21069 }
21070
21071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21072         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21073         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21074         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
21075         return (int64_t)ret_conv;
21076 }
21077
21078 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21079         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
21080         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
21081         return ret_conv;
21082 }
21083
21084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21085         if ((_res & 1) != 0) return;
21086         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21087         CHECK_ACCESS(_res_ptr);
21088         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
21089         FREE((void*)_res);
21090         CResult_InvoiceSemanticErrorZ_free(_res_conv);
21091 }
21092
21093 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
21094         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21095         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
21096         return (int64_t)ret_conv;
21097 }
21098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21099         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
21100         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
21101         return ret_conv;
21102 }
21103
21104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21105         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
21106         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21107         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
21108         return (int64_t)ret_conv;
21109 }
21110
21111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21112         LDKDescription o_conv;
21113         o_conv.inner = (void*)(o & (~1));
21114         o_conv.is_owned = (o & 1) || (o == 0);
21115         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21116         o_conv = Description_clone(&o_conv);
21117         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21118         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
21119         return (int64_t)ret_conv;
21120 }
21121
21122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21123         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21124         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21125         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
21126         return (int64_t)ret_conv;
21127 }
21128
21129 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21130         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
21131         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
21132         return ret_conv;
21133 }
21134
21135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21136         if ((_res & 1) != 0) return;
21137         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21138         CHECK_ACCESS(_res_ptr);
21139         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
21140         FREE((void*)_res);
21141         CResult_DescriptionCreationErrorZ_free(_res_conv);
21142 }
21143
21144 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
21145         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21146         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
21147         return (int64_t)ret_conv;
21148 }
21149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21150         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
21151         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
21152         return ret_conv;
21153 }
21154
21155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21156         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
21157         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21158         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
21159         return (int64_t)ret_conv;
21160 }
21161
21162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21163         LDKPrivateRoute o_conv;
21164         o_conv.inner = (void*)(o & (~1));
21165         o_conv.is_owned = (o & 1) || (o == 0);
21166         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21167         o_conv = PrivateRoute_clone(&o_conv);
21168         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21169         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
21170         return (int64_t)ret_conv;
21171 }
21172
21173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21174         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21175         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21176         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
21177         return (int64_t)ret_conv;
21178 }
21179
21180 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21181         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
21182         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
21183         return ret_conv;
21184 }
21185
21186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21187         if ((_res & 1) != 0) return;
21188         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21189         CHECK_ACCESS(_res_ptr);
21190         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
21191         FREE((void*)_res);
21192         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
21193 }
21194
21195 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
21196         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21197         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
21198         return (int64_t)ret_conv;
21199 }
21200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21201         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
21202         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
21203         return ret_conv;
21204 }
21205
21206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21207         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
21208         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21209         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
21210         return (int64_t)ret_conv;
21211 }
21212
21213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
21214         LDKStr o_conv = java_to_owned_str(env, o);
21215         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21216         *ret_conv = CResult_StringErrorZ_ok(o_conv);
21217         return (int64_t)ret_conv;
21218 }
21219
21220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21221         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
21222         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21223         *ret_conv = CResult_StringErrorZ_err(e_conv);
21224         return (int64_t)ret_conv;
21225 }
21226
21227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21228         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
21229         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
21230         return ret_conv;
21231 }
21232
21233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21234         if ((_res & 1) != 0) return;
21235         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21236         CHECK_ACCESS(_res_ptr);
21237         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
21238         FREE((void*)_res);
21239         CResult_StringErrorZ_free(_res_conv);
21240 }
21241
21242 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
21243         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21244         *ret_conv = CResult_StringErrorZ_clone(arg);
21245         return (int64_t)ret_conv;
21246 }
21247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21248         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
21249         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
21250         return ret_conv;
21251 }
21252
21253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21254         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
21255         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21256         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
21257         return (int64_t)ret_conv;
21258 }
21259
21260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21261         LDKChannelMonitorUpdate o_conv;
21262         o_conv.inner = (void*)(o & (~1));
21263         o_conv.is_owned = (o & 1) || (o == 0);
21264         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21265         o_conv = ChannelMonitorUpdate_clone(&o_conv);
21266         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21267         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
21268         return (int64_t)ret_conv;
21269 }
21270
21271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21272         LDKDecodeError e_conv;
21273         e_conv.inner = (void*)(e & (~1));
21274         e_conv.is_owned = (e & 1) || (e == 0);
21275         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21276         e_conv = DecodeError_clone(&e_conv);
21277         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21278         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
21279         return (int64_t)ret_conv;
21280 }
21281
21282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21283         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
21284         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
21285         return ret_conv;
21286 }
21287
21288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21289         if ((_res & 1) != 0) return;
21290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21291         CHECK_ACCESS(_res_ptr);
21292         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
21293         FREE((void*)_res);
21294         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
21295 }
21296
21297 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
21298         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21299         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
21300         return (int64_t)ret_conv;
21301 }
21302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21303         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
21304         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
21305         return ret_conv;
21306 }
21307
21308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21309         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
21310         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21311         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
21312         return (int64_t)ret_conv;
21313 }
21314
21315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21316         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21317         CHECK_ACCESS(o_ptr);
21318         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
21319         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
21320         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21321         *ret_copy = COption_MonitorEventZ_some(o_conv);
21322         int64_t ret_ref = (uintptr_t)ret_copy;
21323         return ret_ref;
21324 }
21325
21326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
21327         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21328         *ret_copy = COption_MonitorEventZ_none();
21329         int64_t ret_ref = (uintptr_t)ret_copy;
21330         return ret_ref;
21331 }
21332
21333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_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         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
21338         FREE((void*)_res);
21339         COption_MonitorEventZ_free(_res_conv);
21340 }
21341
21342 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
21343         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21344         *ret_copy = COption_MonitorEventZ_clone(arg);
21345 int64_t ret_ref = (uintptr_t)ret_copy;
21346         return ret_ref;
21347 }
21348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21349         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
21350         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
21351         return ret_conv;
21352 }
21353
21354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21355         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
21356         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21357         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
21358         int64_t ret_ref = (uintptr_t)ret_copy;
21359         return ret_ref;
21360 }
21361
21362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21363         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21364         CHECK_ACCESS(o_ptr);
21365         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
21366         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
21367         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21368         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
21369         return (int64_t)ret_conv;
21370 }
21371
21372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21373         LDKDecodeError e_conv;
21374         e_conv.inner = (void*)(e & (~1));
21375         e_conv.is_owned = (e & 1) || (e == 0);
21376         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21377         e_conv = DecodeError_clone(&e_conv);
21378         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21379         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
21380         return (int64_t)ret_conv;
21381 }
21382
21383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21384         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
21385         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
21386         return ret_conv;
21387 }
21388
21389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21390         if ((_res & 1) != 0) return;
21391         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21392         CHECK_ACCESS(_res_ptr);
21393         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
21394         FREE((void*)_res);
21395         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
21396 }
21397
21398 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
21399         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21400         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
21401         return (int64_t)ret_conv;
21402 }
21403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21404         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
21405         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
21406         return ret_conv;
21407 }
21408
21409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21410         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
21411         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21412         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
21413         return (int64_t)ret_conv;
21414 }
21415
21416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21417         LDKHTLCUpdate o_conv;
21418         o_conv.inner = (void*)(o & (~1));
21419         o_conv.is_owned = (o & 1) || (o == 0);
21420         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21421         o_conv = HTLCUpdate_clone(&o_conv);
21422         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21423         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
21424         return (int64_t)ret_conv;
21425 }
21426
21427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21428         LDKDecodeError e_conv;
21429         e_conv.inner = (void*)(e & (~1));
21430         e_conv.is_owned = (e & 1) || (e == 0);
21431         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21432         e_conv = DecodeError_clone(&e_conv);
21433         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21434         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
21435         return (int64_t)ret_conv;
21436 }
21437
21438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21439         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
21440         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
21441         return ret_conv;
21442 }
21443
21444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21445         if ((_res & 1) != 0) return;
21446         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21447         CHECK_ACCESS(_res_ptr);
21448         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
21449         FREE((void*)_res);
21450         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
21451 }
21452
21453 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
21454         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21455         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
21456         return (int64_t)ret_conv;
21457 }
21458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21459         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
21460         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
21461         return ret_conv;
21462 }
21463
21464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21465         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
21466         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21467         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
21468         return (int64_t)ret_conv;
21469 }
21470
21471 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
21472         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21473         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
21474         return ((int64_t)ret_conv);
21475 }
21476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21477         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
21478         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
21479         return ret_conv;
21480 }
21481
21482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21483         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
21484         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21485         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
21486         return ((int64_t)ret_conv);
21487 }
21488
21489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
21490         LDKOutPoint a_conv;
21491         a_conv.inner = (void*)(a & (~1));
21492         a_conv.is_owned = (a & 1) || (a == 0);
21493         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21494         a_conv = OutPoint_clone(&a_conv);
21495         LDKCVec_u8Z b_ref;
21496         b_ref.datalen = (*env)->GetArrayLength(env, b);
21497         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21498         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21499         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21500         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
21501         return ((int64_t)ret_conv);
21502 }
21503
21504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21505         if ((_res & 1) != 0) return;
21506         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21507         CHECK_ACCESS(_res_ptr);
21508         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
21509         FREE((void*)_res);
21510         C2Tuple_OutPointScriptZ_free(_res_conv);
21511 }
21512
21513 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
21514         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21515         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
21516         return ((int64_t)ret_conv);
21517 }
21518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21519         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
21520         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
21521         return ret_conv;
21522 }
21523
21524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21525         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
21526         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21527         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
21528         return ((int64_t)ret_conv);
21529 }
21530
21531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
21532         LDKCVec_u8Z b_ref;
21533         b_ref.datalen = (*env)->GetArrayLength(env, b);
21534         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21535         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21536         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21537         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
21538         return ((int64_t)ret_conv);
21539 }
21540
21541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21542         if ((_res & 1) != 0) return;
21543         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21544         CHECK_ACCESS(_res_ptr);
21545         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
21546         FREE((void*)_res);
21547         C2Tuple_u32ScriptZ_free(_res_conv);
21548 }
21549
21550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21551         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
21552         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21553         if (_res_constr.datalen > 0)
21554                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21555         else
21556                 _res_constr.data = NULL;
21557         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21558         for (size_t v = 0; v < _res_constr.datalen; v++) {
21559                 int64_t _res_conv_21 = _res_vals[v];
21560                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
21561                 CHECK_ACCESS(_res_conv_21_ptr);
21562                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
21563                 FREE((void*)_res_conv_21);
21564                 _res_constr.data[v] = _res_conv_21_conv;
21565         }
21566         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21567         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
21568 }
21569
21570 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
21571         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21572         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
21573         return ((int64_t)ret_conv);
21574 }
21575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21576         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
21577         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
21578         return ret_conv;
21579 }
21580
21581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21582         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
21583         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21584         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
21585         return ((int64_t)ret_conv);
21586 }
21587
21588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21589         LDKThirtyTwoBytes a_ref;
21590         CHECK((*env)->GetArrayLength(env, a) == 32);
21591         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21592         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
21593         b_constr.datalen = (*env)->GetArrayLength(env, b);
21594         if (b_constr.datalen > 0)
21595                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21596         else
21597                 b_constr.data = NULL;
21598         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21599         for (size_t v = 0; v < b_constr.datalen; v++) {
21600                 int64_t b_conv_21 = b_vals[v];
21601                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
21602                 CHECK_ACCESS(b_conv_21_ptr);
21603                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
21604                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
21605                 b_constr.data[v] = b_conv_21_conv;
21606         }
21607         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21608         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21609         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
21610         return ((int64_t)ret_conv);
21611 }
21612
21613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21614         if ((_res & 1) != 0) return;
21615         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21616         CHECK_ACCESS(_res_ptr);
21617         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
21618         FREE((void*)_res);
21619         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
21620 }
21621
21622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21623         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
21624         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21625         if (_res_constr.datalen > 0)
21626                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
21627         else
21628                 _res_constr.data = NULL;
21629         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21630         for (size_t o = 0; o < _res_constr.datalen; o++) {
21631                 int64_t _res_conv_40 = _res_vals[o];
21632                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
21633                 CHECK_ACCESS(_res_conv_40_ptr);
21634                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
21635                 FREE((void*)_res_conv_40);
21636                 _res_constr.data[o] = _res_conv_40_conv;
21637         }
21638         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21639         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
21640 }
21641
21642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21643         LDKCVec_EventZ _res_constr;
21644         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21645         if (_res_constr.datalen > 0)
21646                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
21647         else
21648                 _res_constr.data = NULL;
21649         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21650         for (size_t h = 0; h < _res_constr.datalen; h++) {
21651                 int64_t _res_conv_7 = _res_vals[h];
21652                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
21653                 CHECK_ACCESS(_res_conv_7_ptr);
21654                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
21655                 FREE((void*)_res_conv_7);
21656                 _res_constr.data[h] = _res_conv_7_conv;
21657         }
21658         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21659         CVec_EventZ_free(_res_constr);
21660 }
21661
21662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21663         LDKCVec_TransactionZ _res_constr;
21664         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21665         if (_res_constr.datalen > 0)
21666                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
21667         else
21668                 _res_constr.data = NULL;
21669         for (size_t i = 0; i < _res_constr.datalen; i++) {
21670                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21671                 LDKTransaction _res_conv_8_ref;
21672                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
21673                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
21674                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
21675                 _res_conv_8_ref.data_is_owned = true;
21676                 _res_constr.data[i] = _res_conv_8_ref;
21677         }
21678         CVec_TransactionZ_free(_res_constr);
21679 }
21680
21681 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
21682         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21683         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
21684         return ((int64_t)ret_conv);
21685 }
21686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21687         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
21688         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
21689         return ret_conv;
21690 }
21691
21692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21693         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
21694         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21695         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
21696         return ((int64_t)ret_conv);
21697 }
21698
21699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
21700         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21701         CHECK_ACCESS(b_ptr);
21702         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
21703         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
21704         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21705         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
21706         return ((int64_t)ret_conv);
21707 }
21708
21709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21710         if ((_res & 1) != 0) return;
21711         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21712         CHECK_ACCESS(_res_ptr);
21713         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
21714         FREE((void*)_res);
21715         C2Tuple_u32TxOutZ_free(_res_conv);
21716 }
21717
21718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21719         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
21720         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21721         if (_res_constr.datalen > 0)
21722                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21723         else
21724                 _res_constr.data = NULL;
21725         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21726         for (size_t u = 0; u < _res_constr.datalen; u++) {
21727                 int64_t _res_conv_20 = _res_vals[u];
21728                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
21729                 CHECK_ACCESS(_res_conv_20_ptr);
21730                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
21731                 FREE((void*)_res_conv_20);
21732                 _res_constr.data[u] = _res_conv_20_conv;
21733         }
21734         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21735         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
21736 }
21737
21738 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
21739         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21740         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
21741         return ((int64_t)ret_conv);
21742 }
21743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21744         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
21745         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
21746         return ret_conv;
21747 }
21748
21749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21750         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
21751         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21752         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
21753         return ((int64_t)ret_conv);
21754 }
21755
21756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21757         LDKThirtyTwoBytes a_ref;
21758         CHECK((*env)->GetArrayLength(env, a) == 32);
21759         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21760         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
21761         b_constr.datalen = (*env)->GetArrayLength(env, b);
21762         if (b_constr.datalen > 0)
21763                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21764         else
21765                 b_constr.data = NULL;
21766         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21767         for (size_t u = 0; u < b_constr.datalen; u++) {
21768                 int64_t b_conv_20 = b_vals[u];
21769                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
21770                 CHECK_ACCESS(b_conv_20_ptr);
21771                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
21772                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
21773                 b_constr.data[u] = b_conv_20_conv;
21774         }
21775         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21776         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21777         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
21778         return ((int64_t)ret_conv);
21779 }
21780
21781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21782         if ((_res & 1) != 0) return;
21783         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21784         CHECK_ACCESS(_res_ptr);
21785         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
21786         FREE((void*)_res);
21787         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
21788 }
21789
21790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21791         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
21792         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21793         if (_res_constr.datalen > 0)
21794                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
21795         else
21796                 _res_constr.data = NULL;
21797         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21798         for (size_t n = 0; n < _res_constr.datalen; n++) {
21799                 int64_t _res_conv_39 = _res_vals[n];
21800                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
21801                 CHECK_ACCESS(_res_conv_39_ptr);
21802                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
21803                 FREE((void*)_res_conv_39);
21804                 _res_constr.data[n] = _res_conv_39_conv;
21805         }
21806         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21807         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
21808 }
21809
21810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21811         LDKCVec_BalanceZ _res_constr;
21812         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21813         if (_res_constr.datalen > 0)
21814                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
21815         else
21816                 _res_constr.data = NULL;
21817         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21818         for (size_t j = 0; j < _res_constr.datalen; j++) {
21819                 int64_t _res_conv_9 = _res_vals[j];
21820                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
21821                 CHECK_ACCESS(_res_conv_9_ptr);
21822                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
21823                 FREE((void*)_res_conv_9);
21824                 _res_constr.data[j] = _res_conv_9_conv;
21825         }
21826         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21827         CVec_BalanceZ_free(_res_constr);
21828 }
21829
21830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21831         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21832         CHECK_ACCESS(o_ptr);
21833         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
21834         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
21835         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21836         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
21837         return (int64_t)ret_conv;
21838 }
21839
21840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21841         LDKDecodeError e_conv;
21842         e_conv.inner = (void*)(e & (~1));
21843         e_conv.is_owned = (e & 1) || (e == 0);
21844         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21845         e_conv = DecodeError_clone(&e_conv);
21846         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21847         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
21848         return (int64_t)ret_conv;
21849 }
21850
21851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21852         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
21853         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
21854         return ret_conv;
21855 }
21856
21857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21858         if ((_res & 1) != 0) return;
21859         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21860         CHECK_ACCESS(_res_ptr);
21861         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
21862         FREE((void*)_res);
21863         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
21864 }
21865
21866 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
21867         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21868         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
21869         return (int64_t)ret_conv;
21870 }
21871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21872         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
21873         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
21874         return ret_conv;
21875 }
21876
21877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21878         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
21879         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21880         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
21881         return (int64_t)ret_conv;
21882 }
21883
21884 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
21885         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21886         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
21887         return ((int64_t)ret_conv);
21888 }
21889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21890         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
21891         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
21892         return ret_conv;
21893 }
21894
21895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21896         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
21897         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21898         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
21899         return ((int64_t)ret_conv);
21900 }
21901
21902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21903         LDKPublicKey a_ref;
21904         CHECK((*env)->GetArrayLength(env, a) == 33);
21905         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
21906         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21907         CHECK_ACCESS(b_ptr);
21908         LDKType b_conv = *(LDKType*)(b_ptr);
21909         if (b_conv.free == LDKType_JCalls_free) {
21910                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21911                 LDKType_JCalls_cloned(&b_conv);
21912         }
21913         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21914         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
21915         return ((int64_t)ret_conv);
21916 }
21917
21918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21919         if ((_res & 1) != 0) return;
21920         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21921         CHECK_ACCESS(_res_ptr);
21922         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
21923         FREE((void*)_res);
21924         C2Tuple_PublicKeyTypeZ_free(_res_conv);
21925 }
21926
21927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21928         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
21929         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21930         if (_res_constr.datalen > 0)
21931                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
21932         else
21933                 _res_constr.data = NULL;
21934         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21935         for (size_t z = 0; z < _res_constr.datalen; z++) {
21936                 int64_t _res_conv_25 = _res_vals[z];
21937                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
21938                 CHECK_ACCESS(_res_conv_25_ptr);
21939                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
21940                 FREE((void*)_res_conv_25);
21941                 _res_constr.data[z] = _res_conv_25_conv;
21942         }
21943         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21944         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
21945 }
21946
21947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21948         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21949         CHECK_ACCESS(o_ptr);
21950         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21951         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21952         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21953         *ret_copy = COption_NetAddressZ_some(o_conv);
21954         int64_t ret_ref = (uintptr_t)ret_copy;
21955         return ret_ref;
21956 }
21957
21958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
21959         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21960         *ret_copy = COption_NetAddressZ_none();
21961         int64_t ret_ref = (uintptr_t)ret_copy;
21962         return ret_ref;
21963 }
21964
21965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21966         if ((_res & 1) != 0) return;
21967         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21968         CHECK_ACCESS(_res_ptr);
21969         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
21970         FREE((void*)_res);
21971         COption_NetAddressZ_free(_res_conv);
21972 }
21973
21974 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
21975         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21976         *ret_copy = COption_NetAddressZ_clone(arg);
21977 int64_t ret_ref = (uintptr_t)ret_copy;
21978         return ret_ref;
21979 }
21980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21981         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
21982         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
21983         return ret_conv;
21984 }
21985
21986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21987         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
21988         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21989         *ret_copy = COption_NetAddressZ_clone(orig_conv);
21990         int64_t ret_ref = (uintptr_t)ret_copy;
21991         return ret_ref;
21992 }
21993
21994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21995         LDKCVec_u8Z o_ref;
21996         o_ref.datalen = (*env)->GetArrayLength(env, o);
21997         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
21998         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21999         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22000         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
22001         return (int64_t)ret_conv;
22002 }
22003
22004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22005         LDKPeerHandleError e_conv;
22006         e_conv.inner = (void*)(e & (~1));
22007         e_conv.is_owned = (e & 1) || (e == 0);
22008         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22009         e_conv = PeerHandleError_clone(&e_conv);
22010         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22011         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
22012         return (int64_t)ret_conv;
22013 }
22014
22015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22016         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
22017         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
22018         return ret_conv;
22019 }
22020
22021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22022         if ((_res & 1) != 0) return;
22023         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22024         CHECK_ACCESS(_res_ptr);
22025         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
22026         FREE((void*)_res);
22027         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
22028 }
22029
22030 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
22031         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22032         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
22033         return (int64_t)ret_conv;
22034 }
22035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22036         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
22037         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
22038         return ret_conv;
22039 }
22040
22041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22042         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
22043         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22044         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
22045         return (int64_t)ret_conv;
22046 }
22047
22048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
22049         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22050         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
22051         return (int64_t)ret_conv;
22052 }
22053
22054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22055         LDKPeerHandleError e_conv;
22056         e_conv.inner = (void*)(e & (~1));
22057         e_conv.is_owned = (e & 1) || (e == 0);
22058         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22059         e_conv = PeerHandleError_clone(&e_conv);
22060         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22061         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
22062         return (int64_t)ret_conv;
22063 }
22064
22065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22066         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
22067         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
22068         return ret_conv;
22069 }
22070
22071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22072         if ((_res & 1) != 0) return;
22073         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22074         CHECK_ACCESS(_res_ptr);
22075         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
22076         FREE((void*)_res);
22077         CResult_NonePeerHandleErrorZ_free(_res_conv);
22078 }
22079
22080 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
22081         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22082         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
22083         return (int64_t)ret_conv;
22084 }
22085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22086         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
22087         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
22088         return ret_conv;
22089 }
22090
22091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22092         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
22093         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22094         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
22095         return (int64_t)ret_conv;
22096 }
22097
22098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
22099         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22100         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
22101         return (int64_t)ret_conv;
22102 }
22103
22104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22105         LDKPeerHandleError e_conv;
22106         e_conv.inner = (void*)(e & (~1));
22107         e_conv.is_owned = (e & 1) || (e == 0);
22108         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22109         e_conv = PeerHandleError_clone(&e_conv);
22110         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22111         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
22112         return (int64_t)ret_conv;
22113 }
22114
22115 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22116         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
22117         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
22118         return ret_conv;
22119 }
22120
22121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22122         if ((_res & 1) != 0) return;
22123         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22124         CHECK_ACCESS(_res_ptr);
22125         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
22126         FREE((void*)_res);
22127         CResult_boolPeerHandleErrorZ_free(_res_conv);
22128 }
22129
22130 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
22131         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22132         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
22133         return (int64_t)ret_conv;
22134 }
22135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22136         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
22137         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
22138         return ret_conv;
22139 }
22140
22141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22142         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
22143         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22144         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
22145         return (int64_t)ret_conv;
22146 }
22147
22148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
22149         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22150         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
22151         return (int64_t)ret_conv;
22152 }
22153
22154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22155         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
22156         CHECK_ACCESS(e_ptr);
22157         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
22158         e_conv = GraphSyncError_clone((LDKGraphSyncError*)(((uintptr_t)e) & ~1));
22159         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22160         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
22161         return (int64_t)ret_conv;
22162 }
22163
22164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22165         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)(o & ~1);
22166         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
22167         return ret_conv;
22168 }
22169
22170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22171         if ((_res & 1) != 0) return;
22172         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22173         CHECK_ACCESS(_res_ptr);
22174         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
22175         FREE((void*)_res);
22176         CResult_u32GraphSyncErrorZ_free(_res_conv);
22177 }
22178
22179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22180         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
22181         CHECK_ACCESS(o_ptr);
22182         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
22183         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
22184         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22185         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
22186         return (int64_t)ret_conv;
22187 }
22188
22189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22190         LDKDecodeError e_conv;
22191         e_conv.inner = (void*)(e & (~1));
22192         e_conv.is_owned = (e & 1) || (e == 0);
22193         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22194         e_conv = DecodeError_clone(&e_conv);
22195         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22196         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
22197         return (int64_t)ret_conv;
22198 }
22199
22200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22201         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
22202         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
22203         return ret_conv;
22204 }
22205
22206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22207         if ((_res & 1) != 0) return;
22208         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22209         CHECK_ACCESS(_res_ptr);
22210         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
22211         FREE((void*)_res);
22212         CResult_NetAddressDecodeErrorZ_free(_res_conv);
22213 }
22214
22215 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
22216         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22217         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
22218         return (int64_t)ret_conv;
22219 }
22220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22221         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
22222         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
22223         return ret_conv;
22224 }
22225
22226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22227         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
22228         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22229         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
22230         return (int64_t)ret_conv;
22231 }
22232
22233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22234         LDKCVec_UpdateAddHTLCZ _res_constr;
22235         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22236         if (_res_constr.datalen > 0)
22237                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
22238         else
22239                 _res_constr.data = NULL;
22240         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22241         for (size_t p = 0; p < _res_constr.datalen; p++) {
22242                 int64_t _res_conv_15 = _res_vals[p];
22243                 LDKUpdateAddHTLC _res_conv_15_conv;
22244                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
22245                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
22246                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
22247                 _res_constr.data[p] = _res_conv_15_conv;
22248         }
22249         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22250         CVec_UpdateAddHTLCZ_free(_res_constr);
22251 }
22252
22253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22254         LDKCVec_UpdateFulfillHTLCZ _res_constr;
22255         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22256         if (_res_constr.datalen > 0)
22257                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
22258         else
22259                 _res_constr.data = NULL;
22260         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22261         for (size_t t = 0; t < _res_constr.datalen; t++) {
22262                 int64_t _res_conv_19 = _res_vals[t];
22263                 LDKUpdateFulfillHTLC _res_conv_19_conv;
22264                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
22265                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
22266                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22267                 _res_constr.data[t] = _res_conv_19_conv;
22268         }
22269         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22270         CVec_UpdateFulfillHTLCZ_free(_res_constr);
22271 }
22272
22273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22274         LDKCVec_UpdateFailHTLCZ _res_constr;
22275         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22276         if (_res_constr.datalen > 0)
22277                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
22278         else
22279                 _res_constr.data = NULL;
22280         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22281         for (size_t q = 0; q < _res_constr.datalen; q++) {
22282                 int64_t _res_conv_16 = _res_vals[q];
22283                 LDKUpdateFailHTLC _res_conv_16_conv;
22284                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
22285                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
22286                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
22287                 _res_constr.data[q] = _res_conv_16_conv;
22288         }
22289         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22290         CVec_UpdateFailHTLCZ_free(_res_constr);
22291 }
22292
22293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22294         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
22295         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22296         if (_res_constr.datalen > 0)
22297                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
22298         else
22299                 _res_constr.data = NULL;
22300         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22301         for (size_t z = 0; z < _res_constr.datalen; z++) {
22302                 int64_t _res_conv_25 = _res_vals[z];
22303                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
22304                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
22305                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
22306                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
22307                 _res_constr.data[z] = _res_conv_25_conv;
22308         }
22309         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22310         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
22311 }
22312
22313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22314         LDKAcceptChannel o_conv;
22315         o_conv.inner = (void*)(o & (~1));
22316         o_conv.is_owned = (o & 1) || (o == 0);
22317         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22318         o_conv = AcceptChannel_clone(&o_conv);
22319         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22320         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
22321         return (int64_t)ret_conv;
22322 }
22323
22324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22325         LDKDecodeError e_conv;
22326         e_conv.inner = (void*)(e & (~1));
22327         e_conv.is_owned = (e & 1) || (e == 0);
22328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22329         e_conv = DecodeError_clone(&e_conv);
22330         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22331         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
22332         return (int64_t)ret_conv;
22333 }
22334
22335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22336         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
22337         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
22338         return ret_conv;
22339 }
22340
22341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22342         if ((_res & 1) != 0) return;
22343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22344         CHECK_ACCESS(_res_ptr);
22345         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
22346         FREE((void*)_res);
22347         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
22348 }
22349
22350 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
22351         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22352         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
22353         return (int64_t)ret_conv;
22354 }
22355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22356         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
22357         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
22358         return ret_conv;
22359 }
22360
22361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22362         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
22363         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22364         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
22365         return (int64_t)ret_conv;
22366 }
22367
22368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22369         LDKAnnouncementSignatures o_conv;
22370         o_conv.inner = (void*)(o & (~1));
22371         o_conv.is_owned = (o & 1) || (o == 0);
22372         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22373         o_conv = AnnouncementSignatures_clone(&o_conv);
22374         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22375         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
22376         return (int64_t)ret_conv;
22377 }
22378
22379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22380         LDKDecodeError e_conv;
22381         e_conv.inner = (void*)(e & (~1));
22382         e_conv.is_owned = (e & 1) || (e == 0);
22383         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22384         e_conv = DecodeError_clone(&e_conv);
22385         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22386         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
22387         return (int64_t)ret_conv;
22388 }
22389
22390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22391         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
22392         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
22393         return ret_conv;
22394 }
22395
22396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22397         if ((_res & 1) != 0) return;
22398         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22399         CHECK_ACCESS(_res_ptr);
22400         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
22401         FREE((void*)_res);
22402         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
22403 }
22404
22405 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
22406         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22407         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
22408         return (int64_t)ret_conv;
22409 }
22410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22411         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
22412         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
22413         return ret_conv;
22414 }
22415
22416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22417         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
22418         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22419         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
22420         return (int64_t)ret_conv;
22421 }
22422
22423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22424         LDKChannelReestablish o_conv;
22425         o_conv.inner = (void*)(o & (~1));
22426         o_conv.is_owned = (o & 1) || (o == 0);
22427         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22428         o_conv = ChannelReestablish_clone(&o_conv);
22429         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22430         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
22431         return (int64_t)ret_conv;
22432 }
22433
22434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22435         LDKDecodeError e_conv;
22436         e_conv.inner = (void*)(e & (~1));
22437         e_conv.is_owned = (e & 1) || (e == 0);
22438         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22439         e_conv = DecodeError_clone(&e_conv);
22440         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22441         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
22442         return (int64_t)ret_conv;
22443 }
22444
22445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22446         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
22447         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
22448         return ret_conv;
22449 }
22450
22451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22452         if ((_res & 1) != 0) return;
22453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22454         CHECK_ACCESS(_res_ptr);
22455         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
22456         FREE((void*)_res);
22457         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
22458 }
22459
22460 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
22461         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22462         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
22463         return (int64_t)ret_conv;
22464 }
22465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22466         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
22467         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
22468         return ret_conv;
22469 }
22470
22471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22472         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
22473         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22474         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
22475         return (int64_t)ret_conv;
22476 }
22477
22478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22479         LDKClosingSigned o_conv;
22480         o_conv.inner = (void*)(o & (~1));
22481         o_conv.is_owned = (o & 1) || (o == 0);
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22483         o_conv = ClosingSigned_clone(&o_conv);
22484         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22485         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
22486         return (int64_t)ret_conv;
22487 }
22488
22489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22490         LDKDecodeError e_conv;
22491         e_conv.inner = (void*)(e & (~1));
22492         e_conv.is_owned = (e & 1) || (e == 0);
22493         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22494         e_conv = DecodeError_clone(&e_conv);
22495         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22496         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
22497         return (int64_t)ret_conv;
22498 }
22499
22500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22501         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
22502         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
22503         return ret_conv;
22504 }
22505
22506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22507         if ((_res & 1) != 0) return;
22508         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22509         CHECK_ACCESS(_res_ptr);
22510         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
22511         FREE((void*)_res);
22512         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
22513 }
22514
22515 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
22516         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22517         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
22518         return (int64_t)ret_conv;
22519 }
22520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22521         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
22522         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
22523         return ret_conv;
22524 }
22525
22526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22527         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
22528         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22529         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
22530         return (int64_t)ret_conv;
22531 }
22532
22533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22534         LDKClosingSignedFeeRange o_conv;
22535         o_conv.inner = (void*)(o & (~1));
22536         o_conv.is_owned = (o & 1) || (o == 0);
22537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22538         o_conv = ClosingSignedFeeRange_clone(&o_conv);
22539         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22540         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
22541         return (int64_t)ret_conv;
22542 }
22543
22544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22545         LDKDecodeError e_conv;
22546         e_conv.inner = (void*)(e & (~1));
22547         e_conv.is_owned = (e & 1) || (e == 0);
22548         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22549         e_conv = DecodeError_clone(&e_conv);
22550         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22551         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
22552         return (int64_t)ret_conv;
22553 }
22554
22555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22556         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
22557         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
22558         return ret_conv;
22559 }
22560
22561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22562         if ((_res & 1) != 0) return;
22563         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22564         CHECK_ACCESS(_res_ptr);
22565         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
22566         FREE((void*)_res);
22567         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
22568 }
22569
22570 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
22571         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22572         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
22573         return (int64_t)ret_conv;
22574 }
22575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22576         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
22577         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
22578         return ret_conv;
22579 }
22580
22581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22582         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
22583         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22584         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
22585         return (int64_t)ret_conv;
22586 }
22587
22588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22589         LDKCommitmentSigned o_conv;
22590         o_conv.inner = (void*)(o & (~1));
22591         o_conv.is_owned = (o & 1) || (o == 0);
22592         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22593         o_conv = CommitmentSigned_clone(&o_conv);
22594         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22595         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
22596         return (int64_t)ret_conv;
22597 }
22598
22599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22600         LDKDecodeError e_conv;
22601         e_conv.inner = (void*)(e & (~1));
22602         e_conv.is_owned = (e & 1) || (e == 0);
22603         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22604         e_conv = DecodeError_clone(&e_conv);
22605         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22606         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
22607         return (int64_t)ret_conv;
22608 }
22609
22610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22611         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
22612         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
22613         return ret_conv;
22614 }
22615
22616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22617         if ((_res & 1) != 0) return;
22618         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22619         CHECK_ACCESS(_res_ptr);
22620         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
22621         FREE((void*)_res);
22622         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
22623 }
22624
22625 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
22626         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22627         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
22628         return (int64_t)ret_conv;
22629 }
22630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22631         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
22632         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
22633         return ret_conv;
22634 }
22635
22636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22637         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
22638         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22639         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
22640         return (int64_t)ret_conv;
22641 }
22642
22643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22644         LDKFundingCreated o_conv;
22645         o_conv.inner = (void*)(o & (~1));
22646         o_conv.is_owned = (o & 1) || (o == 0);
22647         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22648         o_conv = FundingCreated_clone(&o_conv);
22649         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22650         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
22651         return (int64_t)ret_conv;
22652 }
22653
22654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22655         LDKDecodeError e_conv;
22656         e_conv.inner = (void*)(e & (~1));
22657         e_conv.is_owned = (e & 1) || (e == 0);
22658         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22659         e_conv = DecodeError_clone(&e_conv);
22660         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22661         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
22662         return (int64_t)ret_conv;
22663 }
22664
22665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22666         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
22667         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
22668         return ret_conv;
22669 }
22670
22671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22672         if ((_res & 1) != 0) return;
22673         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22674         CHECK_ACCESS(_res_ptr);
22675         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
22676         FREE((void*)_res);
22677         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
22678 }
22679
22680 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
22681         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22682         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
22683         return (int64_t)ret_conv;
22684 }
22685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22686         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
22687         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
22688         return ret_conv;
22689 }
22690
22691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22692         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
22693         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22694         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
22695         return (int64_t)ret_conv;
22696 }
22697
22698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22699         LDKFundingSigned o_conv;
22700         o_conv.inner = (void*)(o & (~1));
22701         o_conv.is_owned = (o & 1) || (o == 0);
22702         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22703         o_conv = FundingSigned_clone(&o_conv);
22704         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22705         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
22706         return (int64_t)ret_conv;
22707 }
22708
22709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22710         LDKDecodeError e_conv;
22711         e_conv.inner = (void*)(e & (~1));
22712         e_conv.is_owned = (e & 1) || (e == 0);
22713         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22714         e_conv = DecodeError_clone(&e_conv);
22715         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22716         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
22717         return (int64_t)ret_conv;
22718 }
22719
22720 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22721         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
22722         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
22723         return ret_conv;
22724 }
22725
22726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22727         if ((_res & 1) != 0) return;
22728         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22729         CHECK_ACCESS(_res_ptr);
22730         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
22731         FREE((void*)_res);
22732         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
22733 }
22734
22735 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
22736         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22737         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
22738         return (int64_t)ret_conv;
22739 }
22740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22741         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
22742         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
22743         return ret_conv;
22744 }
22745
22746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22747         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
22748         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22749         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
22750         return (int64_t)ret_conv;
22751 }
22752
22753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22754         LDKChannelReady o_conv;
22755         o_conv.inner = (void*)(o & (~1));
22756         o_conv.is_owned = (o & 1) || (o == 0);
22757         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22758         o_conv = ChannelReady_clone(&o_conv);
22759         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22760         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
22761         return (int64_t)ret_conv;
22762 }
22763
22764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22765         LDKDecodeError e_conv;
22766         e_conv.inner = (void*)(e & (~1));
22767         e_conv.is_owned = (e & 1) || (e == 0);
22768         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22769         e_conv = DecodeError_clone(&e_conv);
22770         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22771         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
22772         return (int64_t)ret_conv;
22773 }
22774
22775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22776         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
22777         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
22778         return ret_conv;
22779 }
22780
22781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22782         if ((_res & 1) != 0) return;
22783         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22784         CHECK_ACCESS(_res_ptr);
22785         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
22786         FREE((void*)_res);
22787         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
22788 }
22789
22790 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
22791         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22792         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
22793         return (int64_t)ret_conv;
22794 }
22795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22796         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
22797         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
22798         return ret_conv;
22799 }
22800
22801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22802         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
22803         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22804         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
22805         return (int64_t)ret_conv;
22806 }
22807
22808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22809         LDKInit o_conv;
22810         o_conv.inner = (void*)(o & (~1));
22811         o_conv.is_owned = (o & 1) || (o == 0);
22812         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22813         o_conv = Init_clone(&o_conv);
22814         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22815         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
22816         return (int64_t)ret_conv;
22817 }
22818
22819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22820         LDKDecodeError e_conv;
22821         e_conv.inner = (void*)(e & (~1));
22822         e_conv.is_owned = (e & 1) || (e == 0);
22823         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22824         e_conv = DecodeError_clone(&e_conv);
22825         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22826         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
22827         return (int64_t)ret_conv;
22828 }
22829
22830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22831         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
22832         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
22833         return ret_conv;
22834 }
22835
22836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22837         if ((_res & 1) != 0) return;
22838         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22839         CHECK_ACCESS(_res_ptr);
22840         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
22841         FREE((void*)_res);
22842         CResult_InitDecodeErrorZ_free(_res_conv);
22843 }
22844
22845 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
22846         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22847         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
22848         return (int64_t)ret_conv;
22849 }
22850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22851         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
22852         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
22853         return ret_conv;
22854 }
22855
22856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22857         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
22858         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22859         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
22860         return (int64_t)ret_conv;
22861 }
22862
22863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22864         LDKOpenChannel o_conv;
22865         o_conv.inner = (void*)(o & (~1));
22866         o_conv.is_owned = (o & 1) || (o == 0);
22867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22868         o_conv = OpenChannel_clone(&o_conv);
22869         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22870         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
22871         return (int64_t)ret_conv;
22872 }
22873
22874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22875         LDKDecodeError e_conv;
22876         e_conv.inner = (void*)(e & (~1));
22877         e_conv.is_owned = (e & 1) || (e == 0);
22878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22879         e_conv = DecodeError_clone(&e_conv);
22880         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22881         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
22882         return (int64_t)ret_conv;
22883 }
22884
22885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22886         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
22887         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
22888         return ret_conv;
22889 }
22890
22891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22892         if ((_res & 1) != 0) return;
22893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22894         CHECK_ACCESS(_res_ptr);
22895         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
22896         FREE((void*)_res);
22897         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
22898 }
22899
22900 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
22901         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22902         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
22903         return (int64_t)ret_conv;
22904 }
22905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22906         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
22907         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
22908         return ret_conv;
22909 }
22910
22911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22912         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
22913         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22914         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
22915         return (int64_t)ret_conv;
22916 }
22917
22918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22919         LDKRevokeAndACK o_conv;
22920         o_conv.inner = (void*)(o & (~1));
22921         o_conv.is_owned = (o & 1) || (o == 0);
22922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22923         o_conv = RevokeAndACK_clone(&o_conv);
22924         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22925         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
22926         return (int64_t)ret_conv;
22927 }
22928
22929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22930         LDKDecodeError e_conv;
22931         e_conv.inner = (void*)(e & (~1));
22932         e_conv.is_owned = (e & 1) || (e == 0);
22933         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22934         e_conv = DecodeError_clone(&e_conv);
22935         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22936         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
22937         return (int64_t)ret_conv;
22938 }
22939
22940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22941         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
22942         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
22943         return ret_conv;
22944 }
22945
22946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22947         if ((_res & 1) != 0) return;
22948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22949         CHECK_ACCESS(_res_ptr);
22950         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
22951         FREE((void*)_res);
22952         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
22953 }
22954
22955 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
22956         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22957         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
22958         return (int64_t)ret_conv;
22959 }
22960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22961         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
22962         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
22963         return ret_conv;
22964 }
22965
22966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22967         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
22968         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22969         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
22970         return (int64_t)ret_conv;
22971 }
22972
22973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22974         LDKShutdown o_conv;
22975         o_conv.inner = (void*)(o & (~1));
22976         o_conv.is_owned = (o & 1) || (o == 0);
22977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22978         o_conv = Shutdown_clone(&o_conv);
22979         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22980         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
22981         return (int64_t)ret_conv;
22982 }
22983
22984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22985         LDKDecodeError e_conv;
22986         e_conv.inner = (void*)(e & (~1));
22987         e_conv.is_owned = (e & 1) || (e == 0);
22988         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22989         e_conv = DecodeError_clone(&e_conv);
22990         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22991         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
22992         return (int64_t)ret_conv;
22993 }
22994
22995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22996         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
22997         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
22998         return ret_conv;
22999 }
23000
23001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23002         if ((_res & 1) != 0) return;
23003         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23004         CHECK_ACCESS(_res_ptr);
23005         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
23006         FREE((void*)_res);
23007         CResult_ShutdownDecodeErrorZ_free(_res_conv);
23008 }
23009
23010 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
23011         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23012         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
23013         return (int64_t)ret_conv;
23014 }
23015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23016         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
23017         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
23018         return ret_conv;
23019 }
23020
23021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23022         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
23023         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23024         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
23025         return (int64_t)ret_conv;
23026 }
23027
23028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23029         LDKUpdateFailHTLC o_conv;
23030         o_conv.inner = (void*)(o & (~1));
23031         o_conv.is_owned = (o & 1) || (o == 0);
23032         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23033         o_conv = UpdateFailHTLC_clone(&o_conv);
23034         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23035         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
23036         return (int64_t)ret_conv;
23037 }
23038
23039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23040         LDKDecodeError e_conv;
23041         e_conv.inner = (void*)(e & (~1));
23042         e_conv.is_owned = (e & 1) || (e == 0);
23043         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23044         e_conv = DecodeError_clone(&e_conv);
23045         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23046         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
23047         return (int64_t)ret_conv;
23048 }
23049
23050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23051         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
23052         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
23053         return ret_conv;
23054 }
23055
23056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23057         if ((_res & 1) != 0) return;
23058         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23059         CHECK_ACCESS(_res_ptr);
23060         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
23061         FREE((void*)_res);
23062         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
23063 }
23064
23065 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
23066         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23067         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
23068         return (int64_t)ret_conv;
23069 }
23070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23071         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
23072         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
23073         return ret_conv;
23074 }
23075
23076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23077         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
23078         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23079         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
23080         return (int64_t)ret_conv;
23081 }
23082
23083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23084         LDKUpdateFailMalformedHTLC o_conv;
23085         o_conv.inner = (void*)(o & (~1));
23086         o_conv.is_owned = (o & 1) || (o == 0);
23087         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23088         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
23089         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23090         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
23091         return (int64_t)ret_conv;
23092 }
23093
23094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23095         LDKDecodeError e_conv;
23096         e_conv.inner = (void*)(e & (~1));
23097         e_conv.is_owned = (e & 1) || (e == 0);
23098         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23099         e_conv = DecodeError_clone(&e_conv);
23100         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23101         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
23102         return (int64_t)ret_conv;
23103 }
23104
23105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23106         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
23107         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
23108         return ret_conv;
23109 }
23110
23111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23112         if ((_res & 1) != 0) return;
23113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23114         CHECK_ACCESS(_res_ptr);
23115         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
23116         FREE((void*)_res);
23117         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
23118 }
23119
23120 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
23121         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23122         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
23123         return (int64_t)ret_conv;
23124 }
23125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23126         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
23127         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
23128         return ret_conv;
23129 }
23130
23131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23132         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
23133         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23134         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
23135         return (int64_t)ret_conv;
23136 }
23137
23138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23139         LDKUpdateFee o_conv;
23140         o_conv.inner = (void*)(o & (~1));
23141         o_conv.is_owned = (o & 1) || (o == 0);
23142         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23143         o_conv = UpdateFee_clone(&o_conv);
23144         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23145         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
23146         return (int64_t)ret_conv;
23147 }
23148
23149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23150         LDKDecodeError e_conv;
23151         e_conv.inner = (void*)(e & (~1));
23152         e_conv.is_owned = (e & 1) || (e == 0);
23153         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23154         e_conv = DecodeError_clone(&e_conv);
23155         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23156         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
23157         return (int64_t)ret_conv;
23158 }
23159
23160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23161         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
23162         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
23163         return ret_conv;
23164 }
23165
23166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23167         if ((_res & 1) != 0) return;
23168         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23169         CHECK_ACCESS(_res_ptr);
23170         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
23171         FREE((void*)_res);
23172         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
23173 }
23174
23175 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
23176         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23177         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
23178         return (int64_t)ret_conv;
23179 }
23180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23181         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
23182         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
23183         return ret_conv;
23184 }
23185
23186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23187         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
23188         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23189         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
23190         return (int64_t)ret_conv;
23191 }
23192
23193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23194         LDKUpdateFulfillHTLC o_conv;
23195         o_conv.inner = (void*)(o & (~1));
23196         o_conv.is_owned = (o & 1) || (o == 0);
23197         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23198         o_conv = UpdateFulfillHTLC_clone(&o_conv);
23199         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23200         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
23201         return (int64_t)ret_conv;
23202 }
23203
23204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23205         LDKDecodeError e_conv;
23206         e_conv.inner = (void*)(e & (~1));
23207         e_conv.is_owned = (e & 1) || (e == 0);
23208         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23209         e_conv = DecodeError_clone(&e_conv);
23210         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23211         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
23212         return (int64_t)ret_conv;
23213 }
23214
23215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23216         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
23217         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
23218         return ret_conv;
23219 }
23220
23221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23222         if ((_res & 1) != 0) return;
23223         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23224         CHECK_ACCESS(_res_ptr);
23225         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
23226         FREE((void*)_res);
23227         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
23228 }
23229
23230 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
23231         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23232         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
23233         return (int64_t)ret_conv;
23234 }
23235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23236         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
23237         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
23238         return ret_conv;
23239 }
23240
23241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23242         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
23243         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23244         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
23245         return (int64_t)ret_conv;
23246 }
23247
23248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23249         LDKUpdateAddHTLC o_conv;
23250         o_conv.inner = (void*)(o & (~1));
23251         o_conv.is_owned = (o & 1) || (o == 0);
23252         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23253         o_conv = UpdateAddHTLC_clone(&o_conv);
23254         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23255         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
23256         return (int64_t)ret_conv;
23257 }
23258
23259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23260         LDKDecodeError e_conv;
23261         e_conv.inner = (void*)(e & (~1));
23262         e_conv.is_owned = (e & 1) || (e == 0);
23263         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23264         e_conv = DecodeError_clone(&e_conv);
23265         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23266         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
23267         return (int64_t)ret_conv;
23268 }
23269
23270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23271         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
23272         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
23273         return ret_conv;
23274 }
23275
23276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23277         if ((_res & 1) != 0) return;
23278         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23279         CHECK_ACCESS(_res_ptr);
23280         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
23281         FREE((void*)_res);
23282         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
23283 }
23284
23285 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
23286         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23287         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
23288         return (int64_t)ret_conv;
23289 }
23290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23291         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
23292         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
23293         return ret_conv;
23294 }
23295
23296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23297         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
23298         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23299         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
23300         return (int64_t)ret_conv;
23301 }
23302
23303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23304         LDKPing o_conv;
23305         o_conv.inner = (void*)(o & (~1));
23306         o_conv.is_owned = (o & 1) || (o == 0);
23307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23308         o_conv = Ping_clone(&o_conv);
23309         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23310         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
23311         return (int64_t)ret_conv;
23312 }
23313
23314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23315         LDKDecodeError e_conv;
23316         e_conv.inner = (void*)(e & (~1));
23317         e_conv.is_owned = (e & 1) || (e == 0);
23318         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23319         e_conv = DecodeError_clone(&e_conv);
23320         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23321         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
23322         return (int64_t)ret_conv;
23323 }
23324
23325 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23326         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
23327         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
23328         return ret_conv;
23329 }
23330
23331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23332         if ((_res & 1) != 0) return;
23333         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23334         CHECK_ACCESS(_res_ptr);
23335         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
23336         FREE((void*)_res);
23337         CResult_PingDecodeErrorZ_free(_res_conv);
23338 }
23339
23340 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
23341         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23342         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
23343         return (int64_t)ret_conv;
23344 }
23345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23346         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
23347         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
23348         return ret_conv;
23349 }
23350
23351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23352         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
23353         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23354         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
23355         return (int64_t)ret_conv;
23356 }
23357
23358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23359         LDKPong o_conv;
23360         o_conv.inner = (void*)(o & (~1));
23361         o_conv.is_owned = (o & 1) || (o == 0);
23362         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23363         o_conv = Pong_clone(&o_conv);
23364         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23365         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
23366         return (int64_t)ret_conv;
23367 }
23368
23369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23370         LDKDecodeError e_conv;
23371         e_conv.inner = (void*)(e & (~1));
23372         e_conv.is_owned = (e & 1) || (e == 0);
23373         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23374         e_conv = DecodeError_clone(&e_conv);
23375         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23376         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
23377         return (int64_t)ret_conv;
23378 }
23379
23380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23381         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
23382         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
23383         return ret_conv;
23384 }
23385
23386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23387         if ((_res & 1) != 0) return;
23388         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23389         CHECK_ACCESS(_res_ptr);
23390         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
23391         FREE((void*)_res);
23392         CResult_PongDecodeErrorZ_free(_res_conv);
23393 }
23394
23395 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
23396         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23397         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
23398         return (int64_t)ret_conv;
23399 }
23400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23401         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
23402         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
23403         return ret_conv;
23404 }
23405
23406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23407         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
23408         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23409         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
23410         return (int64_t)ret_conv;
23411 }
23412
23413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23414         LDKUnsignedChannelAnnouncement o_conv;
23415         o_conv.inner = (void*)(o & (~1));
23416         o_conv.is_owned = (o & 1) || (o == 0);
23417         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23418         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
23419         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23420         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
23421         return (int64_t)ret_conv;
23422 }
23423
23424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23425         LDKDecodeError e_conv;
23426         e_conv.inner = (void*)(e & (~1));
23427         e_conv.is_owned = (e & 1) || (e == 0);
23428         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23429         e_conv = DecodeError_clone(&e_conv);
23430         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23431         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
23432         return (int64_t)ret_conv;
23433 }
23434
23435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23436         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
23437         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23438         return ret_conv;
23439 }
23440
23441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23442         if ((_res & 1) != 0) return;
23443         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23444         CHECK_ACCESS(_res_ptr);
23445         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23446         FREE((void*)_res);
23447         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
23448 }
23449
23450 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23451         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23452         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
23453         return (int64_t)ret_conv;
23454 }
23455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23456         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23457         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23458         return ret_conv;
23459 }
23460
23461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23462         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23463         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23464         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23465         return (int64_t)ret_conv;
23466 }
23467
23468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23469         LDKChannelAnnouncement o_conv;
23470         o_conv.inner = (void*)(o & (~1));
23471         o_conv.is_owned = (o & 1) || (o == 0);
23472         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23473         o_conv = ChannelAnnouncement_clone(&o_conv);
23474         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23475         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
23476         return (int64_t)ret_conv;
23477 }
23478
23479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23480         LDKDecodeError e_conv;
23481         e_conv.inner = (void*)(e & (~1));
23482         e_conv.is_owned = (e & 1) || (e == 0);
23483         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23484         e_conv = DecodeError_clone(&e_conv);
23485         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23486         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
23487         return (int64_t)ret_conv;
23488 }
23489
23490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23491         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
23492         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23493         return ret_conv;
23494 }
23495
23496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23497         if ((_res & 1) != 0) return;
23498         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23499         CHECK_ACCESS(_res_ptr);
23500         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23501         FREE((void*)_res);
23502         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
23503 }
23504
23505 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23506         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23507         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
23508         return (int64_t)ret_conv;
23509 }
23510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23511         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23512         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23513         return ret_conv;
23514 }
23515
23516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23517         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23518         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23519         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23520         return (int64_t)ret_conv;
23521 }
23522
23523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23524         LDKUnsignedChannelUpdate o_conv;
23525         o_conv.inner = (void*)(o & (~1));
23526         o_conv.is_owned = (o & 1) || (o == 0);
23527         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23528         o_conv = UnsignedChannelUpdate_clone(&o_conv);
23529         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23530         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
23531         return (int64_t)ret_conv;
23532 }
23533
23534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23535         LDKDecodeError e_conv;
23536         e_conv.inner = (void*)(e & (~1));
23537         e_conv.is_owned = (e & 1) || (e == 0);
23538         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23539         e_conv = DecodeError_clone(&e_conv);
23540         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23541         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
23542         return (int64_t)ret_conv;
23543 }
23544
23545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23546         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
23547         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
23548         return ret_conv;
23549 }
23550
23551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23552         if ((_res & 1) != 0) return;
23553         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23554         CHECK_ACCESS(_res_ptr);
23555         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
23556         FREE((void*)_res);
23557         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
23558 }
23559
23560 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23561         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23562         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
23563         return (int64_t)ret_conv;
23564 }
23565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23566         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
23567         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23568         return ret_conv;
23569 }
23570
23571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23572         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
23573         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23574         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
23575         return (int64_t)ret_conv;
23576 }
23577
23578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23579         LDKChannelUpdate o_conv;
23580         o_conv.inner = (void*)(o & (~1));
23581         o_conv.is_owned = (o & 1) || (o == 0);
23582         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23583         o_conv = ChannelUpdate_clone(&o_conv);
23584         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23585         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
23586         return (int64_t)ret_conv;
23587 }
23588
23589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23590         LDKDecodeError e_conv;
23591         e_conv.inner = (void*)(e & (~1));
23592         e_conv.is_owned = (e & 1) || (e == 0);
23593         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23594         e_conv = DecodeError_clone(&e_conv);
23595         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23596         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
23597         return (int64_t)ret_conv;
23598 }
23599
23600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23601         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
23602         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
23603         return ret_conv;
23604 }
23605
23606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23607         if ((_res & 1) != 0) return;
23608         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23609         CHECK_ACCESS(_res_ptr);
23610         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
23611         FREE((void*)_res);
23612         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
23613 }
23614
23615 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23616         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23617         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
23618         return (int64_t)ret_conv;
23619 }
23620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23621         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
23622         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23623         return ret_conv;
23624 }
23625
23626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23627         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
23628         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23629         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
23630         return (int64_t)ret_conv;
23631 }
23632
23633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23634         LDKErrorMessage o_conv;
23635         o_conv.inner = (void*)(o & (~1));
23636         o_conv.is_owned = (o & 1) || (o == 0);
23637         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23638         o_conv = ErrorMessage_clone(&o_conv);
23639         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23640         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
23641         return (int64_t)ret_conv;
23642 }
23643
23644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23645         LDKDecodeError e_conv;
23646         e_conv.inner = (void*)(e & (~1));
23647         e_conv.is_owned = (e & 1) || (e == 0);
23648         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23649         e_conv = DecodeError_clone(&e_conv);
23650         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23651         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
23652         return (int64_t)ret_conv;
23653 }
23654
23655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23656         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
23657         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
23658         return ret_conv;
23659 }
23660
23661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23662         if ((_res & 1) != 0) return;
23663         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23664         CHECK_ACCESS(_res_ptr);
23665         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
23666         FREE((void*)_res);
23667         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
23668 }
23669
23670 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
23671         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23672         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
23673         return (int64_t)ret_conv;
23674 }
23675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23676         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
23677         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
23678         return ret_conv;
23679 }
23680
23681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23682         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
23683         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23684         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
23685         return (int64_t)ret_conv;
23686 }
23687
23688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23689         LDKWarningMessage o_conv;
23690         o_conv.inner = (void*)(o & (~1));
23691         o_conv.is_owned = (o & 1) || (o == 0);
23692         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23693         o_conv = WarningMessage_clone(&o_conv);
23694         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23695         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
23696         return (int64_t)ret_conv;
23697 }
23698
23699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23700         LDKDecodeError e_conv;
23701         e_conv.inner = (void*)(e & (~1));
23702         e_conv.is_owned = (e & 1) || (e == 0);
23703         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23704         e_conv = DecodeError_clone(&e_conv);
23705         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23706         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
23707         return (int64_t)ret_conv;
23708 }
23709
23710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23711         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
23712         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
23713         return ret_conv;
23714 }
23715
23716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23717         if ((_res & 1) != 0) return;
23718         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23719         CHECK_ACCESS(_res_ptr);
23720         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
23721         FREE((void*)_res);
23722         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
23723 }
23724
23725 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
23726         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23727         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
23728         return (int64_t)ret_conv;
23729 }
23730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23731         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
23732         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
23733         return ret_conv;
23734 }
23735
23736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23737         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
23738         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23739         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
23740         return (int64_t)ret_conv;
23741 }
23742
23743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23744         LDKUnsignedNodeAnnouncement o_conv;
23745         o_conv.inner = (void*)(o & (~1));
23746         o_conv.is_owned = (o & 1) || (o == 0);
23747         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23748         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
23749         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23750         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
23751         return (int64_t)ret_conv;
23752 }
23753
23754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23755         LDKDecodeError e_conv;
23756         e_conv.inner = (void*)(e & (~1));
23757         e_conv.is_owned = (e & 1) || (e == 0);
23758         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23759         e_conv = DecodeError_clone(&e_conv);
23760         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23761         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
23762         return (int64_t)ret_conv;
23763 }
23764
23765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23766         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
23767         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23768         return ret_conv;
23769 }
23770
23771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23772         if ((_res & 1) != 0) return;
23773         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23774         CHECK_ACCESS(_res_ptr);
23775         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
23776         FREE((void*)_res);
23777         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
23778 }
23779
23780 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23781         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23782         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
23783         return (int64_t)ret_conv;
23784 }
23785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23786         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
23787         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23788         return ret_conv;
23789 }
23790
23791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23792         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
23793         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23794         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
23795         return (int64_t)ret_conv;
23796 }
23797
23798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23799         LDKNodeAnnouncement o_conv;
23800         o_conv.inner = (void*)(o & (~1));
23801         o_conv.is_owned = (o & 1) || (o == 0);
23802         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23803         o_conv = NodeAnnouncement_clone(&o_conv);
23804         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23805         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
23806         return (int64_t)ret_conv;
23807 }
23808
23809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23810         LDKDecodeError e_conv;
23811         e_conv.inner = (void*)(e & (~1));
23812         e_conv.is_owned = (e & 1) || (e == 0);
23813         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23814         e_conv = DecodeError_clone(&e_conv);
23815         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23816         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
23817         return (int64_t)ret_conv;
23818 }
23819
23820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23821         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
23822         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23823         return ret_conv;
23824 }
23825
23826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23827         if ((_res & 1) != 0) return;
23828         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23829         CHECK_ACCESS(_res_ptr);
23830         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
23831         FREE((void*)_res);
23832         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
23833 }
23834
23835 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23836         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23837         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
23838         return (int64_t)ret_conv;
23839 }
23840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23841         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
23842         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23843         return ret_conv;
23844 }
23845
23846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23847         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
23848         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23849         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
23850         return (int64_t)ret_conv;
23851 }
23852
23853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23854         LDKQueryShortChannelIds o_conv;
23855         o_conv.inner = (void*)(o & (~1));
23856         o_conv.is_owned = (o & 1) || (o == 0);
23857         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23858         o_conv = QueryShortChannelIds_clone(&o_conv);
23859         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23860         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
23861         return (int64_t)ret_conv;
23862 }
23863
23864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23865         LDKDecodeError e_conv;
23866         e_conv.inner = (void*)(e & (~1));
23867         e_conv.is_owned = (e & 1) || (e == 0);
23868         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23869         e_conv = DecodeError_clone(&e_conv);
23870         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23871         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
23872         return (int64_t)ret_conv;
23873 }
23874
23875 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23876         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
23877         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
23878         return ret_conv;
23879 }
23880
23881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23882         if ((_res & 1) != 0) return;
23883         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23884         CHECK_ACCESS(_res_ptr);
23885         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
23886         FREE((void*)_res);
23887         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
23888 }
23889
23890 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
23891         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23892         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
23893         return (int64_t)ret_conv;
23894 }
23895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23896         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
23897         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
23898         return ret_conv;
23899 }
23900
23901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23902         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
23903         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23904         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
23905         return (int64_t)ret_conv;
23906 }
23907
23908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23909         LDKReplyShortChannelIdsEnd o_conv;
23910         o_conv.inner = (void*)(o & (~1));
23911         o_conv.is_owned = (o & 1) || (o == 0);
23912         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23913         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
23914         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23915         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
23916         return (int64_t)ret_conv;
23917 }
23918
23919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23920         LDKDecodeError e_conv;
23921         e_conv.inner = (void*)(e & (~1));
23922         e_conv.is_owned = (e & 1) || (e == 0);
23923         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23924         e_conv = DecodeError_clone(&e_conv);
23925         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23926         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
23927         return (int64_t)ret_conv;
23928 }
23929
23930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23931         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
23932         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
23933         return ret_conv;
23934 }
23935
23936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23937         if ((_res & 1) != 0) return;
23938         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23939         CHECK_ACCESS(_res_ptr);
23940         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
23941         FREE((void*)_res);
23942         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
23943 }
23944
23945 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
23946         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23947         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
23948         return (int64_t)ret_conv;
23949 }
23950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23951         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
23952         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
23953         return ret_conv;
23954 }
23955
23956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23957         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
23958         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23959         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
23960         return (int64_t)ret_conv;
23961 }
23962
23963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23964         LDKQueryChannelRange o_conv;
23965         o_conv.inner = (void*)(o & (~1));
23966         o_conv.is_owned = (o & 1) || (o == 0);
23967         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23968         o_conv = QueryChannelRange_clone(&o_conv);
23969         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23970         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
23971         return (int64_t)ret_conv;
23972 }
23973
23974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23975         LDKDecodeError e_conv;
23976         e_conv.inner = (void*)(e & (~1));
23977         e_conv.is_owned = (e & 1) || (e == 0);
23978         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23979         e_conv = DecodeError_clone(&e_conv);
23980         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23981         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
23982         return (int64_t)ret_conv;
23983 }
23984
23985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23986         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
23987         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
23988         return ret_conv;
23989 }
23990
23991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23992         if ((_res & 1) != 0) return;
23993         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23994         CHECK_ACCESS(_res_ptr);
23995         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
23996         FREE((void*)_res);
23997         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
23998 }
23999
24000 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24001         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24002         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
24003         return (int64_t)ret_conv;
24004 }
24005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24006         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
24007         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24008         return ret_conv;
24009 }
24010
24011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24012         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
24013         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24014         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
24015         return (int64_t)ret_conv;
24016 }
24017
24018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24019         LDKReplyChannelRange o_conv;
24020         o_conv.inner = (void*)(o & (~1));
24021         o_conv.is_owned = (o & 1) || (o == 0);
24022         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24023         o_conv = ReplyChannelRange_clone(&o_conv);
24024         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24025         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
24026         return (int64_t)ret_conv;
24027 }
24028
24029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24030         LDKDecodeError e_conv;
24031         e_conv.inner = (void*)(e & (~1));
24032         e_conv.is_owned = (e & 1) || (e == 0);
24033         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24034         e_conv = DecodeError_clone(&e_conv);
24035         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24036         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
24037         return (int64_t)ret_conv;
24038 }
24039
24040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24041         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
24042         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
24043         return ret_conv;
24044 }
24045
24046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24047         if ((_res & 1) != 0) return;
24048         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24049         CHECK_ACCESS(_res_ptr);
24050         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
24051         FREE((void*)_res);
24052         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
24053 }
24054
24055 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24056         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24057         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
24058         return (int64_t)ret_conv;
24059 }
24060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24061         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
24062         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24063         return ret_conv;
24064 }
24065
24066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24067         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
24068         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24069         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
24070         return (int64_t)ret_conv;
24071 }
24072
24073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24074         LDKGossipTimestampFilter o_conv;
24075         o_conv.inner = (void*)(o & (~1));
24076         o_conv.is_owned = (o & 1) || (o == 0);
24077         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24078         o_conv = GossipTimestampFilter_clone(&o_conv);
24079         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24080         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
24081         return (int64_t)ret_conv;
24082 }
24083
24084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24085         LDKDecodeError e_conv;
24086         e_conv.inner = (void*)(e & (~1));
24087         e_conv.is_owned = (e & 1) || (e == 0);
24088         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24089         e_conv = DecodeError_clone(&e_conv);
24090         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24091         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
24092         return (int64_t)ret_conv;
24093 }
24094
24095 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24096         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
24097         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
24098         return ret_conv;
24099 }
24100
24101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24102         if ((_res & 1) != 0) return;
24103         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24104         CHECK_ACCESS(_res_ptr);
24105         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
24106         FREE((void*)_res);
24107         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
24108 }
24109
24110 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
24111         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24112         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
24113         return (int64_t)ret_conv;
24114 }
24115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24116         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
24117         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
24118         return ret_conv;
24119 }
24120
24121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24122         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
24123         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24124         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
24125         return (int64_t)ret_conv;
24126 }
24127
24128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24129         LDKCVec_PhantomRouteHintsZ _res_constr;
24130         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24131         if (_res_constr.datalen > 0)
24132                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
24133         else
24134                 _res_constr.data = NULL;
24135         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24136         for (size_t t = 0; t < _res_constr.datalen; t++) {
24137                 int64_t _res_conv_19 = _res_vals[t];
24138                 LDKPhantomRouteHints _res_conv_19_conv;
24139                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
24140                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
24141                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24142                 _res_constr.data[t] = _res_conv_19_conv;
24143         }
24144         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24145         CVec_PhantomRouteHintsZ_free(_res_constr);
24146 }
24147
24148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24149         LDKInvoice o_conv;
24150         o_conv.inner = (void*)(o & (~1));
24151         o_conv.is_owned = (o & 1) || (o == 0);
24152         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24153         o_conv = Invoice_clone(&o_conv);
24154         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24155         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
24156         return (int64_t)ret_conv;
24157 }
24158
24159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24160         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
24161         CHECK_ACCESS(e_ptr);
24162         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
24163         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
24164         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24165         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
24166         return (int64_t)ret_conv;
24167 }
24168
24169 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24170         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
24171         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
24172         return ret_conv;
24173 }
24174
24175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24176         if ((_res & 1) != 0) return;
24177         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24178         CHECK_ACCESS(_res_ptr);
24179         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
24180         FREE((void*)_res);
24181         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
24182 }
24183
24184 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
24185         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24186         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
24187         return (int64_t)ret_conv;
24188 }
24189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24190         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
24191         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
24192         return ret_conv;
24193 }
24194
24195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24196         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
24197         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24198         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
24199         return (int64_t)ret_conv;
24200 }
24201
24202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
24203         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
24204         CHECK_ACCESS(o_ptr);
24205         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
24206         if (o_conv.free == LDKFilter_JCalls_free) {
24207                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24208                 LDKFilter_JCalls_cloned(&o_conv);
24209         }
24210         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
24211         *ret_copy = COption_FilterZ_some(o_conv);
24212         int64_t ret_ref = (uintptr_t)ret_copy;
24213         return ret_ref;
24214 }
24215
24216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
24217         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
24218         *ret_copy = COption_FilterZ_none();
24219         int64_t ret_ref = (uintptr_t)ret_copy;
24220         return ret_ref;
24221 }
24222
24223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24224         if ((_res & 1) != 0) return;
24225         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24226         CHECK_ACCESS(_res_ptr);
24227         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
24228         FREE((void*)_res);
24229         COption_FilterZ_free(_res_conv);
24230 }
24231
24232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24233         LDKLockedChannelMonitor o_conv;
24234         o_conv.inner = (void*)(o & (~1));
24235         o_conv.is_owned = (o & 1) || (o == 0);
24236         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24237         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
24238         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
24239         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
24240         return (int64_t)ret_conv;
24241 }
24242
24243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
24244         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
24245         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
24246         return (int64_t)ret_conv;
24247 }
24248
24249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24250         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
24251         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
24252         return ret_conv;
24253 }
24254
24255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24256         if ((_res & 1) != 0) return;
24257         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24258         CHECK_ACCESS(_res_ptr);
24259         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
24260         FREE((void*)_res);
24261         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
24262 }
24263
24264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24265         LDKCVec_OutPointZ _res_constr;
24266         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24267         if (_res_constr.datalen > 0)
24268                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
24269         else
24270                 _res_constr.data = NULL;
24271         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24272         for (size_t k = 0; k < _res_constr.datalen; k++) {
24273                 int64_t _res_conv_10 = _res_vals[k];
24274                 LDKOutPoint _res_conv_10_conv;
24275                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
24276                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
24277                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
24278                 _res_constr.data[k] = _res_conv_10_conv;
24279         }
24280         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24281         CVec_OutPointZ_free(_res_constr);
24282 }
24283
24284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24285         if ((this_ptr & 1) != 0) return;
24286         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24287         CHECK_ACCESS(this_ptr_ptr);
24288         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
24289         FREE((void*)this_ptr);
24290         PaymentPurpose_free(this_ptr_conv);
24291 }
24292
24293 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
24294         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24295         *ret_copy = PaymentPurpose_clone(arg);
24296 int64_t ret_ref = (uintptr_t)ret_copy;
24297         return ret_ref;
24298 }
24299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24300         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
24301         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
24302         return ret_conv;
24303 }
24304
24305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24306         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
24307         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24308         *ret_copy = PaymentPurpose_clone(orig_conv);
24309         int64_t ret_ref = (uintptr_t)ret_copy;
24310         return ret_ref;
24311 }
24312
24313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
24314         LDKThirtyTwoBytes payment_preimage_ref;
24315         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24316         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24317         LDKThirtyTwoBytes payment_secret_ref;
24318         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
24319         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
24320         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24321         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
24322         int64_t ret_ref = (uintptr_t)ret_copy;
24323         return ret_ref;
24324 }
24325
24326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
24327         LDKThirtyTwoBytes a_ref;
24328         CHECK((*env)->GetArrayLength(env, a) == 32);
24329         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
24330         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24331         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
24332         int64_t ret_ref = (uintptr_t)ret_copy;
24333         return ret_ref;
24334 }
24335
24336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
24337         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
24338         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
24339         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24340         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24341         CVec_u8Z_free(ret_var);
24342         return ret_arr;
24343 }
24344
24345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24346         LDKu8slice ser_ref;
24347         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24348         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24349         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
24350         *ret_conv = PaymentPurpose_read(ser_ref);
24351         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24352         return (int64_t)ret_conv;
24353 }
24354
24355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24356         if ((this_ptr & 1) != 0) return;
24357         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24358         CHECK_ACCESS(this_ptr_ptr);
24359         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
24360         FREE((void*)this_ptr);
24361         ClosureReason_free(this_ptr_conv);
24362 }
24363
24364 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
24365         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24366         *ret_copy = ClosureReason_clone(arg);
24367 int64_t ret_ref = (uintptr_t)ret_copy;
24368         return ret_ref;
24369 }
24370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24371         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
24372         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
24373         return ret_conv;
24374 }
24375
24376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24377         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
24378         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24379         *ret_copy = ClosureReason_clone(orig_conv);
24380         int64_t ret_ref = (uintptr_t)ret_copy;
24381         return ret_ref;
24382 }
24383
24384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
24385         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
24386         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24387         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
24388         int64_t ret_ref = (uintptr_t)ret_copy;
24389         return ret_ref;
24390 }
24391
24392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
24393         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24394         *ret_copy = ClosureReason_holder_force_closed();
24395         int64_t ret_ref = (uintptr_t)ret_copy;
24396         return ret_ref;
24397 }
24398
24399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
24400         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24401         *ret_copy = ClosureReason_cooperative_closure();
24402         int64_t ret_ref = (uintptr_t)ret_copy;
24403         return ret_ref;
24404 }
24405
24406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
24407         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24408         *ret_copy = ClosureReason_commitment_tx_confirmed();
24409         int64_t ret_ref = (uintptr_t)ret_copy;
24410         return ret_ref;
24411 }
24412
24413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
24414         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24415         *ret_copy = ClosureReason_funding_timed_out();
24416         int64_t ret_ref = (uintptr_t)ret_copy;
24417         return ret_ref;
24418 }
24419
24420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
24421         LDKStr err_conv = java_to_owned_str(env, err);
24422         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24423         *ret_copy = ClosureReason_processing_error(err_conv);
24424         int64_t ret_ref = (uintptr_t)ret_copy;
24425         return ret_ref;
24426 }
24427
24428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
24429         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24430         *ret_copy = ClosureReason_disconnected_peer();
24431         int64_t ret_ref = (uintptr_t)ret_copy;
24432         return ret_ref;
24433 }
24434
24435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
24436         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24437         *ret_copy = ClosureReason_outdated_channel_manager();
24438         int64_t ret_ref = (uintptr_t)ret_copy;
24439         return ret_ref;
24440 }
24441
24442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
24443         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
24444         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
24445         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24446         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24447         CVec_u8Z_free(ret_var);
24448         return ret_arr;
24449 }
24450
24451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24452         LDKu8slice ser_ref;
24453         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24454         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24455         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
24456         *ret_conv = ClosureReason_read(ser_ref);
24457         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24458         return (int64_t)ret_conv;
24459 }
24460
24461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24462         if ((this_ptr & 1) != 0) return;
24463         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24464         CHECK_ACCESS(this_ptr_ptr);
24465         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
24466         FREE((void*)this_ptr);
24467         HTLCDestination_free(this_ptr_conv);
24468 }
24469
24470 static inline uintptr_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
24471         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24472         *ret_copy = HTLCDestination_clone(arg);
24473 int64_t ret_ref = (uintptr_t)ret_copy;
24474         return ret_ref;
24475 }
24476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24477         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)arg;
24478         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
24479         return ret_conv;
24480 }
24481
24482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24483         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)orig;
24484         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24485         *ret_copy = HTLCDestination_clone(orig_conv);
24486         int64_t ret_ref = (uintptr_t)ret_copy;
24487         return ret_ref;
24488 }
24489
24490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1next_1hop_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int8_tArray channel_id) {
24491         LDKPublicKey node_id_ref;
24492         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24493         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24494         LDKThirtyTwoBytes channel_id_ref;
24495         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24496         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24497         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24498         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
24499         int64_t ret_ref = (uintptr_t)ret_copy;
24500         return ret_ref;
24501 }
24502
24503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
24504         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24505         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
24506         int64_t ret_ref = (uintptr_t)ret_copy;
24507         return ret_ref;
24508 }
24509
24510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
24511         LDKThirtyTwoBytes payment_hash_ref;
24512         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24513         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24514         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24515         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
24516         int64_t ret_ref = (uintptr_t)ret_copy;
24517         return ret_ref;
24518 }
24519
24520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
24521         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)obj;
24522         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
24523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24525         CVec_u8Z_free(ret_var);
24526         return ret_arr;
24527 }
24528
24529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24530         LDKu8slice ser_ref;
24531         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24532         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24533         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
24534         *ret_conv = HTLCDestination_read(ser_ref);
24535         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24536         return (int64_t)ret_conv;
24537 }
24538
24539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24540         if ((this_ptr & 1) != 0) return;
24541         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24542         CHECK_ACCESS(this_ptr_ptr);
24543         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
24544         FREE((void*)this_ptr);
24545         Event_free(this_ptr_conv);
24546 }
24547
24548 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
24549         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24550         *ret_copy = Event_clone(arg);
24551 int64_t ret_ref = (uintptr_t)ret_copy;
24552         return ret_ref;
24553 }
24554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24555         LDKEvent* arg_conv = (LDKEvent*)arg;
24556         int64_t ret_conv = Event_clone_ptr(arg_conv);
24557         return ret_conv;
24558 }
24559
24560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24561         LDKEvent* orig_conv = (LDKEvent*)orig;
24562         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24563         *ret_copy = Event_clone(orig_conv);
24564         int64_t ret_ref = (uintptr_t)ret_copy;
24565         return ret_ref;
24566 }
24567
24568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
24569         LDKThirtyTwoBytes temporary_channel_id_ref;
24570         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24571         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24572         LDKPublicKey counterparty_node_id_ref;
24573         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24574         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24575         LDKCVec_u8Z output_script_ref;
24576         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
24577         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
24578         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
24579         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24580         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
24581         int64_t ret_ref = (uintptr_t)ret_copy;
24582         return ret_ref;
24583 }
24584
24585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
24586         LDKThirtyTwoBytes payment_hash_ref;
24587         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24588         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24589         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24590         CHECK_ACCESS(purpose_ptr);
24591         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24592         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24593         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24594         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
24595         int64_t ret_ref = (uintptr_t)ret_copy;
24596         return ret_ref;
24597 }
24598
24599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimed(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
24600         LDKThirtyTwoBytes payment_hash_ref;
24601         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24602         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24603         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24604         CHECK_ACCESS(purpose_ptr);
24605         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24606         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24607         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24608         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
24609         int64_t ret_ref = (uintptr_t)ret_copy;
24610         return ret_ref;
24611 }
24612
24613 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) {
24614         LDKThirtyTwoBytes payment_id_ref;
24615         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24616         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24617         LDKThirtyTwoBytes payment_preimage_ref;
24618         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24619         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24620         LDKThirtyTwoBytes payment_hash_ref;
24621         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24622         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24623         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
24624         CHECK_ACCESS(fee_paid_msat_ptr);
24625         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
24626         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
24627         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24628         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
24629         int64_t ret_ref = (uintptr_t)ret_copy;
24630         return ret_ref;
24631 }
24632
24633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
24634         LDKThirtyTwoBytes payment_id_ref;
24635         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24636         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24637         LDKThirtyTwoBytes payment_hash_ref;
24638         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24639         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24640         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24641         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
24642         int64_t ret_ref = (uintptr_t)ret_copy;
24643         return ret_ref;
24644 }
24645
24646 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) {
24647         LDKThirtyTwoBytes payment_id_ref;
24648         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24649         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24650         LDKThirtyTwoBytes payment_hash_ref;
24651         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24652         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24653         LDKCVec_RouteHopZ path_constr;
24654         path_constr.datalen = (*env)->GetArrayLength(env, path);
24655         if (path_constr.datalen > 0)
24656                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24657         else
24658                 path_constr.data = NULL;
24659         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24660         for (size_t k = 0; k < path_constr.datalen; k++) {
24661                 int64_t path_conv_10 = path_vals[k];
24662                 LDKRouteHop path_conv_10_conv;
24663                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24664                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24665                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24666                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24667                 path_constr.data[k] = path_conv_10_conv;
24668         }
24669         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24670         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24671         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
24672         int64_t ret_ref = (uintptr_t)ret_copy;
24673         return ret_ref;
24674 }
24675
24676 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) {
24677         LDKThirtyTwoBytes payment_id_ref;
24678         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24679         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24680         LDKThirtyTwoBytes payment_hash_ref;
24681         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24682         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24683         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
24684         CHECK_ACCESS(network_update_ptr);
24685         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
24686         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
24687         LDKCVec_RouteHopZ path_constr;
24688         path_constr.datalen = (*env)->GetArrayLength(env, path);
24689         if (path_constr.datalen > 0)
24690                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24691         else
24692                 path_constr.data = NULL;
24693         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24694         for (size_t k = 0; k < path_constr.datalen; k++) {
24695                 int64_t path_conv_10 = path_vals[k];
24696                 LDKRouteHop path_conv_10_conv;
24697                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24698                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24699                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24700                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24701                 path_constr.data[k] = path_conv_10_conv;
24702         }
24703         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24704         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
24705         CHECK_ACCESS(short_channel_id_ptr);
24706         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
24707         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
24708         LDKRouteParameters retry_conv;
24709         retry_conv.inner = (void*)(retry & (~1));
24710         retry_conv.is_owned = (retry & 1) || (retry == 0);
24711         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
24712         retry_conv = RouteParameters_clone(&retry_conv);
24713         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24714         *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);
24715         int64_t ret_ref = (uintptr_t)ret_copy;
24716         return ret_ref;
24717 }
24718
24719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path) {
24720         LDKThirtyTwoBytes payment_id_ref;
24721         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24722         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24723         LDKThirtyTwoBytes payment_hash_ref;
24724         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24725         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24726         LDKCVec_RouteHopZ path_constr;
24727         path_constr.datalen = (*env)->GetArrayLength(env, path);
24728         if (path_constr.datalen > 0)
24729                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24730         else
24731                 path_constr.data = NULL;
24732         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24733         for (size_t k = 0; k < path_constr.datalen; k++) {
24734                 int64_t path_conv_10 = path_vals[k];
24735                 LDKRouteHop path_conv_10_conv;
24736                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24737                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24738                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24739                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24740                 path_constr.data[k] = path_conv_10_conv;
24741         }
24742         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24743         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24744         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
24745         int64_t ret_ref = (uintptr_t)ret_copy;
24746         return ret_ref;
24747 }
24748
24749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path, int64_t short_channel_id) {
24750         LDKThirtyTwoBytes payment_id_ref;
24751         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24752         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24753         LDKThirtyTwoBytes payment_hash_ref;
24754         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24755         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24756         LDKCVec_RouteHopZ path_constr;
24757         path_constr.datalen = (*env)->GetArrayLength(env, path);
24758         if (path_constr.datalen > 0)
24759                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24760         else
24761                 path_constr.data = NULL;
24762         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24763         for (size_t k = 0; k < path_constr.datalen; k++) {
24764                 int64_t path_conv_10 = path_vals[k];
24765                 LDKRouteHop path_conv_10_conv;
24766                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24767                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24768                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24769                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24770                 path_constr.data[k] = path_conv_10_conv;
24771         }
24772         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24773         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
24774         CHECK_ACCESS(short_channel_id_ptr);
24775         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
24776         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
24777         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24778         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
24779         int64_t ret_ref = (uintptr_t)ret_copy;
24780         return ret_ref;
24781 }
24782
24783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
24784         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24785         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
24786         int64_t ret_ref = (uintptr_t)ret_copy;
24787         return ret_ref;
24788 }
24789
24790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
24791         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
24792         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
24793         if (outputs_constr.datalen > 0)
24794                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24795         else
24796                 outputs_constr.data = NULL;
24797         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
24798         for (size_t b = 0; b < outputs_constr.datalen; b++) {
24799                 int64_t outputs_conv_27 = outputs_vals[b];
24800                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
24801                 CHECK_ACCESS(outputs_conv_27_ptr);
24802                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
24803                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
24804                 outputs_constr.data[b] = outputs_conv_27_conv;
24805         }
24806         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
24807         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24808         *ret_copy = Event_spendable_outputs(outputs_constr);
24809         int64_t ret_ref = (uintptr_t)ret_copy;
24810         return ret_ref;
24811 }
24812
24813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int8_tArray next_channel_id, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
24814         LDKThirtyTwoBytes prev_channel_id_ref;
24815         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
24816         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
24817         LDKThirtyTwoBytes next_channel_id_ref;
24818         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
24819         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
24820         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
24821         CHECK_ACCESS(fee_earned_msat_ptr);
24822         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
24823         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
24824         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24825         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
24826         int64_t ret_ref = (uintptr_t)ret_copy;
24827         return ret_ref;
24828 }
24829
24830 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) {
24831         LDKThirtyTwoBytes channel_id_ref;
24832         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24833         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24834         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
24835         CHECK_ACCESS(reason_ptr);
24836         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
24837         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
24838         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24839         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
24840         int64_t ret_ref = (uintptr_t)ret_copy;
24841         return ret_ref;
24842 }
24843
24844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
24845         LDKThirtyTwoBytes channel_id_ref;
24846         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24847         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24848         LDKTransaction transaction_ref;
24849         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
24850         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
24851         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
24852         transaction_ref.data_is_owned = true;
24853         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24854         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
24855         int64_t ret_ref = (uintptr_t)ret_copy;
24856         return ret_ref;
24857 }
24858
24859 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) {
24860         LDKThirtyTwoBytes temporary_channel_id_ref;
24861         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24862         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24863         LDKPublicKey counterparty_node_id_ref;
24864         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24865         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24866         LDKChannelTypeFeatures channel_type_conv;
24867         channel_type_conv.inner = (void*)(channel_type & (~1));
24868         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
24869         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
24870         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
24871         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24872         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
24873         int64_t ret_ref = (uintptr_t)ret_copy;
24874         return ret_ref;
24875 }
24876
24877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1htlchandling_1failed(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int64_t failed_next_destination) {
24878         LDKThirtyTwoBytes prev_channel_id_ref;
24879         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
24880         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
24881         void* failed_next_destination_ptr = (void*)(((uintptr_t)failed_next_destination) & ~1);
24882         CHECK_ACCESS(failed_next_destination_ptr);
24883         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
24884         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)failed_next_destination) & ~1));
24885         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24886         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
24887         int64_t ret_ref = (uintptr_t)ret_copy;
24888         return ret_ref;
24889 }
24890
24891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
24892         LDKEvent* obj_conv = (LDKEvent*)obj;
24893         LDKCVec_u8Z ret_var = Event_write(obj_conv);
24894         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24895         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24896         CVec_u8Z_free(ret_var);
24897         return ret_arr;
24898 }
24899
24900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24901         LDKu8slice ser_ref;
24902         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24903         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24904         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
24905         *ret_conv = Event_read(ser_ref);
24906         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24907         return (int64_t)ret_conv;
24908 }
24909
24910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24911         if ((this_ptr & 1) != 0) return;
24912         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24913         CHECK_ACCESS(this_ptr_ptr);
24914         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
24915         FREE((void*)this_ptr);
24916         MessageSendEvent_free(this_ptr_conv);
24917 }
24918
24919 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
24920         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24921         *ret_copy = MessageSendEvent_clone(arg);
24922 int64_t ret_ref = (uintptr_t)ret_copy;
24923         return ret_ref;
24924 }
24925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24926         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
24927         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
24928         return ret_conv;
24929 }
24930
24931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24932         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
24933         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24934         *ret_copy = MessageSendEvent_clone(orig_conv);
24935         int64_t ret_ref = (uintptr_t)ret_copy;
24936         return ret_ref;
24937 }
24938
24939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24940         LDKPublicKey node_id_ref;
24941         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24942         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24943         LDKAcceptChannel msg_conv;
24944         msg_conv.inner = (void*)(msg & (~1));
24945         msg_conv.is_owned = (msg & 1) || (msg == 0);
24946         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24947         msg_conv = AcceptChannel_clone(&msg_conv);
24948         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24949         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
24950         int64_t ret_ref = (uintptr_t)ret_copy;
24951         return ret_ref;
24952 }
24953
24954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24955         LDKPublicKey node_id_ref;
24956         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24957         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24958         LDKOpenChannel msg_conv;
24959         msg_conv.inner = (void*)(msg & (~1));
24960         msg_conv.is_owned = (msg & 1) || (msg == 0);
24961         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24962         msg_conv = OpenChannel_clone(&msg_conv);
24963         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24964         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
24965         int64_t ret_ref = (uintptr_t)ret_copy;
24966         return ret_ref;
24967 }
24968
24969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24970         LDKPublicKey node_id_ref;
24971         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24972         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24973         LDKFundingCreated msg_conv;
24974         msg_conv.inner = (void*)(msg & (~1));
24975         msg_conv.is_owned = (msg & 1) || (msg == 0);
24976         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24977         msg_conv = FundingCreated_clone(&msg_conv);
24978         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24979         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
24980         int64_t ret_ref = (uintptr_t)ret_copy;
24981         return ret_ref;
24982 }
24983
24984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24985         LDKPublicKey node_id_ref;
24986         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24987         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24988         LDKFundingSigned msg_conv;
24989         msg_conv.inner = (void*)(msg & (~1));
24990         msg_conv.is_owned = (msg & 1) || (msg == 0);
24991         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24992         msg_conv = FundingSigned_clone(&msg_conv);
24993         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24994         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
24995         int64_t ret_ref = (uintptr_t)ret_copy;
24996         return ret_ref;
24997 }
24998
24999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25000         LDKPublicKey node_id_ref;
25001         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25002         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25003         LDKChannelReady msg_conv;
25004         msg_conv.inner = (void*)(msg & (~1));
25005         msg_conv.is_owned = (msg & 1) || (msg == 0);
25006         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25007         msg_conv = ChannelReady_clone(&msg_conv);
25008         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25009         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
25010         int64_t ret_ref = (uintptr_t)ret_copy;
25011         return ret_ref;
25012 }
25013
25014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25015         LDKPublicKey node_id_ref;
25016         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25017         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25018         LDKAnnouncementSignatures msg_conv;
25019         msg_conv.inner = (void*)(msg & (~1));
25020         msg_conv.is_owned = (msg & 1) || (msg == 0);
25021         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25022         msg_conv = AnnouncementSignatures_clone(&msg_conv);
25023         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25024         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
25025         int64_t ret_ref = (uintptr_t)ret_copy;
25026         return ret_ref;
25027 }
25028
25029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
25030         LDKPublicKey node_id_ref;
25031         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25032         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25033         LDKCommitmentUpdate updates_conv;
25034         updates_conv.inner = (void*)(updates & (~1));
25035         updates_conv.is_owned = (updates & 1) || (updates == 0);
25036         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
25037         updates_conv = CommitmentUpdate_clone(&updates_conv);
25038         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25039         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
25040         int64_t ret_ref = (uintptr_t)ret_copy;
25041         return ret_ref;
25042 }
25043
25044 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) {
25045         LDKPublicKey node_id_ref;
25046         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25047         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25048         LDKRevokeAndACK msg_conv;
25049         msg_conv.inner = (void*)(msg & (~1));
25050         msg_conv.is_owned = (msg & 1) || (msg == 0);
25051         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25052         msg_conv = RevokeAndACK_clone(&msg_conv);
25053         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25054         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
25055         int64_t ret_ref = (uintptr_t)ret_copy;
25056         return ret_ref;
25057 }
25058
25059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25060         LDKPublicKey node_id_ref;
25061         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25062         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25063         LDKClosingSigned msg_conv;
25064         msg_conv.inner = (void*)(msg & (~1));
25065         msg_conv.is_owned = (msg & 1) || (msg == 0);
25066         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25067         msg_conv = ClosingSigned_clone(&msg_conv);
25068         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25069         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
25070         int64_t ret_ref = (uintptr_t)ret_copy;
25071         return ret_ref;
25072 }
25073
25074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25075         LDKPublicKey node_id_ref;
25076         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25077         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25078         LDKShutdown msg_conv;
25079         msg_conv.inner = (void*)(msg & (~1));
25080         msg_conv.is_owned = (msg & 1) || (msg == 0);
25081         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25082         msg_conv = Shutdown_clone(&msg_conv);
25083         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25084         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
25085         int64_t ret_ref = (uintptr_t)ret_copy;
25086         return ret_ref;
25087 }
25088
25089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25090         LDKPublicKey node_id_ref;
25091         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25092         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25093         LDKChannelReestablish msg_conv;
25094         msg_conv.inner = (void*)(msg & (~1));
25095         msg_conv.is_owned = (msg & 1) || (msg == 0);
25096         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25097         msg_conv = ChannelReestablish_clone(&msg_conv);
25098         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25099         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
25100         int64_t ret_ref = (uintptr_t)ret_copy;
25101         return ret_ref;
25102 }
25103
25104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
25105         LDKChannelAnnouncement msg_conv;
25106         msg_conv.inner = (void*)(msg & (~1));
25107         msg_conv.is_owned = (msg & 1) || (msg == 0);
25108         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25109         msg_conv = ChannelAnnouncement_clone(&msg_conv);
25110         LDKChannelUpdate update_msg_conv;
25111         update_msg_conv.inner = (void*)(update_msg & (~1));
25112         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
25113         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
25114         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
25115         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25116         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
25117         int64_t ret_ref = (uintptr_t)ret_copy;
25118         return ret_ref;
25119 }
25120
25121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
25122         LDKNodeAnnouncement msg_conv;
25123         msg_conv.inner = (void*)(msg & (~1));
25124         msg_conv.is_owned = (msg & 1) || (msg == 0);
25125         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25126         msg_conv = NodeAnnouncement_clone(&msg_conv);
25127         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25128         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
25129         int64_t ret_ref = (uintptr_t)ret_copy;
25130         return ret_ref;
25131 }
25132
25133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
25134         LDKChannelUpdate msg_conv;
25135         msg_conv.inner = (void*)(msg & (~1));
25136         msg_conv.is_owned = (msg & 1) || (msg == 0);
25137         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25138         msg_conv = ChannelUpdate_clone(&msg_conv);
25139         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25140         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
25141         int64_t ret_ref = (uintptr_t)ret_copy;
25142         return ret_ref;
25143 }
25144
25145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25146         LDKPublicKey node_id_ref;
25147         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25148         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25149         LDKChannelUpdate msg_conv;
25150         msg_conv.inner = (void*)(msg & (~1));
25151         msg_conv.is_owned = (msg & 1) || (msg == 0);
25152         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25153         msg_conv = ChannelUpdate_clone(&msg_conv);
25154         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25155         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
25156         int64_t ret_ref = (uintptr_t)ret_copy;
25157         return ret_ref;
25158 }
25159
25160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
25161         LDKPublicKey node_id_ref;
25162         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25163         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25164         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
25165         CHECK_ACCESS(action_ptr);
25166         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
25167         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
25168         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25169         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
25170         int64_t ret_ref = (uintptr_t)ret_copy;
25171         return ret_ref;
25172 }
25173
25174 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) {
25175         LDKPublicKey node_id_ref;
25176         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25177         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25178         LDKQueryChannelRange msg_conv;
25179         msg_conv.inner = (void*)(msg & (~1));
25180         msg_conv.is_owned = (msg & 1) || (msg == 0);
25181         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25182         msg_conv = QueryChannelRange_clone(&msg_conv);
25183         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25184         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
25185         int64_t ret_ref = (uintptr_t)ret_copy;
25186         return ret_ref;
25187 }
25188
25189 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) {
25190         LDKPublicKey node_id_ref;
25191         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25192         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25193         LDKQueryShortChannelIds msg_conv;
25194         msg_conv.inner = (void*)(msg & (~1));
25195         msg_conv.is_owned = (msg & 1) || (msg == 0);
25196         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25197         msg_conv = QueryShortChannelIds_clone(&msg_conv);
25198         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25199         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
25200         int64_t ret_ref = (uintptr_t)ret_copy;
25201         return ret_ref;
25202 }
25203
25204 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) {
25205         LDKPublicKey node_id_ref;
25206         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25207         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25208         LDKReplyChannelRange msg_conv;
25209         msg_conv.inner = (void*)(msg & (~1));
25210         msg_conv.is_owned = (msg & 1) || (msg == 0);
25211         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25212         msg_conv = ReplyChannelRange_clone(&msg_conv);
25213         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25214         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
25215         int64_t ret_ref = (uintptr_t)ret_copy;
25216         return ret_ref;
25217 }
25218
25219 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) {
25220         LDKPublicKey node_id_ref;
25221         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25222         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25223         LDKGossipTimestampFilter msg_conv;
25224         msg_conv.inner = (void*)(msg & (~1));
25225         msg_conv.is_owned = (msg & 1) || (msg == 0);
25226         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25227         msg_conv = GossipTimestampFilter_clone(&msg_conv);
25228         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25229         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
25230         int64_t ret_ref = (uintptr_t)ret_copy;
25231         return ret_ref;
25232 }
25233
25234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25235         if ((this_ptr & 1) != 0) return;
25236         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25237         CHECK_ACCESS(this_ptr_ptr);
25238         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
25239         FREE((void*)this_ptr);
25240         MessageSendEventsProvider_free(this_ptr_conv);
25241 }
25242
25243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25244         if ((this_ptr & 1) != 0) return;
25245         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25246         CHECK_ACCESS(this_ptr_ptr);
25247         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
25248         FREE((void*)this_ptr);
25249         EventsProvider_free(this_ptr_conv);
25250 }
25251
25252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25253         if ((this_ptr & 1) != 0) return;
25254         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25255         CHECK_ACCESS(this_ptr_ptr);
25256         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
25257         FREE((void*)this_ptr);
25258         EventHandler_free(this_ptr_conv);
25259 }
25260
25261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25262         if ((this_ptr & 1) != 0) return;
25263         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25264         CHECK_ACCESS(this_ptr_ptr);
25265         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
25266         FREE((void*)this_ptr);
25267         APIError_free(this_ptr_conv);
25268 }
25269
25270 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
25271         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25272         *ret_copy = APIError_clone(arg);
25273 int64_t ret_ref = (uintptr_t)ret_copy;
25274         return ret_ref;
25275 }
25276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25277         LDKAPIError* arg_conv = (LDKAPIError*)arg;
25278         int64_t ret_conv = APIError_clone_ptr(arg_conv);
25279         return ret_conv;
25280 }
25281
25282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25283         LDKAPIError* orig_conv = (LDKAPIError*)orig;
25284         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25285         *ret_copy = APIError_clone(orig_conv);
25286         int64_t ret_ref = (uintptr_t)ret_copy;
25287         return ret_ref;
25288 }
25289
25290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
25291         LDKStr err_conv = java_to_owned_str(env, err);
25292         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25293         *ret_copy = APIError_apimisuse_error(err_conv);
25294         int64_t ret_ref = (uintptr_t)ret_copy;
25295         return ret_ref;
25296 }
25297
25298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
25299         LDKStr err_conv = java_to_owned_str(env, err);
25300         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25301         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
25302         int64_t ret_ref = (uintptr_t)ret_copy;
25303         return ret_ref;
25304 }
25305
25306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
25307         LDKStr err_conv = java_to_owned_str(env, err);
25308         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25309         *ret_copy = APIError_route_error(err_conv);
25310         int64_t ret_ref = (uintptr_t)ret_copy;
25311         return ret_ref;
25312 }
25313
25314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
25315         LDKStr err_conv = java_to_owned_str(env, err);
25316         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25317         *ret_copy = APIError_channel_unavailable(err_conv);
25318         int64_t ret_ref = (uintptr_t)ret_copy;
25319         return ret_ref;
25320 }
25321
25322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
25323         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25324         *ret_copy = APIError_monitor_update_failed();
25325         int64_t ret_ref = (uintptr_t)ret_copy;
25326         return ret_ref;
25327 }
25328
25329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
25330         LDKShutdownScript script_conv;
25331         script_conv.inner = (void*)(script & (~1));
25332         script_conv.is_owned = (script & 1) || (script == 0);
25333         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
25334         script_conv = ShutdownScript_clone(&script_conv);
25335         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25336         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
25337         int64_t ret_ref = (uintptr_t)ret_copy;
25338         return ret_ref;
25339 }
25340
25341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25342         LDKBigSize this_obj_conv;
25343         this_obj_conv.inner = (void*)(this_obj & (~1));
25344         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25346         BigSize_free(this_obj_conv);
25347 }
25348
25349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
25350         LDKBigSize this_ptr_conv;
25351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25352         this_ptr_conv.is_owned = false;
25353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25354         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
25355         return ret_conv;
25356 }
25357
25358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25359         LDKBigSize this_ptr_conv;
25360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25361         this_ptr_conv.is_owned = false;
25362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25363         BigSize_set_a(&this_ptr_conv, val);
25364 }
25365
25366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
25367         LDKBigSize ret_var = BigSize_new(a_arg);
25368         int64_t ret_ref = 0;
25369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25372         ret_ref = (uintptr_t)ret_var.inner;
25373         if (ret_var.is_owned) {
25374                 ret_ref |= 1;
25375         }
25376         return ret_ref;
25377 }
25378
25379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25380         LDKHostname this_obj_conv;
25381         this_obj_conv.inner = (void*)(this_obj & (~1));
25382         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25384         Hostname_free(this_obj_conv);
25385 }
25386
25387 static inline uintptr_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
25388         LDKHostname ret_var = Hostname_clone(arg);
25389 int64_t ret_ref = 0;
25390 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25391 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25392 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25393 ret_ref = (uintptr_t)ret_var.inner;
25394 if (ret_var.is_owned) {
25395         ret_ref |= 1;
25396 }
25397         return ret_ref;
25398 }
25399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25400         LDKHostname arg_conv;
25401         arg_conv.inner = (void*)(arg & (~1));
25402         arg_conv.is_owned = false;
25403         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25404         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
25405         return ret_conv;
25406 }
25407
25408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25409         LDKHostname orig_conv;
25410         orig_conv.inner = (void*)(orig & (~1));
25411         orig_conv.is_owned = false;
25412         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25413         LDKHostname ret_var = Hostname_clone(&orig_conv);
25414         int64_t ret_ref = 0;
25415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25418         ret_ref = (uintptr_t)ret_var.inner;
25419         if (ret_var.is_owned) {
25420                 ret_ref |= 1;
25421         }
25422         return ret_ref;
25423 }
25424
25425 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
25426         LDKHostname this_arg_conv;
25427         this_arg_conv.inner = (void*)(this_arg & (~1));
25428         this_arg_conv.is_owned = false;
25429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25430         int8_t ret_conv = Hostname_len(&this_arg_conv);
25431         return ret_conv;
25432 }
25433
25434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
25435         LDKu8slice msg_ref;
25436         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25437         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25438         unsigned char sk_arr[32];
25439         CHECK((*env)->GetArrayLength(env, sk) == 32);
25440         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
25441         unsigned char (*sk_ref)[32] = &sk_arr;
25442         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
25443         *ret_conv = sign(msg_ref, sk_ref);
25444         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25445         return (int64_t)ret_conv;
25446 }
25447
25448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
25449         LDKu8slice msg_ref;
25450         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25451         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25452         LDKStr sig_conv = java_to_owned_str(env, sig);
25453         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
25454         *ret_conv = recover_pk(msg_ref, sig_conv);
25455         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25456         return (int64_t)ret_conv;
25457 }
25458
25459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
25460         LDKu8slice msg_ref;
25461         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25462         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25463         LDKStr sig_conv = java_to_owned_str(env, sig);
25464         LDKPublicKey pk_ref;
25465         CHECK((*env)->GetArrayLength(env, pk) == 33);
25466         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
25467         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
25468         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25469         return ret_conv;
25470 }
25471
25472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
25473         LDKu8slice hrp_bytes_ref;
25474         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
25475         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
25476         LDKCVec_u5Z data_without_signature_constr;
25477         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
25478         if (data_without_signature_constr.datalen > 0)
25479                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
25480         else
25481                 data_without_signature_constr.data = NULL;
25482         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
25483         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
25484                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
25485                 
25486                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
25487         }
25488         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
25489         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
25490         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25491         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25492         CVec_u8Z_free(ret_var);
25493         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
25494         return ret_arr;
25495 }
25496
25497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25498         if ((this_ptr & 1) != 0) return;
25499         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25500         CHECK_ACCESS(this_ptr_ptr);
25501         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
25502         FREE((void*)this_ptr);
25503         Persister_free(this_ptr_conv);
25504 }
25505
25506 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25507         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
25508         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
25509         return ret_conv;
25510 }
25511
25512 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
25513         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
25514         return ret_conv;
25515 }
25516
25517 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
25518         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
25519         return ret_conv;
25520 }
25521
25522 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
25523         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
25524         return ret_conv;
25525 }
25526
25527 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
25528         jclass ret_conv = LDKLevel_to_java(env, Level_info());
25529         return ret_conv;
25530 }
25531
25532 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
25533         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
25534         return ret_conv;
25535 }
25536
25537 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
25538         jclass ret_conv = LDKLevel_to_java(env, Level_error());
25539         return ret_conv;
25540 }
25541
25542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25543         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
25544         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
25545         jboolean ret_conv = Level_eq(a_conv, b_conv);
25546         return ret_conv;
25547 }
25548
25549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
25550         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
25551         int64_t ret_conv = Level_hash(o_conv);
25552         return ret_conv;
25553 }
25554
25555 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
25556         jclass ret_conv = LDKLevel_to_java(env, Level_max());
25557         return ret_conv;
25558 }
25559
25560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25561         LDKRecord this_obj_conv;
25562         this_obj_conv.inner = (void*)(this_obj & (~1));
25563         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25565         Record_free(this_obj_conv);
25566 }
25567
25568 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
25569         LDKRecord this_ptr_conv;
25570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25571         this_ptr_conv.is_owned = false;
25572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25573         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
25574         return ret_conv;
25575 }
25576
25577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
25578         LDKRecord this_ptr_conv;
25579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25580         this_ptr_conv.is_owned = false;
25581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25582         LDKLevel val_conv = LDKLevel_from_java(env, val);
25583         Record_set_level(&this_ptr_conv, val_conv);
25584 }
25585
25586 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
25587         LDKRecord this_ptr_conv;
25588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25589         this_ptr_conv.is_owned = false;
25590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25591         LDKStr ret_str = Record_get_args(&this_ptr_conv);
25592         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25593         Str_free(ret_str);
25594         return ret_conv;
25595 }
25596
25597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25598         LDKRecord this_ptr_conv;
25599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25600         this_ptr_conv.is_owned = false;
25601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25602         LDKStr val_conv = java_to_owned_str(env, val);
25603         Record_set_args(&this_ptr_conv, val_conv);
25604 }
25605
25606 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
25607         LDKRecord this_ptr_conv;
25608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25609         this_ptr_conv.is_owned = false;
25610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25611         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
25612         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25613         Str_free(ret_str);
25614         return ret_conv;
25615 }
25616
25617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25618         LDKRecord this_ptr_conv;
25619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25620         this_ptr_conv.is_owned = false;
25621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25622         LDKStr val_conv = java_to_owned_str(env, val);
25623         Record_set_module_path(&this_ptr_conv, val_conv);
25624 }
25625
25626 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
25627         LDKRecord this_ptr_conv;
25628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25629         this_ptr_conv.is_owned = false;
25630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25631         LDKStr ret_str = Record_get_file(&this_ptr_conv);
25632         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25633         Str_free(ret_str);
25634         return ret_conv;
25635 }
25636
25637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25638         LDKRecord this_ptr_conv;
25639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25640         this_ptr_conv.is_owned = false;
25641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25642         LDKStr val_conv = java_to_owned_str(env, val);
25643         Record_set_file(&this_ptr_conv, val_conv);
25644 }
25645
25646 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
25647         LDKRecord this_ptr_conv;
25648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25649         this_ptr_conv.is_owned = false;
25650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25651         int32_t ret_conv = Record_get_line(&this_ptr_conv);
25652         return ret_conv;
25653 }
25654
25655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25656         LDKRecord this_ptr_conv;
25657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25658         this_ptr_conv.is_owned = false;
25659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25660         Record_set_line(&this_ptr_conv, val);
25661 }
25662
25663 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
25664         LDKRecord ret_var = Record_clone(arg);
25665 int64_t ret_ref = 0;
25666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25669 ret_ref = (uintptr_t)ret_var.inner;
25670 if (ret_var.is_owned) {
25671         ret_ref |= 1;
25672 }
25673         return ret_ref;
25674 }
25675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25676         LDKRecord arg_conv;
25677         arg_conv.inner = (void*)(arg & (~1));
25678         arg_conv.is_owned = false;
25679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25680         int64_t ret_conv = Record_clone_ptr(&arg_conv);
25681         return ret_conv;
25682 }
25683
25684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25685         LDKRecord orig_conv;
25686         orig_conv.inner = (void*)(orig & (~1));
25687         orig_conv.is_owned = false;
25688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25689         LDKRecord ret_var = Record_clone(&orig_conv);
25690         int64_t ret_ref = 0;
25691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25694         ret_ref = (uintptr_t)ret_var.inner;
25695         if (ret_var.is_owned) {
25696                 ret_ref |= 1;
25697         }
25698         return ret_ref;
25699 }
25700
25701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25702         if ((this_ptr & 1) != 0) return;
25703         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25704         CHECK_ACCESS(this_ptr_ptr);
25705         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
25706         FREE((void*)this_ptr);
25707         Logger_free(this_ptr_conv);
25708 }
25709
25710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25711         LDKChannelHandshakeConfig this_obj_conv;
25712         this_obj_conv.inner = (void*)(this_obj & (~1));
25713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25715         ChannelHandshakeConfig_free(this_obj_conv);
25716 }
25717
25718 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
25719         LDKChannelHandshakeConfig this_ptr_conv;
25720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25721         this_ptr_conv.is_owned = false;
25722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25723         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
25724         return ret_conv;
25725 }
25726
25727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25728         LDKChannelHandshakeConfig this_ptr_conv;
25729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25730         this_ptr_conv.is_owned = false;
25731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25732         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
25733 }
25734
25735 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25736         LDKChannelHandshakeConfig this_ptr_conv;
25737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25738         this_ptr_conv.is_owned = false;
25739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25740         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
25741         return ret_conv;
25742 }
25743
25744 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) {
25745         LDKChannelHandshakeConfig this_ptr_conv;
25746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25747         this_ptr_conv.is_owned = false;
25748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25749         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
25750 }
25751
25752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25753         LDKChannelHandshakeConfig this_ptr_conv;
25754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25755         this_ptr_conv.is_owned = false;
25756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25757         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
25758         return ret_conv;
25759 }
25760
25761 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) {
25762         LDKChannelHandshakeConfig this_ptr_conv;
25763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25764         this_ptr_conv.is_owned = false;
25765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25766         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
25767 }
25768
25769 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
25770         LDKChannelHandshakeConfig this_ptr_conv;
25771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25772         this_ptr_conv.is_owned = false;
25773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25774         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
25775         return ret_conv;
25776 }
25777
25778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
25779         LDKChannelHandshakeConfig this_ptr_conv;
25780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25781         this_ptr_conv.is_owned = false;
25782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25783         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
25784 }
25785
25786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
25787         LDKChannelHandshakeConfig this_ptr_conv;
25788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25789         this_ptr_conv.is_owned = false;
25790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25791         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
25792         return ret_conv;
25793 }
25794
25795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25796         LDKChannelHandshakeConfig this_ptr_conv;
25797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25798         this_ptr_conv.is_owned = false;
25799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25800         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
25801 }
25802
25803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
25804         LDKChannelHandshakeConfig this_ptr_conv;
25805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25806         this_ptr_conv.is_owned = false;
25807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25808         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
25809         return ret_conv;
25810 }
25811
25812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25813         LDKChannelHandshakeConfig this_ptr_conv;
25814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25815         this_ptr_conv.is_owned = false;
25816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25817         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
25818 }
25819
25820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25821         LDKChannelHandshakeConfig this_ptr_conv;
25822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25823         this_ptr_conv.is_owned = false;
25824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25825         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
25826         return ret_conv;
25827 }
25828
25829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25830         LDKChannelHandshakeConfig this_ptr_conv;
25831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25832         this_ptr_conv.is_owned = false;
25833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25834         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
25835 }
25836
25837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
25838         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
25839         int64_t ret_ref = 0;
25840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25843         ret_ref = (uintptr_t)ret_var.inner;
25844         if (ret_var.is_owned) {
25845                 ret_ref |= 1;
25846         }
25847         return ret_ref;
25848 }
25849
25850 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
25851         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
25852 int64_t ret_ref = 0;
25853 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25854 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25855 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25856 ret_ref = (uintptr_t)ret_var.inner;
25857 if (ret_var.is_owned) {
25858         ret_ref |= 1;
25859 }
25860         return ret_ref;
25861 }
25862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25863         LDKChannelHandshakeConfig arg_conv;
25864         arg_conv.inner = (void*)(arg & (~1));
25865         arg_conv.is_owned = false;
25866         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25867         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
25868         return ret_conv;
25869 }
25870
25871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25872         LDKChannelHandshakeConfig orig_conv;
25873         orig_conv.inner = (void*)(orig & (~1));
25874         orig_conv.is_owned = false;
25875         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25876         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
25877         int64_t ret_ref = 0;
25878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25881         ret_ref = (uintptr_t)ret_var.inner;
25882         if (ret_var.is_owned) {
25883                 ret_ref |= 1;
25884         }
25885         return ret_ref;
25886 }
25887
25888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
25889         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
25890         int64_t ret_ref = 0;
25891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25894         ret_ref = (uintptr_t)ret_var.inner;
25895         if (ret_var.is_owned) {
25896                 ret_ref |= 1;
25897         }
25898         return ret_ref;
25899 }
25900
25901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25902         LDKChannelHandshakeLimits this_obj_conv;
25903         this_obj_conv.inner = (void*)(this_obj & (~1));
25904         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25906         ChannelHandshakeLimits_free(this_obj_conv);
25907 }
25908
25909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25910         LDKChannelHandshakeLimits this_ptr_conv;
25911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25912         this_ptr_conv.is_owned = false;
25913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25914         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
25915         return ret_conv;
25916 }
25917
25918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25919         LDKChannelHandshakeLimits this_ptr_conv;
25920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25921         this_ptr_conv.is_owned = false;
25922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25923         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
25924 }
25925
25926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25927         LDKChannelHandshakeLimits this_ptr_conv;
25928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25929         this_ptr_conv.is_owned = false;
25930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25931         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
25932         return ret_conv;
25933 }
25934
25935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25936         LDKChannelHandshakeLimits this_ptr_conv;
25937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25938         this_ptr_conv.is_owned = false;
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25940         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
25941 }
25942
25943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25944         LDKChannelHandshakeLimits this_ptr_conv;
25945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25946         this_ptr_conv.is_owned = false;
25947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25948         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
25949         return ret_conv;
25950 }
25951
25952 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) {
25953         LDKChannelHandshakeLimits this_ptr_conv;
25954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25955         this_ptr_conv.is_owned = false;
25956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25957         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
25958 }
25959
25960 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) {
25961         LDKChannelHandshakeLimits this_ptr_conv;
25962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25963         this_ptr_conv.is_owned = false;
25964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25965         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
25966         return ret_conv;
25967 }
25968
25969 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) {
25970         LDKChannelHandshakeLimits this_ptr_conv;
25971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25972         this_ptr_conv.is_owned = false;
25973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25974         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
25975 }
25976
25977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25978         LDKChannelHandshakeLimits this_ptr_conv;
25979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25980         this_ptr_conv.is_owned = false;
25981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25982         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
25983         return ret_conv;
25984 }
25985
25986 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) {
25987         LDKChannelHandshakeLimits this_ptr_conv;
25988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25989         this_ptr_conv.is_owned = false;
25990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25991         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
25992 }
25993
25994 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25995         LDKChannelHandshakeLimits this_ptr_conv;
25996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25997         this_ptr_conv.is_owned = false;
25998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25999         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
26000         return ret_conv;
26001 }
26002
26003 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) {
26004         LDKChannelHandshakeLimits this_ptr_conv;
26005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26006         this_ptr_conv.is_owned = false;
26007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26008         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
26009 }
26010
26011 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26012         LDKChannelHandshakeLimits this_ptr_conv;
26013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26014         this_ptr_conv.is_owned = false;
26015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26016         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
26017         return ret_conv;
26018 }
26019
26020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26021         LDKChannelHandshakeLimits this_ptr_conv;
26022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26023         this_ptr_conv.is_owned = false;
26024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26025         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
26026 }
26027
26028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
26029         LDKChannelHandshakeLimits this_ptr_conv;
26030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26031         this_ptr_conv.is_owned = false;
26032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26033         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
26034         return ret_conv;
26035 }
26036
26037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26038         LDKChannelHandshakeLimits this_ptr_conv;
26039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26040         this_ptr_conv.is_owned = false;
26041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26042         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
26043 }
26044
26045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
26046         LDKChannelHandshakeLimits this_ptr_conv;
26047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26048         this_ptr_conv.is_owned = false;
26049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26050         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
26051         return ret_conv;
26052 }
26053
26054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26055         LDKChannelHandshakeLimits this_ptr_conv;
26056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26057         this_ptr_conv.is_owned = false;
26058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26059         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
26060 }
26061
26062 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26063         LDKChannelHandshakeLimits this_ptr_conv;
26064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26065         this_ptr_conv.is_owned = false;
26066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26067         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
26068         return ret_conv;
26069 }
26070
26071 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) {
26072         LDKChannelHandshakeLimits this_ptr_conv;
26073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26074         this_ptr_conv.is_owned = false;
26075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26076         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
26077 }
26078
26079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean trust_own_funding_0conf_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
26080         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
26081         int64_t ret_ref = 0;
26082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26085         ret_ref = (uintptr_t)ret_var.inner;
26086         if (ret_var.is_owned) {
26087                 ret_ref |= 1;
26088         }
26089         return ret_ref;
26090 }
26091
26092 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
26093         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
26094 int64_t ret_ref = 0;
26095 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26096 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26097 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26098 ret_ref = (uintptr_t)ret_var.inner;
26099 if (ret_var.is_owned) {
26100         ret_ref |= 1;
26101 }
26102         return ret_ref;
26103 }
26104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26105         LDKChannelHandshakeLimits arg_conv;
26106         arg_conv.inner = (void*)(arg & (~1));
26107         arg_conv.is_owned = false;
26108         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26109         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
26110         return ret_conv;
26111 }
26112
26113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26114         LDKChannelHandshakeLimits orig_conv;
26115         orig_conv.inner = (void*)(orig & (~1));
26116         orig_conv.is_owned = false;
26117         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26118         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
26119         int64_t ret_ref = 0;
26120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26123         ret_ref = (uintptr_t)ret_var.inner;
26124         if (ret_var.is_owned) {
26125                 ret_ref |= 1;
26126         }
26127         return ret_ref;
26128 }
26129
26130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
26131         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
26132         int64_t ret_ref = 0;
26133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26136         ret_ref = (uintptr_t)ret_var.inner;
26137         if (ret_var.is_owned) {
26138                 ret_ref |= 1;
26139         }
26140         return ret_ref;
26141 }
26142
26143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26144         LDKChannelConfig this_obj_conv;
26145         this_obj_conv.inner = (void*)(this_obj & (~1));
26146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26148         ChannelConfig_free(this_obj_conv);
26149 }
26150
26151 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
26152         LDKChannelConfig this_ptr_conv;
26153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26154         this_ptr_conv.is_owned = false;
26155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26156         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
26157         return ret_conv;
26158 }
26159
26160 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) {
26161         LDKChannelConfig this_ptr_conv;
26162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26163         this_ptr_conv.is_owned = false;
26164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26165         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
26166 }
26167
26168 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26169         LDKChannelConfig this_ptr_conv;
26170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26171         this_ptr_conv.is_owned = false;
26172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26173         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
26174         return ret_conv;
26175 }
26176
26177 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) {
26178         LDKChannelConfig this_ptr_conv;
26179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26180         this_ptr_conv.is_owned = false;
26181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26182         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
26183 }
26184
26185 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
26186         LDKChannelConfig this_ptr_conv;
26187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26188         this_ptr_conv.is_owned = false;
26189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26190         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
26191         return ret_conv;
26192 }
26193
26194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26195         LDKChannelConfig this_ptr_conv;
26196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26197         this_ptr_conv.is_owned = false;
26198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26199         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
26200 }
26201
26202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26203         LDKChannelConfig this_ptr_conv;
26204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26205         this_ptr_conv.is_owned = false;
26206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26207         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
26208         return ret_conv;
26209 }
26210
26211 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) {
26212         LDKChannelConfig this_ptr_conv;
26213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26214         this_ptr_conv.is_owned = false;
26215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26216         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
26217 }
26218
26219 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) {
26220         LDKChannelConfig this_ptr_conv;
26221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26222         this_ptr_conv.is_owned = false;
26223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26224         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
26225         return ret_conv;
26226 }
26227
26228 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) {
26229         LDKChannelConfig this_ptr_conv;
26230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26231         this_ptr_conv.is_owned = false;
26232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26233         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
26234 }
26235
26236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
26237         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
26238         int64_t ret_ref = 0;
26239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26242         ret_ref = (uintptr_t)ret_var.inner;
26243         if (ret_var.is_owned) {
26244                 ret_ref |= 1;
26245         }
26246         return ret_ref;
26247 }
26248
26249 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
26250         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
26251 int64_t ret_ref = 0;
26252 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26253 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26254 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26255 ret_ref = (uintptr_t)ret_var.inner;
26256 if (ret_var.is_owned) {
26257         ret_ref |= 1;
26258 }
26259         return ret_ref;
26260 }
26261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26262         LDKChannelConfig arg_conv;
26263         arg_conv.inner = (void*)(arg & (~1));
26264         arg_conv.is_owned = false;
26265         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26266         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
26267         return ret_conv;
26268 }
26269
26270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26271         LDKChannelConfig orig_conv;
26272         orig_conv.inner = (void*)(orig & (~1));
26273         orig_conv.is_owned = false;
26274         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26275         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
26276         int64_t ret_ref = 0;
26277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26280         ret_ref = (uintptr_t)ret_var.inner;
26281         if (ret_var.is_owned) {
26282                 ret_ref |= 1;
26283         }
26284         return ret_ref;
26285 }
26286
26287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
26288         LDKChannelConfig ret_var = ChannelConfig_default();
26289         int64_t ret_ref = 0;
26290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26293         ret_ref = (uintptr_t)ret_var.inner;
26294         if (ret_var.is_owned) {
26295                 ret_ref |= 1;
26296         }
26297         return ret_ref;
26298 }
26299
26300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
26301         LDKChannelConfig obj_conv;
26302         obj_conv.inner = (void*)(obj & (~1));
26303         obj_conv.is_owned = false;
26304         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26305         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
26306         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26307         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26308         CVec_u8Z_free(ret_var);
26309         return ret_arr;
26310 }
26311
26312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26313         LDKu8slice ser_ref;
26314         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26315         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26316         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
26317         *ret_conv = ChannelConfig_read(ser_ref);
26318         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26319         return (int64_t)ret_conv;
26320 }
26321
26322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26323         LDKUserConfig this_obj_conv;
26324         this_obj_conv.inner = (void*)(this_obj & (~1));
26325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26327         UserConfig_free(this_obj_conv);
26328 }
26329
26330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
26331         LDKUserConfig this_ptr_conv;
26332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26333         this_ptr_conv.is_owned = false;
26334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26335         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
26336         int64_t ret_ref = 0;
26337         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26338         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26340         ret_ref = (uintptr_t)ret_var.inner;
26341         if (ret_var.is_owned) {
26342                 ret_ref |= 1;
26343         }
26344         return ret_ref;
26345 }
26346
26347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26348         LDKUserConfig this_ptr_conv;
26349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26350         this_ptr_conv.is_owned = false;
26351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26352         LDKChannelHandshakeConfig val_conv;
26353         val_conv.inner = (void*)(val & (~1));
26354         val_conv.is_owned = (val & 1) || (val == 0);
26355         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26356         val_conv = ChannelHandshakeConfig_clone(&val_conv);
26357         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
26358 }
26359
26360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
26361         LDKUserConfig this_ptr_conv;
26362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26363         this_ptr_conv.is_owned = false;
26364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26365         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
26366         int64_t ret_ref = 0;
26367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26370         ret_ref = (uintptr_t)ret_var.inner;
26371         if (ret_var.is_owned) {
26372                 ret_ref |= 1;
26373         }
26374         return ret_ref;
26375 }
26376
26377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26378         LDKUserConfig this_ptr_conv;
26379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26380         this_ptr_conv.is_owned = false;
26381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26382         LDKChannelHandshakeLimits val_conv;
26383         val_conv.inner = (void*)(val & (~1));
26384         val_conv.is_owned = (val & 1) || (val == 0);
26385         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26386         val_conv = ChannelHandshakeLimits_clone(&val_conv);
26387         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
26388 }
26389
26390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
26391         LDKUserConfig this_ptr_conv;
26392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26393         this_ptr_conv.is_owned = false;
26394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26395         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
26396         int64_t ret_ref = 0;
26397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26400         ret_ref = (uintptr_t)ret_var.inner;
26401         if (ret_var.is_owned) {
26402                 ret_ref |= 1;
26403         }
26404         return ret_ref;
26405 }
26406
26407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26408         LDKUserConfig this_ptr_conv;
26409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26410         this_ptr_conv.is_owned = false;
26411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26412         LDKChannelConfig val_conv;
26413         val_conv.inner = (void*)(val & (~1));
26414         val_conv.is_owned = (val & 1) || (val == 0);
26415         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26416         val_conv = ChannelConfig_clone(&val_conv);
26417         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
26418 }
26419
26420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26421         LDKUserConfig this_ptr_conv;
26422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26423         this_ptr_conv.is_owned = false;
26424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26425         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
26426         return ret_conv;
26427 }
26428
26429 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) {
26430         LDKUserConfig this_ptr_conv;
26431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26432         this_ptr_conv.is_owned = false;
26433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26434         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
26435 }
26436
26437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26438         LDKUserConfig this_ptr_conv;
26439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26440         this_ptr_conv.is_owned = false;
26441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26442         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
26443         return ret_conv;
26444 }
26445
26446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26447         LDKUserConfig this_ptr_conv;
26448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26449         this_ptr_conv.is_owned = false;
26450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26451         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
26452 }
26453
26454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26455         LDKUserConfig this_ptr_conv;
26456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26457         this_ptr_conv.is_owned = false;
26458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26459         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
26460         return ret_conv;
26461 }
26462
26463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26464         LDKUserConfig this_ptr_conv;
26465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26466         this_ptr_conv.is_owned = false;
26467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26468         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
26469 }
26470
26471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t channel_handshake_config_arg, int64_t channel_handshake_limits_arg, int64_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
26472         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
26473         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
26474         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
26475         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
26476         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
26477         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
26478         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
26479         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
26480         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
26481         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
26482         LDKChannelConfig channel_config_arg_conv;
26483         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
26484         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
26485         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
26486         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
26487         LDKUserConfig ret_var = UserConfig_new(channel_handshake_config_arg_conv, channel_handshake_limits_arg_conv, channel_config_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
26488         int64_t ret_ref = 0;
26489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26492         ret_ref = (uintptr_t)ret_var.inner;
26493         if (ret_var.is_owned) {
26494                 ret_ref |= 1;
26495         }
26496         return ret_ref;
26497 }
26498
26499 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
26500         LDKUserConfig ret_var = UserConfig_clone(arg);
26501 int64_t ret_ref = 0;
26502 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26503 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26504 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26505 ret_ref = (uintptr_t)ret_var.inner;
26506 if (ret_var.is_owned) {
26507         ret_ref |= 1;
26508 }
26509         return ret_ref;
26510 }
26511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26512         LDKUserConfig arg_conv;
26513         arg_conv.inner = (void*)(arg & (~1));
26514         arg_conv.is_owned = false;
26515         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26516         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
26517         return ret_conv;
26518 }
26519
26520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26521         LDKUserConfig orig_conv;
26522         orig_conv.inner = (void*)(orig & (~1));
26523         orig_conv.is_owned = false;
26524         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26525         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
26526         int64_t ret_ref = 0;
26527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26530         ret_ref = (uintptr_t)ret_var.inner;
26531         if (ret_var.is_owned) {
26532                 ret_ref |= 1;
26533         }
26534         return ret_ref;
26535 }
26536
26537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
26538         LDKUserConfig ret_var = UserConfig_default();
26539         int64_t ret_ref = 0;
26540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26543         ret_ref = (uintptr_t)ret_var.inner;
26544         if (ret_var.is_owned) {
26545                 ret_ref |= 1;
26546         }
26547         return ret_ref;
26548 }
26549
26550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26551         LDKBestBlock this_obj_conv;
26552         this_obj_conv.inner = (void*)(this_obj & (~1));
26553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26555         BestBlock_free(this_obj_conv);
26556 }
26557
26558 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
26559         LDKBestBlock ret_var = BestBlock_clone(arg);
26560 int64_t ret_ref = 0;
26561 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26562 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26563 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26564 ret_ref = (uintptr_t)ret_var.inner;
26565 if (ret_var.is_owned) {
26566         ret_ref |= 1;
26567 }
26568         return ret_ref;
26569 }
26570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26571         LDKBestBlock arg_conv;
26572         arg_conv.inner = (void*)(arg & (~1));
26573         arg_conv.is_owned = false;
26574         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26575         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
26576         return ret_conv;
26577 }
26578
26579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26580         LDKBestBlock orig_conv;
26581         orig_conv.inner = (void*)(orig & (~1));
26582         orig_conv.is_owned = false;
26583         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26584         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
26585         int64_t ret_ref = 0;
26586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26589         ret_ref = (uintptr_t)ret_var.inner;
26590         if (ret_var.is_owned) {
26591                 ret_ref |= 1;
26592         }
26593         return ret_ref;
26594 }
26595
26596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
26597         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
26598         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
26599         int64_t ret_ref = 0;
26600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26603         ret_ref = (uintptr_t)ret_var.inner;
26604         if (ret_var.is_owned) {
26605                 ret_ref |= 1;
26606         }
26607         return ret_ref;
26608 }
26609
26610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
26611         LDKThirtyTwoBytes block_hash_ref;
26612         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
26613         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
26614         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
26615         int64_t ret_ref = 0;
26616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26619         ret_ref = (uintptr_t)ret_var.inner;
26620         if (ret_var.is_owned) {
26621                 ret_ref |= 1;
26622         }
26623         return ret_ref;
26624 }
26625
26626 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26627         LDKBestBlock this_arg_conv;
26628         this_arg_conv.inner = (void*)(this_arg & (~1));
26629         this_arg_conv.is_owned = false;
26630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26631         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26632         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
26633         return ret_arr;
26634 }
26635
26636 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
26637         LDKBestBlock this_arg_conv;
26638         this_arg_conv.inner = (void*)(this_arg & (~1));
26639         this_arg_conv.is_owned = false;
26640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26641         int32_t ret_conv = BestBlock_height(&this_arg_conv);
26642         return ret_conv;
26643 }
26644
26645 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26646         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
26647         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
26648         return ret_conv;
26649 }
26650
26651 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
26652         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
26653         return ret_conv;
26654 }
26655
26656 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
26657         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
26658         return ret_conv;
26659 }
26660
26661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26662         if ((this_ptr & 1) != 0) return;
26663         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26664         CHECK_ACCESS(this_ptr_ptr);
26665         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
26666         FREE((void*)this_ptr);
26667         Access_free(this_ptr_conv);
26668 }
26669
26670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26671         if ((this_ptr & 1) != 0) return;
26672         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26673         CHECK_ACCESS(this_ptr_ptr);
26674         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
26675         FREE((void*)this_ptr);
26676         Listen_free(this_ptr_conv);
26677 }
26678
26679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26680         if ((this_ptr & 1) != 0) return;
26681         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26682         CHECK_ACCESS(this_ptr_ptr);
26683         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
26684         FREE((void*)this_ptr);
26685         Confirm_free(this_ptr_conv);
26686 }
26687
26688 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26689         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
26690         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
26691         return ret_conv;
26692 }
26693
26694 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
26695         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
26696         return ret_conv;
26697 }
26698
26699 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
26700         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
26701         return ret_conv;
26702 }
26703
26704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26705         if ((this_ptr & 1) != 0) return;
26706         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26707         CHECK_ACCESS(this_ptr_ptr);
26708         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
26709         FREE((void*)this_ptr);
26710         Watch_free(this_ptr_conv);
26711 }
26712
26713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26714         if ((this_ptr & 1) != 0) return;
26715         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26716         CHECK_ACCESS(this_ptr_ptr);
26717         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
26718         FREE((void*)this_ptr);
26719         Filter_free(this_ptr_conv);
26720 }
26721
26722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26723         LDKWatchedOutput this_obj_conv;
26724         this_obj_conv.inner = (void*)(this_obj & (~1));
26725         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26727         WatchedOutput_free(this_obj_conv);
26728 }
26729
26730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
26731         LDKWatchedOutput this_ptr_conv;
26732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26733         this_ptr_conv.is_owned = false;
26734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26735         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
26737         return ret_arr;
26738 }
26739
26740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26741         LDKWatchedOutput this_ptr_conv;
26742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26743         this_ptr_conv.is_owned = false;
26744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26745         LDKThirtyTwoBytes val_ref;
26746         CHECK((*env)->GetArrayLength(env, val) == 32);
26747         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26748         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
26749 }
26750
26751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26752         LDKWatchedOutput this_ptr_conv;
26753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26754         this_ptr_conv.is_owned = false;
26755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26756         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
26757         int64_t ret_ref = 0;
26758         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26759         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26761         ret_ref = (uintptr_t)ret_var.inner;
26762         if (ret_var.is_owned) {
26763                 ret_ref |= 1;
26764         }
26765         return ret_ref;
26766 }
26767
26768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26769         LDKWatchedOutput this_ptr_conv;
26770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26771         this_ptr_conv.is_owned = false;
26772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26773         LDKOutPoint val_conv;
26774         val_conv.inner = (void*)(val & (~1));
26775         val_conv.is_owned = (val & 1) || (val == 0);
26776         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26777         val_conv = OutPoint_clone(&val_conv);
26778         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
26779 }
26780
26781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26782         LDKWatchedOutput this_ptr_conv;
26783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26784         this_ptr_conv.is_owned = false;
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26786         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
26787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26789         return ret_arr;
26790 }
26791
26792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26793         LDKWatchedOutput this_ptr_conv;
26794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26795         this_ptr_conv.is_owned = false;
26796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26797         LDKCVec_u8Z val_ref;
26798         val_ref.datalen = (*env)->GetArrayLength(env, val);
26799         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
26800         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26801         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
26802 }
26803
26804 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) {
26805         LDKThirtyTwoBytes block_hash_arg_ref;
26806         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
26807         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
26808         LDKOutPoint outpoint_arg_conv;
26809         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26810         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26811         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26812         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26813         LDKCVec_u8Z script_pubkey_arg_ref;
26814         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
26815         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
26816         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
26817         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
26818         int64_t ret_ref = 0;
26819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26822         ret_ref = (uintptr_t)ret_var.inner;
26823         if (ret_var.is_owned) {
26824                 ret_ref |= 1;
26825         }
26826         return ret_ref;
26827 }
26828
26829 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
26830         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
26831 int64_t ret_ref = 0;
26832 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26833 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26834 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26835 ret_ref = (uintptr_t)ret_var.inner;
26836 if (ret_var.is_owned) {
26837         ret_ref |= 1;
26838 }
26839         return ret_ref;
26840 }
26841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26842         LDKWatchedOutput arg_conv;
26843         arg_conv.inner = (void*)(arg & (~1));
26844         arg_conv.is_owned = false;
26845         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26846         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
26847         return ret_conv;
26848 }
26849
26850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26851         LDKWatchedOutput orig_conv;
26852         orig_conv.inner = (void*)(orig & (~1));
26853         orig_conv.is_owned = false;
26854         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26855         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
26856         int64_t ret_ref = 0;
26857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26860         ret_ref = (uintptr_t)ret_var.inner;
26861         if (ret_var.is_owned) {
26862                 ret_ref |= 1;
26863         }
26864         return ret_ref;
26865 }
26866
26867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
26868         LDKWatchedOutput o_conv;
26869         o_conv.inner = (void*)(o & (~1));
26870         o_conv.is_owned = false;
26871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26872         int64_t ret_conv = WatchedOutput_hash(&o_conv);
26873         return ret_conv;
26874 }
26875
26876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26877         if ((this_ptr & 1) != 0) return;
26878         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26879         CHECK_ACCESS(this_ptr_ptr);
26880         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
26881         FREE((void*)this_ptr);
26882         BroadcasterInterface_free(this_ptr_conv);
26883 }
26884
26885 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26886         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
26887         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
26888         return ret_conv;
26889 }
26890
26891 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
26892         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
26893         return ret_conv;
26894 }
26895
26896 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
26897         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
26898         return ret_conv;
26899 }
26900
26901 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
26902         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
26903         return ret_conv;
26904 }
26905
26906 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26907         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
26908         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
26909         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
26910         return ret_conv;
26911 }
26912
26913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26914         if ((this_ptr & 1) != 0) return;
26915         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26916         CHECK_ACCESS(this_ptr_ptr);
26917         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
26918         FREE((void*)this_ptr);
26919         FeeEstimator_free(this_ptr_conv);
26920 }
26921
26922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26923         LDKMonitorUpdateId this_obj_conv;
26924         this_obj_conv.inner = (void*)(this_obj & (~1));
26925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26927         MonitorUpdateId_free(this_obj_conv);
26928 }
26929
26930 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
26931         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
26932 int64_t ret_ref = 0;
26933 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26934 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26935 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26936 ret_ref = (uintptr_t)ret_var.inner;
26937 if (ret_var.is_owned) {
26938         ret_ref |= 1;
26939 }
26940         return ret_ref;
26941 }
26942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26943         LDKMonitorUpdateId arg_conv;
26944         arg_conv.inner = (void*)(arg & (~1));
26945         arg_conv.is_owned = false;
26946         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26947         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
26948         return ret_conv;
26949 }
26950
26951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26952         LDKMonitorUpdateId orig_conv;
26953         orig_conv.inner = (void*)(orig & (~1));
26954         orig_conv.is_owned = false;
26955         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26956         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
26957         int64_t ret_ref = 0;
26958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26961         ret_ref = (uintptr_t)ret_var.inner;
26962         if (ret_var.is_owned) {
26963                 ret_ref |= 1;
26964         }
26965         return ret_ref;
26966 }
26967
26968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
26969         LDKMonitorUpdateId o_conv;
26970         o_conv.inner = (void*)(o & (~1));
26971         o_conv.is_owned = false;
26972         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26973         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
26974         return ret_conv;
26975 }
26976
26977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26978         LDKMonitorUpdateId a_conv;
26979         a_conv.inner = (void*)(a & (~1));
26980         a_conv.is_owned = false;
26981         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26982         LDKMonitorUpdateId b_conv;
26983         b_conv.inner = (void*)(b & (~1));
26984         b_conv.is_owned = false;
26985         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26986         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
26987         return ret_conv;
26988 }
26989
26990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26991         if ((this_ptr & 1) != 0) return;
26992         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26993         CHECK_ACCESS(this_ptr_ptr);
26994         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
26995         FREE((void*)this_ptr);
26996         Persist_free(this_ptr_conv);
26997 }
26998
26999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27000         LDKLockedChannelMonitor this_obj_conv;
27001         this_obj_conv.inner = (void*)(this_obj & (~1));
27002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27004         LockedChannelMonitor_free(this_obj_conv);
27005 }
27006
27007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27008         LDKChainMonitor this_obj_conv;
27009         this_obj_conv.inner = (void*)(this_obj & (~1));
27010         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27012         ChainMonitor_free(this_obj_conv);
27013 }
27014
27015 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) {
27016         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
27017         CHECK_ACCESS(chain_source_ptr);
27018         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
27019         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
27020         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
27021                 // Manually implement clone for Java trait instances
27022                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
27023                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27024                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
27025                 }
27026         }
27027         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27028         CHECK_ACCESS(broadcaster_ptr);
27029         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27030         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27031                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27032                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27033         }
27034         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27035         CHECK_ACCESS(logger_ptr);
27036         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27037         if (logger_conv.free == LDKLogger_JCalls_free) {
27038                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27039                 LDKLogger_JCalls_cloned(&logger_conv);
27040         }
27041         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
27042         CHECK_ACCESS(feeest_ptr);
27043         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
27044         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
27045                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27046                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
27047         }
27048         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
27049         CHECK_ACCESS(persister_ptr);
27050         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
27051         if (persister_conv.free == LDKPersist_JCalls_free) {
27052                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27053                 LDKPersist_JCalls_cloned(&persister_conv);
27054         }
27055         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
27056         int64_t ret_ref = 0;
27057         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27058         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27060         ret_ref = (uintptr_t)ret_var.inner;
27061         if (ret_var.is_owned) {
27062                 ret_ref |= 1;
27063         }
27064         return ret_ref;
27065 }
27066
27067 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) {
27068         LDKChainMonitor this_arg_conv;
27069         this_arg_conv.inner = (void*)(this_arg & (~1));
27070         this_arg_conv.is_owned = false;
27071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27072         LDKCVec_ChannelDetailsZ ignored_channels_constr;
27073         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
27074         if (ignored_channels_constr.datalen > 0)
27075                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27076         else
27077                 ignored_channels_constr.data = NULL;
27078         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
27079         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
27080                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
27081                 LDKChannelDetails ignored_channels_conv_16_conv;
27082                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
27083                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
27084                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
27085                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
27086                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
27087         }
27088         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
27089         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
27090         int64_tArray ret_arr = NULL;
27091         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27092         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27093         for (size_t j = 0; j < ret_var.datalen; j++) {
27094                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27095                 *ret_conv_9_copy = ret_var.data[j];
27096                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
27097                 ret_arr_ptr[j] = ret_conv_9_ref;
27098         }
27099         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27100         FREE(ret_var.data);
27101         return ret_arr;
27102 }
27103
27104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
27105         LDKChainMonitor this_arg_conv;
27106         this_arg_conv.inner = (void*)(this_arg & (~1));
27107         this_arg_conv.is_owned = false;
27108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27109         LDKOutPoint funding_txo_conv;
27110         funding_txo_conv.inner = (void*)(funding_txo & (~1));
27111         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
27112         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27113         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27114         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
27115         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
27116         return (int64_t)ret_conv;
27117 }
27118
27119 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
27120         LDKChainMonitor this_arg_conv;
27121         this_arg_conv.inner = (void*)(this_arg & (~1));
27122         this_arg_conv.is_owned = false;
27123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27124         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
27125         int64_tArray ret_arr = NULL;
27126         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27127         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27128         for (size_t k = 0; k < ret_var.datalen; k++) {
27129                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
27130                 int64_t ret_conv_10_ref = 0;
27131                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27132                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27133                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
27134                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
27135                 if (ret_conv_10_var.is_owned) {
27136                         ret_conv_10_ref |= 1;
27137                 }
27138                 ret_arr_ptr[k] = ret_conv_10_ref;
27139         }
27140         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27141         FREE(ret_var.data);
27142         return ret_arr;
27143 }
27144
27145 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) {
27146         LDKChainMonitor this_arg_conv;
27147         this_arg_conv.inner = (void*)(this_arg & (~1));
27148         this_arg_conv.is_owned = false;
27149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27150         LDKOutPoint funding_txo_conv;
27151         funding_txo_conv.inner = (void*)(funding_txo & (~1));
27152         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
27153         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27154         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27155         LDKMonitorUpdateId completed_update_id_conv;
27156         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
27157         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
27158         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
27159         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
27160         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27161         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
27162         return (int64_t)ret_conv;
27163 }
27164
27165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
27166         LDKChainMonitor this_arg_conv;
27167         this_arg_conv.inner = (void*)(this_arg & (~1));
27168         this_arg_conv.is_owned = false;
27169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27170         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27171         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
27172         return (int64_t)ret_ret;
27173 }
27174
27175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
27176         LDKChainMonitor this_arg_conv;
27177         this_arg_conv.inner = (void*)(this_arg & (~1));
27178         this_arg_conv.is_owned = false;
27179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27180         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27181         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
27182         return (int64_t)ret_ret;
27183 }
27184
27185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
27186         LDKChainMonitor this_arg_conv;
27187         this_arg_conv.inner = (void*)(this_arg & (~1));
27188         this_arg_conv.is_owned = false;
27189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27190         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
27191         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
27192         return (int64_t)ret_ret;
27193 }
27194
27195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
27196         LDKChainMonitor this_arg_conv;
27197         this_arg_conv.inner = (void*)(this_arg & (~1));
27198         this_arg_conv.is_owned = false;
27199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27200         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27201         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
27202         return (int64_t)ret_ret;
27203 }
27204
27205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27206         LDKChannelMonitorUpdate 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         ChannelMonitorUpdate_free(this_obj_conv);
27211 }
27212
27213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27214         LDKChannelMonitorUpdate 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         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
27219         return ret_conv;
27220 }
27221
27222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27223         LDKChannelMonitorUpdate this_ptr_conv;
27224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27225         this_ptr_conv.is_owned = false;
27226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27227         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
27228 }
27229
27230 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
27231         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
27232 int64_t ret_ref = 0;
27233 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27234 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27235 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27236 ret_ref = (uintptr_t)ret_var.inner;
27237 if (ret_var.is_owned) {
27238         ret_ref |= 1;
27239 }
27240         return ret_ref;
27241 }
27242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27243         LDKChannelMonitorUpdate arg_conv;
27244         arg_conv.inner = (void*)(arg & (~1));
27245         arg_conv.is_owned = false;
27246         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27247         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
27248         return ret_conv;
27249 }
27250
27251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27252         LDKChannelMonitorUpdate orig_conv;
27253         orig_conv.inner = (void*)(orig & (~1));
27254         orig_conv.is_owned = false;
27255         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27256         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
27257         int64_t ret_ref = 0;
27258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27261         ret_ref = (uintptr_t)ret_var.inner;
27262         if (ret_var.is_owned) {
27263                 ret_ref |= 1;
27264         }
27265         return ret_ref;
27266 }
27267
27268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27269         LDKChannelMonitorUpdate obj_conv;
27270         obj_conv.inner = (void*)(obj & (~1));
27271         obj_conv.is_owned = false;
27272         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27273         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
27274         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27275         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27276         CVec_u8Z_free(ret_var);
27277         return ret_arr;
27278 }
27279
27280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27281         LDKu8slice ser_ref;
27282         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27283         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27284         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
27285         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
27286         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27287         return (int64_t)ret_conv;
27288 }
27289
27290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27291         if ((this_ptr & 1) != 0) return;
27292         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27293         CHECK_ACCESS(this_ptr_ptr);
27294         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
27295         FREE((void*)this_ptr);
27296         MonitorEvent_free(this_ptr_conv);
27297 }
27298
27299 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
27300         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27301         *ret_copy = MonitorEvent_clone(arg);
27302 int64_t ret_ref = (uintptr_t)ret_copy;
27303         return ret_ref;
27304 }
27305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27306         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
27307         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
27308         return ret_conv;
27309 }
27310
27311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27312         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
27313         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27314         *ret_copy = MonitorEvent_clone(orig_conv);
27315         int64_t ret_ref = (uintptr_t)ret_copy;
27316         return ret_ref;
27317 }
27318
27319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
27320         LDKHTLCUpdate a_conv;
27321         a_conv.inner = (void*)(a & (~1));
27322         a_conv.is_owned = (a & 1) || (a == 0);
27323         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27324         a_conv = HTLCUpdate_clone(&a_conv);
27325         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27326         *ret_copy = MonitorEvent_htlcevent(a_conv);
27327         int64_t ret_ref = (uintptr_t)ret_copy;
27328         return ret_ref;
27329 }
27330
27331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
27332         LDKOutPoint a_conv;
27333         a_conv.inner = (void*)(a & (~1));
27334         a_conv.is_owned = (a & 1) || (a == 0);
27335         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27336         a_conv = OutPoint_clone(&a_conv);
27337         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27338         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
27339         int64_t ret_ref = (uintptr_t)ret_copy;
27340         return ret_ref;
27341 }
27342
27343 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) {
27344         LDKOutPoint funding_txo_conv;
27345         funding_txo_conv.inner = (void*)(funding_txo & (~1));
27346         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
27347         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27348         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27349         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27350         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
27351         int64_t ret_ref = (uintptr_t)ret_copy;
27352         return ret_ref;
27353 }
27354
27355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
27356         LDKOutPoint a_conv;
27357         a_conv.inner = (void*)(a & (~1));
27358         a_conv.is_owned = (a & 1) || (a == 0);
27359         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27360         a_conv = OutPoint_clone(&a_conv);
27361         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27362         *ret_copy = MonitorEvent_update_failed(a_conv);
27363         int64_t ret_ref = (uintptr_t)ret_copy;
27364         return ret_ref;
27365 }
27366
27367 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
27368         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
27369         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
27370         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27371         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27372         CVec_u8Z_free(ret_var);
27373         return ret_arr;
27374 }
27375
27376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27377         LDKu8slice ser_ref;
27378         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27379         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27380         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
27381         *ret_conv = MonitorEvent_read(ser_ref);
27382         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27383         return (int64_t)ret_conv;
27384 }
27385
27386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27387         LDKHTLCUpdate this_obj_conv;
27388         this_obj_conv.inner = (void*)(this_obj & (~1));
27389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27391         HTLCUpdate_free(this_obj_conv);
27392 }
27393
27394 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
27395         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
27396 int64_t ret_ref = 0;
27397 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27398 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27399 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27400 ret_ref = (uintptr_t)ret_var.inner;
27401 if (ret_var.is_owned) {
27402         ret_ref |= 1;
27403 }
27404         return ret_ref;
27405 }
27406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27407         LDKHTLCUpdate arg_conv;
27408         arg_conv.inner = (void*)(arg & (~1));
27409         arg_conv.is_owned = false;
27410         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27411         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
27412         return ret_conv;
27413 }
27414
27415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27416         LDKHTLCUpdate orig_conv;
27417         orig_conv.inner = (void*)(orig & (~1));
27418         orig_conv.is_owned = false;
27419         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27420         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
27421         int64_t ret_ref = 0;
27422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27425         ret_ref = (uintptr_t)ret_var.inner;
27426         if (ret_var.is_owned) {
27427                 ret_ref |= 1;
27428         }
27429         return ret_ref;
27430 }
27431
27432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27433         LDKHTLCUpdate obj_conv;
27434         obj_conv.inner = (void*)(obj & (~1));
27435         obj_conv.is_owned = false;
27436         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27437         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
27438         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27439         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27440         CVec_u8Z_free(ret_var);
27441         return ret_arr;
27442 }
27443
27444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27445         LDKu8slice ser_ref;
27446         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27447         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27448         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
27449         *ret_conv = HTLCUpdate_read(ser_ref);
27450         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27451         return (int64_t)ret_conv;
27452 }
27453
27454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27455         if ((this_ptr & 1) != 0) return;
27456         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27457         CHECK_ACCESS(this_ptr_ptr);
27458         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
27459         FREE((void*)this_ptr);
27460         Balance_free(this_ptr_conv);
27461 }
27462
27463 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
27464         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27465         *ret_copy = Balance_clone(arg);
27466 int64_t ret_ref = (uintptr_t)ret_copy;
27467         return ret_ref;
27468 }
27469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27470         LDKBalance* arg_conv = (LDKBalance*)arg;
27471         int64_t ret_conv = Balance_clone_ptr(arg_conv);
27472         return ret_conv;
27473 }
27474
27475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27476         LDKBalance* orig_conv = (LDKBalance*)orig;
27477         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27478         *ret_copy = Balance_clone(orig_conv);
27479         int64_t ret_ref = (uintptr_t)ret_copy;
27480         return ret_ref;
27481 }
27482
27483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
27484         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27485         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
27486         int64_t ret_ref = (uintptr_t)ret_copy;
27487         return ret_ref;
27488 }
27489
27490 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) {
27491         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27492         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
27493         int64_t ret_ref = (uintptr_t)ret_copy;
27494         return ret_ref;
27495 }
27496
27497 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) {
27498         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27499         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
27500         int64_t ret_ref = (uintptr_t)ret_copy;
27501         return ret_ref;
27502 }
27503
27504 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) {
27505         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27506         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
27507         int64_t ret_ref = (uintptr_t)ret_copy;
27508         return ret_ref;
27509 }
27510
27511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27512         LDKBalance* a_conv = (LDKBalance*)a;
27513         LDKBalance* b_conv = (LDKBalance*)b;
27514         jboolean ret_conv = Balance_eq(a_conv, b_conv);
27515         return ret_conv;
27516 }
27517
27518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27519         LDKChannelMonitor this_obj_conv;
27520         this_obj_conv.inner = (void*)(this_obj & (~1));
27521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27523         ChannelMonitor_free(this_obj_conv);
27524 }
27525
27526 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
27527         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
27528 int64_t ret_ref = 0;
27529 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27530 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27531 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27532 ret_ref = (uintptr_t)ret_var.inner;
27533 if (ret_var.is_owned) {
27534         ret_ref |= 1;
27535 }
27536         return ret_ref;
27537 }
27538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27539         LDKChannelMonitor arg_conv;
27540         arg_conv.inner = (void*)(arg & (~1));
27541         arg_conv.is_owned = false;
27542         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27543         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
27544         return ret_conv;
27545 }
27546
27547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27548         LDKChannelMonitor orig_conv;
27549         orig_conv.inner = (void*)(orig & (~1));
27550         orig_conv.is_owned = false;
27551         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27552         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
27553         int64_t ret_ref = 0;
27554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27557         ret_ref = (uintptr_t)ret_var.inner;
27558         if (ret_var.is_owned) {
27559                 ret_ref |= 1;
27560         }
27561         return ret_ref;
27562 }
27563
27564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27565         LDKChannelMonitor obj_conv;
27566         obj_conv.inner = (void*)(obj & (~1));
27567         obj_conv.is_owned = false;
27568         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27569         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
27570         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27571         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27572         CVec_u8Z_free(ret_var);
27573         return ret_arr;
27574 }
27575
27576 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) {
27577         LDKChannelMonitor this_arg_conv;
27578         this_arg_conv.inner = (void*)(this_arg & (~1));
27579         this_arg_conv.is_owned = false;
27580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27581         LDKChannelMonitorUpdate updates_conv;
27582         updates_conv.inner = (void*)(updates & (~1));
27583         updates_conv.is_owned = false;
27584         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
27585         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27586         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
27587         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
27588         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27589         CHECK_ACCESS(fee_estimator_ptr);
27590         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27591         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27592                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27593                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27594         }
27595         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27596         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
27597         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
27598         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
27599         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
27600         return (int64_t)ret_conv;
27601 }
27602
27603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27604         LDKChannelMonitor this_arg_conv;
27605         this_arg_conv.inner = (void*)(this_arg & (~1));
27606         this_arg_conv.is_owned = false;
27607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27608         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
27609         return ret_conv;
27610 }
27611
27612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
27613         LDKChannelMonitor this_arg_conv;
27614         this_arg_conv.inner = (void*)(this_arg & (~1));
27615         this_arg_conv.is_owned = false;
27616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27617         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
27618         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
27619         return ((int64_t)ret_conv);
27620 }
27621
27622 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
27623         LDKChannelMonitor this_arg_conv;
27624         this_arg_conv.inner = (void*)(this_arg & (~1));
27625         this_arg_conv.is_owned = false;
27626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27627         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
27628         int64_tArray ret_arr = NULL;
27629         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27630         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27631         for (size_t o = 0; o < ret_var.datalen; o++) {
27632                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
27633                 *ret_conv_40_conv = ret_var.data[o];
27634                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
27635         }
27636         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27637         FREE(ret_var.data);
27638         return ret_arr;
27639 }
27640
27641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
27642         LDKChannelMonitor this_arg_conv;
27643         this_arg_conv.inner = (void*)(this_arg & (~1));
27644         this_arg_conv.is_owned = false;
27645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27646         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
27647         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
27648         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
27649         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
27650 }
27651
27652 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27653         LDKChannelMonitor this_arg_conv;
27654         this_arg_conv.inner = (void*)(this_arg & (~1));
27655         this_arg_conv.is_owned = false;
27656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27657         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
27658         int64_tArray ret_arr = NULL;
27659         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27660         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27661         for (size_t o = 0; o < ret_var.datalen; o++) {
27662                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27663                 *ret_conv_14_copy = ret_var.data[o];
27664                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
27665                 ret_arr_ptr[o] = ret_conv_14_ref;
27666         }
27667         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27668         FREE(ret_var.data);
27669         return ret_arr;
27670 }
27671
27672 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27673         LDKChannelMonitor this_arg_conv;
27674         this_arg_conv.inner = (void*)(this_arg & (~1));
27675         this_arg_conv.is_owned = false;
27676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27677         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
27678         int64_tArray ret_arr = NULL;
27679         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27680         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27681         for (size_t h = 0; h < ret_var.datalen; h++) {
27682                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
27683                 *ret_conv_7_copy = ret_var.data[h];
27684                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
27685                 ret_arr_ptr[h] = ret_conv_7_ref;
27686         }
27687         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27688         FREE(ret_var.data);
27689         return ret_arr;
27690 }
27691
27692 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27693         LDKChannelMonitor this_arg_conv;
27694         this_arg_conv.inner = (void*)(this_arg & (~1));
27695         this_arg_conv.is_owned = false;
27696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27697         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27698         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
27699         return ret_arr;
27700 }
27701
27702 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) {
27703         LDKChannelMonitor this_arg_conv;
27704         this_arg_conv.inner = (void*)(this_arg & (~1));
27705         this_arg_conv.is_owned = false;
27706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27707         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27708         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
27709         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
27710         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
27711         jobjectArray ret_arr = NULL;
27712         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27713         ;
27714         for (size_t i = 0; i < ret_var.datalen; i++) {
27715                 LDKTransaction ret_conv_8_var = ret_var.data[i];
27716                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
27717                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
27718                 Transaction_free(ret_conv_8_var);
27719                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27720         }
27721         
27722         FREE(ret_var.data);
27723         return ret_arr;
27724 }
27725
27726 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) {
27727         LDKChannelMonitor this_arg_conv;
27728         this_arg_conv.inner = (void*)(this_arg & (~1));
27729         this_arg_conv.is_owned = false;
27730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27731         unsigned char header_arr[80];
27732         CHECK((*env)->GetArrayLength(env, header) == 80);
27733         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27734         unsigned char (*header_ref)[80] = &header_arr;
27735         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27736         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27737         if (txdata_constr.datalen > 0)
27738                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27739         else
27740                 txdata_constr.data = NULL;
27741         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27742         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27743                 int64_t txdata_conv_28 = txdata_vals[c];
27744                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27745                 CHECK_ACCESS(txdata_conv_28_ptr);
27746                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27747                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27748                 txdata_constr.data[c] = txdata_conv_28_conv;
27749         }
27750         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27751         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27752         CHECK_ACCESS(broadcaster_ptr);
27753         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27754         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27755                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27756                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27757         }
27758         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27759         CHECK_ACCESS(fee_estimator_ptr);
27760         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27761         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27762                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27763                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27764         }
27765         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27766         CHECK_ACCESS(logger_ptr);
27767         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27768         if (logger_conv.free == LDKLogger_JCalls_free) {
27769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27770                 LDKLogger_JCalls_cloned(&logger_conv);
27771         }
27772         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);
27773         int64_tArray ret_arr = NULL;
27774         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27775         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27776         for (size_t n = 0; n < ret_var.datalen; n++) {
27777                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27778                 *ret_conv_39_conv = ret_var.data[n];
27779                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27780         }
27781         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27782         FREE(ret_var.data);
27783         return ret_arr;
27784 }
27785
27786 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) {
27787         LDKChannelMonitor this_arg_conv;
27788         this_arg_conv.inner = (void*)(this_arg & (~1));
27789         this_arg_conv.is_owned = false;
27790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27791         unsigned char header_arr[80];
27792         CHECK((*env)->GetArrayLength(env, header) == 80);
27793         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27794         unsigned char (*header_ref)[80] = &header_arr;
27795         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27796         CHECK_ACCESS(broadcaster_ptr);
27797         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27798         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27799                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27800                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27801         }
27802         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27803         CHECK_ACCESS(fee_estimator_ptr);
27804         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27805         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27806                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27807                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27808         }
27809         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27810         CHECK_ACCESS(logger_ptr);
27811         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27812         if (logger_conv.free == LDKLogger_JCalls_free) {
27813                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27814                 LDKLogger_JCalls_cloned(&logger_conv);
27815         }
27816         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27817 }
27818
27819 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) {
27820         LDKChannelMonitor this_arg_conv;
27821         this_arg_conv.inner = (void*)(this_arg & (~1));
27822         this_arg_conv.is_owned = false;
27823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27824         unsigned char header_arr[80];
27825         CHECK((*env)->GetArrayLength(env, header) == 80);
27826         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27827         unsigned char (*header_ref)[80] = &header_arr;
27828         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27829         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27830         if (txdata_constr.datalen > 0)
27831                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27832         else
27833                 txdata_constr.data = NULL;
27834         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27835         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27836                 int64_t txdata_conv_28 = txdata_vals[c];
27837                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27838                 CHECK_ACCESS(txdata_conv_28_ptr);
27839                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27840                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27841                 txdata_constr.data[c] = txdata_conv_28_conv;
27842         }
27843         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27844         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27845         CHECK_ACCESS(broadcaster_ptr);
27846         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27847         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27848                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27849                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27850         }
27851         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27852         CHECK_ACCESS(fee_estimator_ptr);
27853         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27854         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27855                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27856                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27857         }
27858         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27859         CHECK_ACCESS(logger_ptr);
27860         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27861         if (logger_conv.free == LDKLogger_JCalls_free) {
27862                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27863                 LDKLogger_JCalls_cloned(&logger_conv);
27864         }
27865         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);
27866         int64_tArray ret_arr = NULL;
27867         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27868         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27869         for (size_t n = 0; n < ret_var.datalen; n++) {
27870                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27871                 *ret_conv_39_conv = ret_var.data[n];
27872                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27873         }
27874         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27875         FREE(ret_var.data);
27876         return ret_arr;
27877 }
27878
27879 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) {
27880         LDKChannelMonitor this_arg_conv;
27881         this_arg_conv.inner = (void*)(this_arg & (~1));
27882         this_arg_conv.is_owned = false;
27883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27884         unsigned char txid_arr[32];
27885         CHECK((*env)->GetArrayLength(env, txid) == 32);
27886         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
27887         unsigned char (*txid_ref)[32] = &txid_arr;
27888         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27889         CHECK_ACCESS(broadcaster_ptr);
27890         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27891         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27892                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27893                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27894         }
27895         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27896         CHECK_ACCESS(fee_estimator_ptr);
27897         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27898         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27899                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27900                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27901         }
27902         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27903         CHECK_ACCESS(logger_ptr);
27904         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27905         if (logger_conv.free == LDKLogger_JCalls_free) {
27906                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27907                 LDKLogger_JCalls_cloned(&logger_conv);
27908         }
27909         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
27910 }
27911
27912 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) {
27913         LDKChannelMonitor this_arg_conv;
27914         this_arg_conv.inner = (void*)(this_arg & (~1));
27915         this_arg_conv.is_owned = false;
27916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27917         unsigned char header_arr[80];
27918         CHECK((*env)->GetArrayLength(env, header) == 80);
27919         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27920         unsigned char (*header_ref)[80] = &header_arr;
27921         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27922         CHECK_ACCESS(broadcaster_ptr);
27923         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27924         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27925                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27926                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27927         }
27928         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27929         CHECK_ACCESS(fee_estimator_ptr);
27930         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27931         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27932                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27933                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27934         }
27935         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27936         CHECK_ACCESS(logger_ptr);
27937         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27938         if (logger_conv.free == LDKLogger_JCalls_free) {
27939                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27940                 LDKLogger_JCalls_cloned(&logger_conv);
27941         }
27942         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27943         int64_tArray ret_arr = NULL;
27944         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27945         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27946         for (size_t n = 0; n < ret_var.datalen; n++) {
27947                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27948                 *ret_conv_39_conv = ret_var.data[n];
27949                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27950         }
27951         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27952         FREE(ret_var.data);
27953         return ret_arr;
27954 }
27955
27956 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
27957         LDKChannelMonitor this_arg_conv;
27958         this_arg_conv.inner = (void*)(this_arg & (~1));
27959         this_arg_conv.is_owned = false;
27960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27961         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
27962         jobjectArray ret_arr = NULL;
27963         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27964         ;
27965         for (size_t i = 0; i < ret_var.datalen; i++) {
27966                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
27967                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
27968                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27969         }
27970         
27971         FREE(ret_var.data);
27972         return ret_arr;
27973 }
27974
27975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
27976         LDKChannelMonitor this_arg_conv;
27977         this_arg_conv.inner = (void*)(this_arg & (~1));
27978         this_arg_conv.is_owned = false;
27979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27980         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
27981         int64_t ret_ref = 0;
27982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27985         ret_ref = (uintptr_t)ret_var.inner;
27986         if (ret_var.is_owned) {
27987                 ret_ref |= 1;
27988         }
27989         return ret_ref;
27990 }
27991
27992 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
27993         LDKChannelMonitor this_arg_conv;
27994         this_arg_conv.inner = (void*)(this_arg & (~1));
27995         this_arg_conv.is_owned = false;
27996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27997         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
27998         int64_tArray ret_arr = NULL;
27999         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28000         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28001         for (size_t j = 0; j < ret_var.datalen; j++) {
28002                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28003                 *ret_conv_9_copy = ret_var.data[j];
28004                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
28005                 ret_arr_ptr[j] = ret_conv_9_ref;
28006         }
28007         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28008         FREE(ret_var.data);
28009         return ret_arr;
28010 }
28011
28012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
28013         LDKu8slice ser_ref;
28014         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28015         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28016         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28017         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28018         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
28019         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
28020         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
28021         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28022         return (int64_t)ret_conv;
28023 }
28024
28025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28026         LDKOutPoint this_obj_conv;
28027         this_obj_conv.inner = (void*)(this_obj & (~1));
28028         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28030         OutPoint_free(this_obj_conv);
28031 }
28032
28033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28034         LDKOutPoint this_ptr_conv;
28035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28036         this_ptr_conv.is_owned = false;
28037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28038         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28039         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
28040         return ret_arr;
28041 }
28042
28043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28044         LDKOutPoint this_ptr_conv;
28045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28046         this_ptr_conv.is_owned = false;
28047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28048         LDKThirtyTwoBytes val_ref;
28049         CHECK((*env)->GetArrayLength(env, val) == 32);
28050         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28051         OutPoint_set_txid(&this_ptr_conv, val_ref);
28052 }
28053
28054 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
28055         LDKOutPoint this_ptr_conv;
28056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28057         this_ptr_conv.is_owned = false;
28058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28059         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
28060         return ret_conv;
28061 }
28062
28063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28064         LDKOutPoint this_ptr_conv;
28065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28066         this_ptr_conv.is_owned = false;
28067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28068         OutPoint_set_index(&this_ptr_conv, val);
28069 }
28070
28071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
28072         LDKThirtyTwoBytes txid_arg_ref;
28073         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
28074         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
28075         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
28076         int64_t ret_ref = 0;
28077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28080         ret_ref = (uintptr_t)ret_var.inner;
28081         if (ret_var.is_owned) {
28082                 ret_ref |= 1;
28083         }
28084         return ret_ref;
28085 }
28086
28087 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
28088         LDKOutPoint ret_var = OutPoint_clone(arg);
28089 int64_t ret_ref = 0;
28090 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28091 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28092 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28093 ret_ref = (uintptr_t)ret_var.inner;
28094 if (ret_var.is_owned) {
28095         ret_ref |= 1;
28096 }
28097         return ret_ref;
28098 }
28099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28100         LDKOutPoint arg_conv;
28101         arg_conv.inner = (void*)(arg & (~1));
28102         arg_conv.is_owned = false;
28103         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28104         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
28105         return ret_conv;
28106 }
28107
28108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28109         LDKOutPoint orig_conv;
28110         orig_conv.inner = (void*)(orig & (~1));
28111         orig_conv.is_owned = false;
28112         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28113         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
28114         int64_t ret_ref = 0;
28115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28118         ret_ref = (uintptr_t)ret_var.inner;
28119         if (ret_var.is_owned) {
28120                 ret_ref |= 1;
28121         }
28122         return ret_ref;
28123 }
28124
28125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28126         LDKOutPoint a_conv;
28127         a_conv.inner = (void*)(a & (~1));
28128         a_conv.is_owned = false;
28129         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28130         LDKOutPoint b_conv;
28131         b_conv.inner = (void*)(b & (~1));
28132         b_conv.is_owned = false;
28133         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28134         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
28135         return ret_conv;
28136 }
28137
28138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
28139         LDKOutPoint o_conv;
28140         o_conv.inner = (void*)(o & (~1));
28141         o_conv.is_owned = false;
28142         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28143         int64_t ret_conv = OutPoint_hash(&o_conv);
28144         return ret_conv;
28145 }
28146
28147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28148         LDKOutPoint this_arg_conv;
28149         this_arg_conv.inner = (void*)(this_arg & (~1));
28150         this_arg_conv.is_owned = false;
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28152         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28153         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
28154         return ret_arr;
28155 }
28156
28157 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
28158         LDKOutPoint obj_conv;
28159         obj_conv.inner = (void*)(obj & (~1));
28160         obj_conv.is_owned = false;
28161         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28162         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
28163         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28164         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28165         CVec_u8Z_free(ret_var);
28166         return ret_arr;
28167 }
28168
28169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28170         LDKu8slice ser_ref;
28171         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28172         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28173         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28174         *ret_conv = OutPoint_read(ser_ref);
28175         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28176         return (int64_t)ret_conv;
28177 }
28178
28179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28180         LDKDelayedPaymentOutputDescriptor this_obj_conv;
28181         this_obj_conv.inner = (void*)(this_obj & (~1));
28182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28184         DelayedPaymentOutputDescriptor_free(this_obj_conv);
28185 }
28186
28187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28188         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28190         this_ptr_conv.is_owned = false;
28191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28192         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
28193         int64_t ret_ref = 0;
28194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28197         ret_ref = (uintptr_t)ret_var.inner;
28198         if (ret_var.is_owned) {
28199                 ret_ref |= 1;
28200         }
28201         return ret_ref;
28202 }
28203
28204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28205         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28207         this_ptr_conv.is_owned = false;
28208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28209         LDKOutPoint val_conv;
28210         val_conv.inner = (void*)(val & (~1));
28211         val_conv.is_owned = (val & 1) || (val == 0);
28212         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28213         val_conv = OutPoint_clone(&val_conv);
28214         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
28215 }
28216
28217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28218         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28220         this_ptr_conv.is_owned = false;
28221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28222         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28223         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
28224         return ret_arr;
28225 }
28226
28227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28228         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28230         this_ptr_conv.is_owned = false;
28231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28232         LDKPublicKey val_ref;
28233         CHECK((*env)->GetArrayLength(env, val) == 33);
28234         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28235         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
28236 }
28237
28238 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28239         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28241         this_ptr_conv.is_owned = false;
28242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28243         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
28244         return ret_conv;
28245 }
28246
28247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28248         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28250         this_ptr_conv.is_owned = false;
28251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28252         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
28253 }
28254
28255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
28256         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28258         this_ptr_conv.is_owned = false;
28259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28260         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
28261         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
28262         return (int64_t)ret_ref;
28263 }
28264
28265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28266         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28268         this_ptr_conv.is_owned = false;
28269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28270         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28271         CHECK_ACCESS(val_ptr);
28272         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
28273         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
28274         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
28275 }
28276
28277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28278         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28280         this_ptr_conv.is_owned = false;
28281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28282         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28283         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
28284         return ret_arr;
28285 }
28286
28287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28288         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28290         this_ptr_conv.is_owned = false;
28291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28292         LDKPublicKey val_ref;
28293         CHECK((*env)->GetArrayLength(env, val) == 33);
28294         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28295         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
28296 }
28297
28298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28299         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28301         this_ptr_conv.is_owned = false;
28302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28303         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28304         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
28305         return ret_arr;
28306 }
28307
28308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28309         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28311         this_ptr_conv.is_owned = false;
28312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28313         LDKThirtyTwoBytes val_ref;
28314         CHECK((*env)->GetArrayLength(env, val) == 32);
28315         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28316         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
28317 }
28318
28319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28320         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28322         this_ptr_conv.is_owned = false;
28323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28324         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
28325         return ret_conv;
28326 }
28327
28328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28329         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28331         this_ptr_conv.is_owned = false;
28332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28333         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
28334 }
28335
28336 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) {
28337         LDKOutPoint outpoint_arg_conv;
28338         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
28339         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
28340         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28341         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28342         LDKPublicKey per_commitment_point_arg_ref;
28343         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
28344         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
28345         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
28346         CHECK_ACCESS(output_arg_ptr);
28347         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
28348         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
28349         LDKPublicKey revocation_pubkey_arg_ref;
28350         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
28351         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
28352         LDKThirtyTwoBytes channel_keys_id_arg_ref;
28353         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
28354         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
28355         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);
28356         int64_t ret_ref = 0;
28357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28360         ret_ref = (uintptr_t)ret_var.inner;
28361         if (ret_var.is_owned) {
28362                 ret_ref |= 1;
28363         }
28364         return ret_ref;
28365 }
28366
28367 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
28368         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
28369 int64_t ret_ref = 0;
28370 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28371 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28372 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28373 ret_ref = (uintptr_t)ret_var.inner;
28374 if (ret_var.is_owned) {
28375         ret_ref |= 1;
28376 }
28377         return ret_ref;
28378 }
28379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28380         LDKDelayedPaymentOutputDescriptor arg_conv;
28381         arg_conv.inner = (void*)(arg & (~1));
28382         arg_conv.is_owned = false;
28383         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28384         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
28385         return ret_conv;
28386 }
28387
28388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28389         LDKDelayedPaymentOutputDescriptor orig_conv;
28390         orig_conv.inner = (void*)(orig & (~1));
28391         orig_conv.is_owned = false;
28392         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28393         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
28394         int64_t ret_ref = 0;
28395         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28396         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28398         ret_ref = (uintptr_t)ret_var.inner;
28399         if (ret_var.is_owned) {
28400                 ret_ref |= 1;
28401         }
28402         return ret_ref;
28403 }
28404
28405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28406         LDKDelayedPaymentOutputDescriptor obj_conv;
28407         obj_conv.inner = (void*)(obj & (~1));
28408         obj_conv.is_owned = false;
28409         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28410         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
28411         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28412         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28413         CVec_u8Z_free(ret_var);
28414         return ret_arr;
28415 }
28416
28417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28418         LDKu8slice ser_ref;
28419         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28420         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28421         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
28422         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
28423         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28424         return (int64_t)ret_conv;
28425 }
28426
28427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28428         LDKStaticPaymentOutputDescriptor this_obj_conv;
28429         this_obj_conv.inner = (void*)(this_obj & (~1));
28430         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28432         StaticPaymentOutputDescriptor_free(this_obj_conv);
28433 }
28434
28435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28436         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28438         this_ptr_conv.is_owned = false;
28439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28440         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
28441         int64_t ret_ref = 0;
28442         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28443         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28445         ret_ref = (uintptr_t)ret_var.inner;
28446         if (ret_var.is_owned) {
28447                 ret_ref |= 1;
28448         }
28449         return ret_ref;
28450 }
28451
28452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28453         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28455         this_ptr_conv.is_owned = false;
28456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28457         LDKOutPoint val_conv;
28458         val_conv.inner = (void*)(val & (~1));
28459         val_conv.is_owned = (val & 1) || (val == 0);
28460         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28461         val_conv = OutPoint_clone(&val_conv);
28462         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
28463 }
28464
28465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
28466         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28468         this_ptr_conv.is_owned = false;
28469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28470         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
28471         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
28472         return (int64_t)ret_ref;
28473 }
28474
28475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28476         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28478         this_ptr_conv.is_owned = false;
28479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28480         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28481         CHECK_ACCESS(val_ptr);
28482         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
28483         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
28484         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
28485 }
28486
28487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28488         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28490         this_ptr_conv.is_owned = false;
28491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28492         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28493         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
28494         return ret_arr;
28495 }
28496
28497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28498         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28500         this_ptr_conv.is_owned = false;
28501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28502         LDKThirtyTwoBytes val_ref;
28503         CHECK((*env)->GetArrayLength(env, val) == 32);
28504         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28505         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
28506 }
28507
28508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28509         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28511         this_ptr_conv.is_owned = false;
28512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28513         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
28514         return ret_conv;
28515 }
28516
28517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28518         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28520         this_ptr_conv.is_owned = false;
28521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28522         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
28523 }
28524
28525 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) {
28526         LDKOutPoint outpoint_arg_conv;
28527         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
28528         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
28529         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28530         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28531         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
28532         CHECK_ACCESS(output_arg_ptr);
28533         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
28534         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
28535         LDKThirtyTwoBytes channel_keys_id_arg_ref;
28536         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
28537         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
28538         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
28539         int64_t ret_ref = 0;
28540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28543         ret_ref = (uintptr_t)ret_var.inner;
28544         if (ret_var.is_owned) {
28545                 ret_ref |= 1;
28546         }
28547         return ret_ref;
28548 }
28549
28550 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
28551         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
28552 int64_t ret_ref = 0;
28553 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28554 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28555 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28556 ret_ref = (uintptr_t)ret_var.inner;
28557 if (ret_var.is_owned) {
28558         ret_ref |= 1;
28559 }
28560         return ret_ref;
28561 }
28562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28563         LDKStaticPaymentOutputDescriptor arg_conv;
28564         arg_conv.inner = (void*)(arg & (~1));
28565         arg_conv.is_owned = false;
28566         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28567         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
28568         return ret_conv;
28569 }
28570
28571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28572         LDKStaticPaymentOutputDescriptor orig_conv;
28573         orig_conv.inner = (void*)(orig & (~1));
28574         orig_conv.is_owned = false;
28575         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28576         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
28577         int64_t ret_ref = 0;
28578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28581         ret_ref = (uintptr_t)ret_var.inner;
28582         if (ret_var.is_owned) {
28583                 ret_ref |= 1;
28584         }
28585         return ret_ref;
28586 }
28587
28588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28589         LDKStaticPaymentOutputDescriptor obj_conv;
28590         obj_conv.inner = (void*)(obj & (~1));
28591         obj_conv.is_owned = false;
28592         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28593         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
28594         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28595         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28596         CVec_u8Z_free(ret_var);
28597         return ret_arr;
28598 }
28599
28600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28601         LDKu8slice ser_ref;
28602         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28603         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28604         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
28605         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
28606         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28607         return (int64_t)ret_conv;
28608 }
28609
28610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28611         if ((this_ptr & 1) != 0) return;
28612         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28613         CHECK_ACCESS(this_ptr_ptr);
28614         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
28615         FREE((void*)this_ptr);
28616         SpendableOutputDescriptor_free(this_ptr_conv);
28617 }
28618
28619 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
28620         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28621         *ret_copy = SpendableOutputDescriptor_clone(arg);
28622 int64_t ret_ref = (uintptr_t)ret_copy;
28623         return ret_ref;
28624 }
28625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28626         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
28627         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
28628         return ret_conv;
28629 }
28630
28631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28632         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
28633         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28634         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
28635         int64_t ret_ref = (uintptr_t)ret_copy;
28636         return ret_ref;
28637 }
28638
28639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
28640         LDKOutPoint outpoint_conv;
28641         outpoint_conv.inner = (void*)(outpoint & (~1));
28642         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
28643         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
28644         outpoint_conv = OutPoint_clone(&outpoint_conv);
28645         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
28646         CHECK_ACCESS(output_ptr);
28647         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
28648         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
28649         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28650         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
28651         int64_t ret_ref = (uintptr_t)ret_copy;
28652         return ret_ref;
28653 }
28654
28655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
28656         LDKDelayedPaymentOutputDescriptor a_conv;
28657         a_conv.inner = (void*)(a & (~1));
28658         a_conv.is_owned = (a & 1) || (a == 0);
28659         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28660         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
28661         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28662         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
28663         int64_t ret_ref = (uintptr_t)ret_copy;
28664         return ret_ref;
28665 }
28666
28667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
28668         LDKStaticPaymentOutputDescriptor a_conv;
28669         a_conv.inner = (void*)(a & (~1));
28670         a_conv.is_owned = (a & 1) || (a == 0);
28671         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28672         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
28673         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28674         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
28675         int64_t ret_ref = (uintptr_t)ret_copy;
28676         return ret_ref;
28677 }
28678
28679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28680         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
28681         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
28682         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28683         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28684         CVec_u8Z_free(ret_var);
28685         return ret_arr;
28686 }
28687
28688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28689         LDKu8slice ser_ref;
28690         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28691         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28692         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
28693         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
28694         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28695         return (int64_t)ret_conv;
28696 }
28697
28698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28699         if ((this_ptr & 1) != 0) return;
28700         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28701         CHECK_ACCESS(this_ptr_ptr);
28702         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
28703         FREE((void*)this_ptr);
28704         BaseSign_free(this_ptr_conv);
28705 }
28706
28707 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
28708         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28709         *ret_ret = Sign_clone(arg);
28710         return (int64_t)ret_ret;
28711 }
28712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28713         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28714         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28715         LDKSign* arg_conv = (LDKSign*)arg_ptr;
28716         int64_t ret_conv = Sign_clone_ptr(arg_conv);
28717         return ret_conv;
28718 }
28719
28720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28721         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
28722         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28723         LDKSign* orig_conv = (LDKSign*)orig_ptr;
28724         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28725         *ret_ret = Sign_clone(orig_conv);
28726         return (int64_t)ret_ret;
28727 }
28728
28729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28730         if ((this_ptr & 1) != 0) return;
28731         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28732         CHECK_ACCESS(this_ptr_ptr);
28733         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
28734         FREE((void*)this_ptr);
28735         Sign_free(this_ptr_conv);
28736 }
28737
28738 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28739         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
28740         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
28741         return ret_conv;
28742 }
28743
28744 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
28745         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
28746         return ret_conv;
28747 }
28748
28749 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
28750         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
28751         return ret_conv;
28752 }
28753
28754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28755         if ((this_ptr & 1) != 0) return;
28756         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28757         CHECK_ACCESS(this_ptr_ptr);
28758         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
28759         FREE((void*)this_ptr);
28760         KeysInterface_free(this_ptr_conv);
28761 }
28762
28763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28764         LDKInMemorySigner this_obj_conv;
28765         this_obj_conv.inner = (void*)(this_obj & (~1));
28766         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28768         InMemorySigner_free(this_obj_conv);
28769 }
28770
28771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28772         LDKInMemorySigner this_ptr_conv;
28773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28774         this_ptr_conv.is_owned = false;
28775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28776         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
28778         return ret_arr;
28779 }
28780
28781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28782         LDKInMemorySigner this_ptr_conv;
28783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28784         this_ptr_conv.is_owned = false;
28785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28786         LDKSecretKey val_ref;
28787         CHECK((*env)->GetArrayLength(env, val) == 32);
28788         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28789         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
28790 }
28791
28792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28793         LDKInMemorySigner this_ptr_conv;
28794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28795         this_ptr_conv.is_owned = false;
28796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28797         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28798         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
28799         return ret_arr;
28800 }
28801
28802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28803         LDKInMemorySigner this_ptr_conv;
28804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28805         this_ptr_conv.is_owned = false;
28806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28807         LDKSecretKey val_ref;
28808         CHECK((*env)->GetArrayLength(env, val) == 32);
28809         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28810         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
28811 }
28812
28813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28814         LDKInMemorySigner this_ptr_conv;
28815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28816         this_ptr_conv.is_owned = false;
28817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28818         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
28820         return ret_arr;
28821 }
28822
28823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28824         LDKInMemorySigner this_ptr_conv;
28825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28826         this_ptr_conv.is_owned = false;
28827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28828         LDKSecretKey val_ref;
28829         CHECK((*env)->GetArrayLength(env, val) == 32);
28830         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28831         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
28832 }
28833
28834 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28835         LDKInMemorySigner this_ptr_conv;
28836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28837         this_ptr_conv.is_owned = false;
28838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28839         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
28841         return ret_arr;
28842 }
28843
28844 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) {
28845         LDKInMemorySigner this_ptr_conv;
28846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28847         this_ptr_conv.is_owned = false;
28848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28849         LDKSecretKey val_ref;
28850         CHECK((*env)->GetArrayLength(env, val) == 32);
28851         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28852         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
28853 }
28854
28855 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28856         LDKInMemorySigner this_ptr_conv;
28857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28858         this_ptr_conv.is_owned = false;
28859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28860         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28861         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
28862         return ret_arr;
28863 }
28864
28865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28866         LDKInMemorySigner this_ptr_conv;
28867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28868         this_ptr_conv.is_owned = false;
28869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28870         LDKSecretKey val_ref;
28871         CHECK((*env)->GetArrayLength(env, val) == 32);
28872         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28873         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
28874 }
28875
28876 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
28877         LDKInMemorySigner this_ptr_conv;
28878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28879         this_ptr_conv.is_owned = false;
28880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28881         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28882         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
28883         return ret_arr;
28884 }
28885
28886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28887         LDKInMemorySigner this_ptr_conv;
28888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28889         this_ptr_conv.is_owned = false;
28890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28891         LDKThirtyTwoBytes val_ref;
28892         CHECK((*env)->GetArrayLength(env, val) == 32);
28893         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28894         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
28895 }
28896
28897 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
28898         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
28899 int64_t ret_ref = 0;
28900 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28901 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28902 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28903 ret_ref = (uintptr_t)ret_var.inner;
28904 if (ret_var.is_owned) {
28905         ret_ref |= 1;
28906 }
28907         return ret_ref;
28908 }
28909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28910         LDKInMemorySigner arg_conv;
28911         arg_conv.inner = (void*)(arg & (~1));
28912         arg_conv.is_owned = false;
28913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28914         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
28915         return ret_conv;
28916 }
28917
28918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28919         LDKInMemorySigner orig_conv;
28920         orig_conv.inner = (void*)(orig & (~1));
28921         orig_conv.is_owned = false;
28922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28923         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
28924         int64_t ret_ref = 0;
28925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28928         ret_ref = (uintptr_t)ret_var.inner;
28929         if (ret_var.is_owned) {
28930                 ret_ref |= 1;
28931         }
28932         return ret_ref;
28933 }
28934
28935 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) {
28936         LDKSecretKey node_secret_ref;
28937         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
28938         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
28939         LDKSecretKey funding_key_ref;
28940         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
28941         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
28942         LDKSecretKey revocation_base_key_ref;
28943         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
28944         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
28945         LDKSecretKey payment_key_ref;
28946         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
28947         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
28948         LDKSecretKey delayed_payment_base_key_ref;
28949         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
28950         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
28951         LDKSecretKey htlc_base_key_ref;
28952         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
28953         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
28954         LDKThirtyTwoBytes commitment_seed_ref;
28955         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
28956         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
28957         LDKThirtyTwoBytes channel_keys_id_ref;
28958         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
28959         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
28960         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);
28961         int64_t ret_ref = 0;
28962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28965         ret_ref = (uintptr_t)ret_var.inner;
28966         if (ret_var.is_owned) {
28967                 ret_ref |= 1;
28968         }
28969         return ret_ref;
28970 }
28971
28972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
28973         LDKInMemorySigner this_arg_conv;
28974         this_arg_conv.inner = (void*)(this_arg & (~1));
28975         this_arg_conv.is_owned = false;
28976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28977         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
28978         int64_t ret_ref = 0;
28979         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28980         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28982         ret_ref = (uintptr_t)ret_var.inner;
28983         if (ret_var.is_owned) {
28984                 ret_ref |= 1;
28985         }
28986         return ret_ref;
28987 }
28988
28989 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28990         LDKInMemorySigner this_arg_conv;
28991         this_arg_conv.inner = (void*)(this_arg & (~1));
28992         this_arg_conv.is_owned = false;
28993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28994         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
28995         return ret_conv;
28996 }
28997
28998 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28999         LDKInMemorySigner this_arg_conv;
29000         this_arg_conv.inner = (void*)(this_arg & (~1));
29001         this_arg_conv.is_owned = false;
29002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29003         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
29004         return ret_conv;
29005 }
29006
29007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
29008         LDKInMemorySigner this_arg_conv;
29009         this_arg_conv.inner = (void*)(this_arg & (~1));
29010         this_arg_conv.is_owned = false;
29011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29012         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
29013         return ret_conv;
29014 }
29015
29016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
29017         LDKInMemorySigner this_arg_conv;
29018         this_arg_conv.inner = (void*)(this_arg & (~1));
29019         this_arg_conv.is_owned = false;
29020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29021         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
29022         int64_t ret_ref = 0;
29023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29026         ret_ref = (uintptr_t)ret_var.inner;
29027         if (ret_var.is_owned) {
29028                 ret_ref |= 1;
29029         }
29030         return ret_ref;
29031 }
29032
29033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
29034         LDKInMemorySigner this_arg_conv;
29035         this_arg_conv.inner = (void*)(this_arg & (~1));
29036         this_arg_conv.is_owned = false;
29037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29038         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
29039         int64_t ret_ref = 0;
29040         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29041         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29043         ret_ref = (uintptr_t)ret_var.inner;
29044         if (ret_var.is_owned) {
29045                 ret_ref |= 1;
29046         }
29047         return ret_ref;
29048 }
29049
29050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
29051         LDKInMemorySigner this_arg_conv;
29052         this_arg_conv.inner = (void*)(this_arg & (~1));
29053         this_arg_conv.is_owned = false;
29054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29055         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
29056         return ret_conv;
29057 }
29058
29059 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) {
29060         LDKInMemorySigner this_arg_conv;
29061         this_arg_conv.inner = (void*)(this_arg & (~1));
29062         this_arg_conv.is_owned = false;
29063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29064         LDKTransaction spend_tx_ref;
29065         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29066         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29067         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29068         spend_tx_ref.data_is_owned = true;
29069         LDKStaticPaymentOutputDescriptor descriptor_conv;
29070         descriptor_conv.inner = (void*)(descriptor & (~1));
29071         descriptor_conv.is_owned = false;
29072         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29073         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29074         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29075         return (int64_t)ret_conv;
29076 }
29077
29078 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) {
29079         LDKInMemorySigner this_arg_conv;
29080         this_arg_conv.inner = (void*)(this_arg & (~1));
29081         this_arg_conv.is_owned = false;
29082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29083         LDKTransaction spend_tx_ref;
29084         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29085         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29086         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29087         spend_tx_ref.data_is_owned = true;
29088         LDKDelayedPaymentOutputDescriptor descriptor_conv;
29089         descriptor_conv.inner = (void*)(descriptor & (~1));
29090         descriptor_conv.is_owned = false;
29091         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29092         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29093         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29094         return (int64_t)ret_conv;
29095 }
29096
29097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
29098         LDKInMemorySigner this_arg_conv;
29099         this_arg_conv.inner = (void*)(this_arg & (~1));
29100         this_arg_conv.is_owned = false;
29101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29102         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
29103         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
29104         return (int64_t)ret_ret;
29105 }
29106
29107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
29108         LDKInMemorySigner this_arg_conv;
29109         this_arg_conv.inner = (void*)(this_arg & (~1));
29110         this_arg_conv.is_owned = false;
29111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29112         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29113         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
29114         return (int64_t)ret_ret;
29115 }
29116
29117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
29118         LDKInMemorySigner obj_conv;
29119         obj_conv.inner = (void*)(obj & (~1));
29120         obj_conv.is_owned = false;
29121         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29122         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
29123         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29124         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29125         CVec_u8Z_free(ret_var);
29126         return ret_arr;
29127 }
29128
29129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
29130         LDKu8slice ser_ref;
29131         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29132         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29133         LDKSecretKey arg_ref;
29134         CHECK((*env)->GetArrayLength(env, arg) == 32);
29135         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
29136         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
29137         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
29138         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29139         return (int64_t)ret_conv;
29140 }
29141
29142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29143         LDKKeysManager this_obj_conv;
29144         this_obj_conv.inner = (void*)(this_obj & (~1));
29145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29147         KeysManager_free(this_obj_conv);
29148 }
29149
29150 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) {
29151         unsigned char seed_arr[32];
29152         CHECK((*env)->GetArrayLength(env, seed) == 32);
29153         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29154         unsigned char (*seed_ref)[32] = &seed_arr;
29155         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
29156         int64_t ret_ref = 0;
29157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29160         ret_ref = (uintptr_t)ret_var.inner;
29161         if (ret_var.is_owned) {
29162                 ret_ref |= 1;
29163         }
29164         return ret_ref;
29165 }
29166
29167 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) {
29168         LDKKeysManager this_arg_conv;
29169         this_arg_conv.inner = (void*)(this_arg & (~1));
29170         this_arg_conv.is_owned = false;
29171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29172         unsigned char params_arr[32];
29173         CHECK((*env)->GetArrayLength(env, params) == 32);
29174         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29175         unsigned char (*params_ref)[32] = &params_arr;
29176         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29177         int64_t ret_ref = 0;
29178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29181         ret_ref = (uintptr_t)ret_var.inner;
29182         if (ret_var.is_owned) {
29183                 ret_ref |= 1;
29184         }
29185         return ret_ref;
29186 }
29187
29188 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) {
29189         LDKKeysManager this_arg_conv;
29190         this_arg_conv.inner = (void*)(this_arg & (~1));
29191         this_arg_conv.is_owned = false;
29192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29193         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29194         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29195         if (descriptors_constr.datalen > 0)
29196                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29197         else
29198                 descriptors_constr.data = NULL;
29199         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29200         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29201                 int64_t descriptors_conv_27 = descriptors_vals[b];
29202                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
29203                 CHECK_ACCESS(descriptors_conv_27_ptr);
29204                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29205                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
29206                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29207         }
29208         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29209         LDKCVec_TxOutZ outputs_constr;
29210         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29211         if (outputs_constr.datalen > 0)
29212                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29213         else
29214                 outputs_constr.data = NULL;
29215         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29216         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29217                 int64_t outputs_conv_7 = outputs_vals[h];
29218                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
29219                 CHECK_ACCESS(outputs_conv_7_ptr);
29220                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29221                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
29222                 outputs_constr.data[h] = outputs_conv_7_conv;
29223         }
29224         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29225         LDKCVec_u8Z change_destination_script_ref;
29226         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29227         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29228         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29229         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29230         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29231         return (int64_t)ret_conv;
29232 }
29233
29234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29235         LDKKeysManager this_arg_conv;
29236         this_arg_conv.inner = (void*)(this_arg & (~1));
29237         this_arg_conv.is_owned = false;
29238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29239         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29240         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
29241         return (int64_t)ret_ret;
29242 }
29243
29244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29245         LDKPhantomKeysManager this_obj_conv;
29246         this_obj_conv.inner = (void*)(this_obj & (~1));
29247         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29249         PhantomKeysManager_free(this_obj_conv);
29250 }
29251
29252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29253         LDKPhantomKeysManager this_arg_conv;
29254         this_arg_conv.inner = (void*)(this_arg & (~1));
29255         this_arg_conv.is_owned = false;
29256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29257         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29258         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
29259         return (int64_t)ret_ret;
29260 }
29261
29262 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) {
29263         unsigned char seed_arr[32];
29264         CHECK((*env)->GetArrayLength(env, seed) == 32);
29265         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29266         unsigned char (*seed_ref)[32] = &seed_arr;
29267         unsigned char cross_node_seed_arr[32];
29268         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
29269         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
29270         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
29271         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
29272         int64_t ret_ref = 0;
29273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29276         ret_ref = (uintptr_t)ret_var.inner;
29277         if (ret_var.is_owned) {
29278                 ret_ref |= 1;
29279         }
29280         return ret_ref;
29281 }
29282
29283 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) {
29284         LDKPhantomKeysManager this_arg_conv;
29285         this_arg_conv.inner = (void*)(this_arg & (~1));
29286         this_arg_conv.is_owned = false;
29287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29288         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29289         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29290         if (descriptors_constr.datalen > 0)
29291                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29292         else
29293                 descriptors_constr.data = NULL;
29294         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29295         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29296                 int64_t descriptors_conv_27 = descriptors_vals[b];
29297                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
29298                 CHECK_ACCESS(descriptors_conv_27_ptr);
29299                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29300                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
29301                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29302         }
29303         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29304         LDKCVec_TxOutZ outputs_constr;
29305         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29306         if (outputs_constr.datalen > 0)
29307                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29308         else
29309                 outputs_constr.data = NULL;
29310         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29311         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29312                 int64_t outputs_conv_7 = outputs_vals[h];
29313                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
29314                 CHECK_ACCESS(outputs_conv_7_ptr);
29315                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29316                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
29317                 outputs_constr.data[h] = outputs_conv_7_conv;
29318         }
29319         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29320         LDKCVec_u8Z change_destination_script_ref;
29321         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29322         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29323         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29324         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29325         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29326         return (int64_t)ret_conv;
29327 }
29328
29329 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) {
29330         LDKPhantomKeysManager this_arg_conv;
29331         this_arg_conv.inner = (void*)(this_arg & (~1));
29332         this_arg_conv.is_owned = false;
29333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29334         unsigned char params_arr[32];
29335         CHECK((*env)->GetArrayLength(env, params) == 32);
29336         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29337         unsigned char (*params_ref)[32] = &params_arr;
29338         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29339         int64_t ret_ref = 0;
29340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29343         ret_ref = (uintptr_t)ret_var.inner;
29344         if (ret_var.is_owned) {
29345                 ret_ref |= 1;
29346         }
29347         return ret_ref;
29348 }
29349
29350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29351         LDKChannelManager this_obj_conv;
29352         this_obj_conv.inner = (void*)(this_obj & (~1));
29353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29355         ChannelManager_free(this_obj_conv);
29356 }
29357
29358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29359         LDKChainParameters this_obj_conv;
29360         this_obj_conv.inner = (void*)(this_obj & (~1));
29361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29363         ChainParameters_free(this_obj_conv);
29364 }
29365
29366 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
29367         LDKChainParameters this_ptr_conv;
29368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29369         this_ptr_conv.is_owned = false;
29370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29371         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
29372         return ret_conv;
29373 }
29374
29375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
29376         LDKChainParameters this_ptr_conv;
29377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29378         this_ptr_conv.is_owned = false;
29379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29380         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
29381         ChainParameters_set_network(&this_ptr_conv, val_conv);
29382 }
29383
29384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
29385         LDKChainParameters this_ptr_conv;
29386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29387         this_ptr_conv.is_owned = false;
29388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29389         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
29390         int64_t ret_ref = 0;
29391         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29392         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29394         ret_ref = (uintptr_t)ret_var.inner;
29395         if (ret_var.is_owned) {
29396                 ret_ref |= 1;
29397         }
29398         return ret_ref;
29399 }
29400
29401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29402         LDKChainParameters this_ptr_conv;
29403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29404         this_ptr_conv.is_owned = false;
29405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29406         LDKBestBlock val_conv;
29407         val_conv.inner = (void*)(val & (~1));
29408         val_conv.is_owned = (val & 1) || (val == 0);
29409         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29410         val_conv = BestBlock_clone(&val_conv);
29411         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
29412 }
29413
29414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
29415         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
29416         LDKBestBlock best_block_arg_conv;
29417         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
29418         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
29419         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
29420         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
29421         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
29422         int64_t ret_ref = 0;
29423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29426         ret_ref = (uintptr_t)ret_var.inner;
29427         if (ret_var.is_owned) {
29428                 ret_ref |= 1;
29429         }
29430         return ret_ref;
29431 }
29432
29433 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
29434         LDKChainParameters ret_var = ChainParameters_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29446         LDKChainParameters arg_conv;
29447         arg_conv.inner = (void*)(arg & (~1));
29448         arg_conv.is_owned = false;
29449         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29450         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
29451         return ret_conv;
29452 }
29453
29454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29455         LDKChainParameters orig_conv;
29456         orig_conv.inner = (void*)(orig & (~1));
29457         orig_conv.is_owned = false;
29458         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29459         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
29460         int64_t ret_ref = 0;
29461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29464         ret_ref = (uintptr_t)ret_var.inner;
29465         if (ret_var.is_owned) {
29466                 ret_ref |= 1;
29467         }
29468         return ret_ref;
29469 }
29470
29471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29472         LDKCounterpartyForwardingInfo this_obj_conv;
29473         this_obj_conv.inner = (void*)(this_obj & (~1));
29474         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29476         CounterpartyForwardingInfo_free(this_obj_conv);
29477 }
29478
29479 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29480         LDKCounterpartyForwardingInfo this_ptr_conv;
29481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29482         this_ptr_conv.is_owned = false;
29483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29484         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
29485         return ret_conv;
29486 }
29487
29488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29489         LDKCounterpartyForwardingInfo this_ptr_conv;
29490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29491         this_ptr_conv.is_owned = false;
29492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29493         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
29494 }
29495
29496 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
29497         LDKCounterpartyForwardingInfo this_ptr_conv;
29498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29499         this_ptr_conv.is_owned = false;
29500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29501         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
29502         return ret_conv;
29503 }
29504
29505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29506         LDKCounterpartyForwardingInfo this_ptr_conv;
29507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29508         this_ptr_conv.is_owned = false;
29509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29510         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
29511 }
29512
29513 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29514         LDKCounterpartyForwardingInfo this_ptr_conv;
29515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29516         this_ptr_conv.is_owned = false;
29517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29518         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
29519         return ret_conv;
29520 }
29521
29522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29523         LDKCounterpartyForwardingInfo this_ptr_conv;
29524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29525         this_ptr_conv.is_owned = false;
29526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29527         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
29528 }
29529
29530 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) {
29531         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
29532         int64_t ret_ref = 0;
29533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29536         ret_ref = (uintptr_t)ret_var.inner;
29537         if (ret_var.is_owned) {
29538                 ret_ref |= 1;
29539         }
29540         return ret_ref;
29541 }
29542
29543 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
29544         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
29545 int64_t ret_ref = 0;
29546 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29547 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29548 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29549 ret_ref = (uintptr_t)ret_var.inner;
29550 if (ret_var.is_owned) {
29551         ret_ref |= 1;
29552 }
29553         return ret_ref;
29554 }
29555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29556         LDKCounterpartyForwardingInfo arg_conv;
29557         arg_conv.inner = (void*)(arg & (~1));
29558         arg_conv.is_owned = false;
29559         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29560         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
29561         return ret_conv;
29562 }
29563
29564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29565         LDKCounterpartyForwardingInfo orig_conv;
29566         orig_conv.inner = (void*)(orig & (~1));
29567         orig_conv.is_owned = false;
29568         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29569         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
29570         int64_t ret_ref = 0;
29571         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29572         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29574         ret_ref = (uintptr_t)ret_var.inner;
29575         if (ret_var.is_owned) {
29576                 ret_ref |= 1;
29577         }
29578         return ret_ref;
29579 }
29580
29581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29582         LDKChannelCounterparty this_obj_conv;
29583         this_obj_conv.inner = (void*)(this_obj & (~1));
29584         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29586         ChannelCounterparty_free(this_obj_conv);
29587 }
29588
29589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29590         LDKChannelCounterparty this_ptr_conv;
29591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29592         this_ptr_conv.is_owned = false;
29593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29594         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29595         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
29596         return ret_arr;
29597 }
29598
29599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29600         LDKChannelCounterparty this_ptr_conv;
29601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29602         this_ptr_conv.is_owned = false;
29603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29604         LDKPublicKey val_ref;
29605         CHECK((*env)->GetArrayLength(env, val) == 33);
29606         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29607         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
29608 }
29609
29610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29611         LDKChannelCounterparty this_ptr_conv;
29612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29613         this_ptr_conv.is_owned = false;
29614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29615         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
29616         int64_t ret_ref = 0;
29617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29620         ret_ref = (uintptr_t)ret_var.inner;
29621         if (ret_var.is_owned) {
29622                 ret_ref |= 1;
29623         }
29624         return ret_ref;
29625 }
29626
29627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29628         LDKChannelCounterparty this_ptr_conv;
29629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29630         this_ptr_conv.is_owned = false;
29631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29632         LDKInitFeatures val_conv;
29633         val_conv.inner = (void*)(val & (~1));
29634         val_conv.is_owned = (val & 1) || (val == 0);
29635         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29636         val_conv = InitFeatures_clone(&val_conv);
29637         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
29638 }
29639
29640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
29641         LDKChannelCounterparty this_ptr_conv;
29642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29643         this_ptr_conv.is_owned = false;
29644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29645         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
29646         return ret_conv;
29647 }
29648
29649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29650         LDKChannelCounterparty this_ptr_conv;
29651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29652         this_ptr_conv.is_owned = false;
29653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29654         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
29655 }
29656
29657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
29658         LDKChannelCounterparty this_ptr_conv;
29659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29660         this_ptr_conv.is_owned = false;
29661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29662         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
29663         int64_t ret_ref = 0;
29664         if ((uintptr_t)ret_var.inner > 4096) {
29665                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29666                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29668                 ret_ref = (uintptr_t)ret_var.inner;
29669                 if (ret_var.is_owned) {
29670                         ret_ref |= 1;
29671                 }
29672         }
29673         return ret_ref;
29674 }
29675
29676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29677         LDKChannelCounterparty this_ptr_conv;
29678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29679         this_ptr_conv.is_owned = false;
29680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29681         LDKCounterpartyForwardingInfo val_conv;
29682         val_conv.inner = (void*)(val & (~1));
29683         val_conv.is_owned = (val & 1) || (val == 0);
29684         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29685         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
29686         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
29687 }
29688
29689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29690         LDKChannelCounterparty this_ptr_conv;
29691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29692         this_ptr_conv.is_owned = false;
29693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29694         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29695         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
29696         int64_t ret_ref = (uintptr_t)ret_copy;
29697         return ret_ref;
29698 }
29699
29700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29701         LDKChannelCounterparty this_ptr_conv;
29702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29703         this_ptr_conv.is_owned = false;
29704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29705         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29706         CHECK_ACCESS(val_ptr);
29707         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29708         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29709         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
29710 }
29711
29712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29713         LDKChannelCounterparty this_ptr_conv;
29714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29715         this_ptr_conv.is_owned = false;
29716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29717         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29718         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
29719         int64_t ret_ref = (uintptr_t)ret_copy;
29720         return ret_ref;
29721 }
29722
29723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29724         LDKChannelCounterparty 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         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29731         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29732         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
29733 }
29734
29735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg, int64_t outbound_htlc_minimum_msat_arg, int64_t outbound_htlc_maximum_msat_arg) {
29736         LDKPublicKey node_id_arg_ref;
29737         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
29738         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
29739         LDKInitFeatures features_arg_conv;
29740         features_arg_conv.inner = (void*)(features_arg & (~1));
29741         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29742         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29743         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29744         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
29745         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
29746         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
29747         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
29748         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
29749         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
29750         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
29751         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
29752         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
29753         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
29754         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
29755         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
29756         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
29757         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv, outbound_htlc_minimum_msat_arg_conv, outbound_htlc_maximum_msat_arg_conv);
29758         int64_t ret_ref = 0;
29759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29762         ret_ref = (uintptr_t)ret_var.inner;
29763         if (ret_var.is_owned) {
29764                 ret_ref |= 1;
29765         }
29766         return ret_ref;
29767 }
29768
29769 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
29770         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
29771 int64_t ret_ref = 0;
29772 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29773 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29774 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29775 ret_ref = (uintptr_t)ret_var.inner;
29776 if (ret_var.is_owned) {
29777         ret_ref |= 1;
29778 }
29779         return ret_ref;
29780 }
29781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29782         LDKChannelCounterparty arg_conv;
29783         arg_conv.inner = (void*)(arg & (~1));
29784         arg_conv.is_owned = false;
29785         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29786         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
29787         return ret_conv;
29788 }
29789
29790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29791         LDKChannelCounterparty orig_conv;
29792         orig_conv.inner = (void*)(orig & (~1));
29793         orig_conv.is_owned = false;
29794         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29795         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
29796         int64_t ret_ref = 0;
29797         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29798         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29800         ret_ref = (uintptr_t)ret_var.inner;
29801         if (ret_var.is_owned) {
29802                 ret_ref |= 1;
29803         }
29804         return ret_ref;
29805 }
29806
29807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29808         LDKChannelDetails this_obj_conv;
29809         this_obj_conv.inner = (void*)(this_obj & (~1));
29810         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29812         ChannelDetails_free(this_obj_conv);
29813 }
29814
29815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29816         LDKChannelDetails this_ptr_conv;
29817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29818         this_ptr_conv.is_owned = false;
29819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29820         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29821         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
29822         return ret_arr;
29823 }
29824
29825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29826         LDKChannelDetails this_ptr_conv;
29827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29828         this_ptr_conv.is_owned = false;
29829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29830         LDKThirtyTwoBytes val_ref;
29831         CHECK((*env)->GetArrayLength(env, val) == 32);
29832         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29833         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
29834 }
29835
29836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
29837         LDKChannelDetails this_ptr_conv;
29838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29839         this_ptr_conv.is_owned = false;
29840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29841         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
29842         int64_t ret_ref = 0;
29843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29846         ret_ref = (uintptr_t)ret_var.inner;
29847         if (ret_var.is_owned) {
29848                 ret_ref |= 1;
29849         }
29850         return ret_ref;
29851 }
29852
29853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29854         LDKChannelDetails this_ptr_conv;
29855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29856         this_ptr_conv.is_owned = false;
29857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29858         LDKChannelCounterparty val_conv;
29859         val_conv.inner = (void*)(val & (~1));
29860         val_conv.is_owned = (val & 1) || (val == 0);
29861         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29862         val_conv = ChannelCounterparty_clone(&val_conv);
29863         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
29864 }
29865
29866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
29867         LDKChannelDetails this_ptr_conv;
29868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29869         this_ptr_conv.is_owned = false;
29870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29871         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
29872         int64_t ret_ref = 0;
29873         if ((uintptr_t)ret_var.inner > 4096) {
29874                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29875                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29877                 ret_ref = (uintptr_t)ret_var.inner;
29878                 if (ret_var.is_owned) {
29879                         ret_ref |= 1;
29880                 }
29881         }
29882         return ret_ref;
29883 }
29884
29885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29886         LDKChannelDetails this_ptr_conv;
29887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29888         this_ptr_conv.is_owned = false;
29889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29890         LDKOutPoint val_conv;
29891         val_conv.inner = (void*)(val & (~1));
29892         val_conv.is_owned = (val & 1) || (val == 0);
29893         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29894         val_conv = OutPoint_clone(&val_conv);
29895         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
29896 }
29897
29898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
29899         LDKChannelDetails this_ptr_conv;
29900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29901         this_ptr_conv.is_owned = false;
29902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29903         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
29904         int64_t ret_ref = 0;
29905         if ((uintptr_t)ret_var.inner > 4096) {
29906                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29907                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29909                 ret_ref = (uintptr_t)ret_var.inner;
29910                 if (ret_var.is_owned) {
29911                         ret_ref |= 1;
29912                 }
29913         }
29914         return ret_ref;
29915 }
29916
29917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29918         LDKChannelDetails this_ptr_conv;
29919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29920         this_ptr_conv.is_owned = false;
29921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29922         LDKChannelTypeFeatures val_conv;
29923         val_conv.inner = (void*)(val & (~1));
29924         val_conv.is_owned = (val & 1) || (val == 0);
29925         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29926         val_conv = ChannelTypeFeatures_clone(&val_conv);
29927         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
29928 }
29929
29930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29931         LDKChannelDetails this_ptr_conv;
29932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29933         this_ptr_conv.is_owned = false;
29934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29935         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29936         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
29937         int64_t ret_ref = (uintptr_t)ret_copy;
29938         return ret_ref;
29939 }
29940
29941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29942         LDKChannelDetails this_ptr_conv;
29943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29944         this_ptr_conv.is_owned = false;
29945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29946         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29947         CHECK_ACCESS(val_ptr);
29948         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29949         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29950         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
29951 }
29952
29953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29954         LDKChannelDetails this_ptr_conv;
29955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29956         this_ptr_conv.is_owned = false;
29957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29958         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29959         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
29960         int64_t ret_ref = (uintptr_t)ret_copy;
29961         return ret_ref;
29962 }
29963
29964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29965         LDKChannelDetails this_ptr_conv;
29966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29967         this_ptr_conv.is_owned = false;
29968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29969         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29970         CHECK_ACCESS(val_ptr);
29971         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29972         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29973         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
29974 }
29975
29976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29977         LDKChannelDetails this_ptr_conv;
29978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29979         this_ptr_conv.is_owned = false;
29980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29981         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29982         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
29983         int64_t ret_ref = (uintptr_t)ret_copy;
29984         return ret_ref;
29985 }
29986
29987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29988         LDKChannelDetails this_ptr_conv;
29989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29990         this_ptr_conv.is_owned = false;
29991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29992         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29993         CHECK_ACCESS(val_ptr);
29994         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29995         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29996         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
29997 }
29998
29999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30000         LDKChannelDetails this_ptr_conv;
30001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30002         this_ptr_conv.is_owned = false;
30003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30004         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
30005         return ret_conv;
30006 }
30007
30008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30009         LDKChannelDetails this_ptr_conv;
30010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30011         this_ptr_conv.is_owned = false;
30012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30013         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
30014 }
30015
30016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
30017         LDKChannelDetails this_ptr_conv;
30018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30019         this_ptr_conv.is_owned = false;
30020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30021         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30022         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
30023         int64_t ret_ref = (uintptr_t)ret_copy;
30024         return ret_ref;
30025 }
30026
30027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30028         LDKChannelDetails this_ptr_conv;
30029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30030         this_ptr_conv.is_owned = false;
30031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30032         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30033         CHECK_ACCESS(val_ptr);
30034         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30035         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30036         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
30037 }
30038
30039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30040         LDKChannelDetails this_ptr_conv;
30041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30042         this_ptr_conv.is_owned = false;
30043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30044         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
30045         return ret_conv;
30046 }
30047
30048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30049         LDKChannelDetails this_ptr_conv;
30050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30051         this_ptr_conv.is_owned = false;
30052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30053         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
30054 }
30055
30056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30057         LDKChannelDetails this_ptr_conv;
30058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30059         this_ptr_conv.is_owned = false;
30060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30061         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
30062         return ret_conv;
30063 }
30064
30065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30066         LDKChannelDetails this_ptr_conv;
30067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30068         this_ptr_conv.is_owned = false;
30069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30070         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
30071 }
30072
30073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30074         LDKChannelDetails this_ptr_conv;
30075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30076         this_ptr_conv.is_owned = false;
30077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30078         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
30079         return ret_conv;
30080 }
30081
30082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30083         LDKChannelDetails this_ptr_conv;
30084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30085         this_ptr_conv.is_owned = false;
30086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30087         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
30088 }
30089
30090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30091         LDKChannelDetails this_ptr_conv;
30092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30093         this_ptr_conv.is_owned = false;
30094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30095         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
30096         return ret_conv;
30097 }
30098
30099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30100         LDKChannelDetails this_ptr_conv;
30101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30102         this_ptr_conv.is_owned = false;
30103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30104         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
30105 }
30106
30107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30108         LDKChannelDetails this_ptr_conv;
30109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30110         this_ptr_conv.is_owned = false;
30111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30112         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
30113         return ret_conv;
30114 }
30115
30116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30117         LDKChannelDetails this_ptr_conv;
30118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30119         this_ptr_conv.is_owned = false;
30120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30121         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
30122 }
30123
30124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
30125         LDKChannelDetails this_ptr_conv;
30126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30127         this_ptr_conv.is_owned = false;
30128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30129         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
30130         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
30131         int64_t ret_ref = (uintptr_t)ret_copy;
30132         return ret_ref;
30133 }
30134
30135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30136         LDKChannelDetails this_ptr_conv;
30137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30138         this_ptr_conv.is_owned = false;
30139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30140         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30141         CHECK_ACCESS(val_ptr);
30142         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
30143         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
30144         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
30145 }
30146
30147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30148         LDKChannelDetails this_ptr_conv;
30149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30150         this_ptr_conv.is_owned = false;
30151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30152         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
30153         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
30154         int64_t ret_ref = (uintptr_t)ret_copy;
30155         return ret_ref;
30156 }
30157
30158 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) {
30159         LDKChannelDetails this_ptr_conv;
30160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30161         this_ptr_conv.is_owned = false;
30162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30163         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30164         CHECK_ACCESS(val_ptr);
30165         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
30166         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
30167         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
30168 }
30169
30170 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
30171         LDKChannelDetails this_ptr_conv;
30172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30173         this_ptr_conv.is_owned = false;
30174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30175         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
30176         return ret_conv;
30177 }
30178
30179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30180         LDKChannelDetails this_ptr_conv;
30181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30182         this_ptr_conv.is_owned = false;
30183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30184         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
30185 }
30186
30187 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
30188         LDKChannelDetails 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         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
30193         return ret_conv;
30194 }
30195
30196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30197         LDKChannelDetails this_ptr_conv;
30198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30199         this_ptr_conv.is_owned = false;
30200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30201         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
30202 }
30203
30204 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
30205         LDKChannelDetails this_ptr_conv;
30206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30207         this_ptr_conv.is_owned = false;
30208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30209         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
30210         return ret_conv;
30211 }
30212
30213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30214         LDKChannelDetails this_ptr_conv;
30215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30216         this_ptr_conv.is_owned = false;
30217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30218         ChannelDetails_set_is_usable(&this_ptr_conv, val);
30219 }
30220
30221 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
30222         LDKChannelDetails this_ptr_conv;
30223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30224         this_ptr_conv.is_owned = false;
30225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30226         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
30227         return ret_conv;
30228 }
30229
30230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30231         LDKChannelDetails this_ptr_conv;
30232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30233         this_ptr_conv.is_owned = false;
30234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30235         ChannelDetails_set_is_public(&this_ptr_conv, val);
30236 }
30237
30238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30239         LDKChannelDetails this_ptr_conv;
30240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30241         this_ptr_conv.is_owned = false;
30242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30243         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30244         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
30245         int64_t ret_ref = (uintptr_t)ret_copy;
30246         return ret_ref;
30247 }
30248
30249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30250         LDKChannelDetails this_ptr_conv;
30251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30252         this_ptr_conv.is_owned = false;
30253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30254         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30255         CHECK_ACCESS(val_ptr);
30256         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30257         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30258         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
30259 }
30260
30261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30262         LDKChannelDetails this_ptr_conv;
30263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30264         this_ptr_conv.is_owned = false;
30265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30266         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30267         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
30268         int64_t ret_ref = (uintptr_t)ret_copy;
30269         return ret_ref;
30270 }
30271
30272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30273         LDKChannelDetails this_ptr_conv;
30274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30275         this_ptr_conv.is_owned = false;
30276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30277         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30278         CHECK_ACCESS(val_ptr);
30279         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30280         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30281         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
30282 }
30283
30284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
30285         LDKChannelDetails this_ptr_conv;
30286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30287         this_ptr_conv.is_owned = false;
30288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30289         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
30290         int64_t ret_ref = 0;
30291         if ((uintptr_t)ret_var.inner > 4096) {
30292                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30293                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30295                 ret_ref = (uintptr_t)ret_var.inner;
30296                 if (ret_var.is_owned) {
30297                         ret_ref |= 1;
30298                 }
30299         }
30300         return ret_ref;
30301 }
30302
30303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30304         LDKChannelDetails this_ptr_conv;
30305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30306         this_ptr_conv.is_owned = false;
30307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30308         LDKChannelConfig val_conv;
30309         val_conv.inner = (void*)(val & (~1));
30310         val_conv.is_owned = (val & 1) || (val == 0);
30311         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30312         val_conv = ChannelConfig_clone(&val_conv);
30313         ChannelDetails_set_config(&this_ptr_conv, val_conv);
30314 }
30315
30316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t outbound_scid_alias_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, int64_t inbound_htlc_minimum_msat_arg, int64_t inbound_htlc_maximum_msat_arg, int64_t config_arg) {
30317         LDKThirtyTwoBytes channel_id_arg_ref;
30318         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30319         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30320         LDKChannelCounterparty counterparty_arg_conv;
30321         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
30322         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
30323         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
30324         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
30325         LDKOutPoint funding_txo_arg_conv;
30326         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
30327         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
30328         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
30329         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
30330         LDKChannelTypeFeatures channel_type_arg_conv;
30331         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
30332         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
30333         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
30334         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
30335         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
30336         CHECK_ACCESS(short_channel_id_arg_ptr);
30337         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
30338         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
30339         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
30340         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
30341         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
30342         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
30343         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
30344         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
30345         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
30346         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
30347         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
30348         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
30349         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
30350         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
30351         CHECK_ACCESS(confirmations_required_arg_ptr);
30352         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
30353         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
30354         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
30355         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
30356         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
30357         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
30358         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
30359         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
30360         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
30361         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
30362         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
30363         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
30364         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
30365         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
30366         LDKChannelConfig config_arg_conv;
30367         config_arg_conv.inner = (void*)(config_arg & (~1));
30368         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
30369         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
30370         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
30371         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
30372         int64_t ret_ref = 0;
30373         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30374         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30376         ret_ref = (uintptr_t)ret_var.inner;
30377         if (ret_var.is_owned) {
30378                 ret_ref |= 1;
30379         }
30380         return ret_ref;
30381 }
30382
30383 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
30384         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
30385 int64_t ret_ref = 0;
30386 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30387 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30388 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30389 ret_ref = (uintptr_t)ret_var.inner;
30390 if (ret_var.is_owned) {
30391         ret_ref |= 1;
30392 }
30393         return ret_ref;
30394 }
30395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30396         LDKChannelDetails arg_conv;
30397         arg_conv.inner = (void*)(arg & (~1));
30398         arg_conv.is_owned = false;
30399         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30400         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
30401         return ret_conv;
30402 }
30403
30404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30405         LDKChannelDetails orig_conv;
30406         orig_conv.inner = (void*)(orig & (~1));
30407         orig_conv.is_owned = false;
30408         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30409         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
30410         int64_t ret_ref = 0;
30411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30414         ret_ref = (uintptr_t)ret_var.inner;
30415         if (ret_var.is_owned) {
30416                 ret_ref |= 1;
30417         }
30418         return ret_ref;
30419 }
30420
30421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30422         LDKChannelDetails this_arg_conv;
30423         this_arg_conv.inner = (void*)(this_arg & (~1));
30424         this_arg_conv.is_owned = false;
30425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30426         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30427         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
30428         int64_t ret_ref = (uintptr_t)ret_copy;
30429         return ret_ref;
30430 }
30431
30432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30433         LDKChannelDetails this_arg_conv;
30434         this_arg_conv.inner = (void*)(this_arg & (~1));
30435         this_arg_conv.is_owned = false;
30436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30437         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30438         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
30439         int64_t ret_ref = (uintptr_t)ret_copy;
30440         return ret_ref;
30441 }
30442
30443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30444         if ((this_ptr & 1) != 0) return;
30445         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30446         CHECK_ACCESS(this_ptr_ptr);
30447         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
30448         FREE((void*)this_ptr);
30449         PaymentSendFailure_free(this_ptr_conv);
30450 }
30451
30452 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
30453         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30454         *ret_copy = PaymentSendFailure_clone(arg);
30455 int64_t ret_ref = (uintptr_t)ret_copy;
30456         return ret_ref;
30457 }
30458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30459         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
30460         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
30461         return ret_conv;
30462 }
30463
30464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30465         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
30466         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30467         *ret_copy = PaymentSendFailure_clone(orig_conv);
30468         int64_t ret_ref = (uintptr_t)ret_copy;
30469         return ret_ref;
30470 }
30471
30472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
30473         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
30474         CHECK_ACCESS(a_ptr);
30475         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
30476         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
30477         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30478         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
30479         int64_t ret_ref = (uintptr_t)ret_copy;
30480         return ret_ref;
30481 }
30482
30483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
30484         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
30485         a_constr.datalen = (*env)->GetArrayLength(env, a);
30486         if (a_constr.datalen > 0)
30487                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
30488         else
30489                 a_constr.data = NULL;
30490         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30491         for (size_t w = 0; w < a_constr.datalen; w++) {
30492                 int64_t a_conv_22 = a_vals[w];
30493                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
30494                 CHECK_ACCESS(a_conv_22_ptr);
30495                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
30496                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
30497                 a_constr.data[w] = a_conv_22_conv;
30498         }
30499         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
30500         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30501         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
30502         int64_t ret_ref = (uintptr_t)ret_copy;
30503         return ret_ref;
30504 }
30505
30506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
30507         LDKCVec_APIErrorZ a_constr;
30508         a_constr.datalen = (*env)->GetArrayLength(env, a);
30509         if (a_constr.datalen > 0)
30510                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
30511         else
30512                 a_constr.data = NULL;
30513         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30514         for (size_t k = 0; k < a_constr.datalen; k++) {
30515                 int64_t a_conv_10 = a_vals[k];
30516                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
30517                 CHECK_ACCESS(a_conv_10_ptr);
30518                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
30519                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
30520                 a_constr.data[k] = a_conv_10_conv;
30521         }
30522         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
30523         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30524         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
30525         int64_t ret_ref = (uintptr_t)ret_copy;
30526         return ret_ref;
30527 }
30528
30529 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) {
30530         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
30531         results_constr.datalen = (*env)->GetArrayLength(env, results);
30532         if (results_constr.datalen > 0)
30533                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
30534         else
30535                 results_constr.data = NULL;
30536         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
30537         for (size_t w = 0; w < results_constr.datalen; w++) {
30538                 int64_t results_conv_22 = results_vals[w];
30539                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
30540                 CHECK_ACCESS(results_conv_22_ptr);
30541                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
30542                 results_constr.data[w] = results_conv_22_conv;
30543         }
30544         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
30545         LDKRouteParameters failed_paths_retry_conv;
30546         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
30547         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
30548         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
30549         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
30550         LDKThirtyTwoBytes payment_id_ref;
30551         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30552         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30553         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30554         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
30555         int64_t ret_ref = (uintptr_t)ret_copy;
30556         return ret_ref;
30557 }
30558
30559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30560         LDKPhantomRouteHints this_obj_conv;
30561         this_obj_conv.inner = (void*)(this_obj & (~1));
30562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30564         PhantomRouteHints_free(this_obj_conv);
30565 }
30566
30567 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
30568         LDKPhantomRouteHints this_ptr_conv;
30569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30570         this_ptr_conv.is_owned = false;
30571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30572         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
30573         int64_tArray ret_arr = NULL;
30574         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30575         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30576         for (size_t q = 0; q < ret_var.datalen; q++) {
30577                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30578                 int64_t ret_conv_16_ref = 0;
30579                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30580                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30581                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30582                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30583                 if (ret_conv_16_var.is_owned) {
30584                         ret_conv_16_ref |= 1;
30585                 }
30586                 ret_arr_ptr[q] = ret_conv_16_ref;
30587         }
30588         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30589         FREE(ret_var.data);
30590         return ret_arr;
30591 }
30592
30593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30594         LDKPhantomRouteHints this_ptr_conv;
30595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30596         this_ptr_conv.is_owned = false;
30597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30598         LDKCVec_ChannelDetailsZ val_constr;
30599         val_constr.datalen = (*env)->GetArrayLength(env, val);
30600         if (val_constr.datalen > 0)
30601                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
30602         else
30603                 val_constr.data = NULL;
30604         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30605         for (size_t q = 0; q < val_constr.datalen; q++) {
30606                 int64_t val_conv_16 = val_vals[q];
30607                 LDKChannelDetails val_conv_16_conv;
30608                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
30609                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
30610                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
30611                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
30612                 val_constr.data[q] = val_conv_16_conv;
30613         }
30614         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30615         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
30616 }
30617
30618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30619         LDKPhantomRouteHints this_ptr_conv;
30620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30621         this_ptr_conv.is_owned = false;
30622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30623         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
30624         return ret_conv;
30625 }
30626
30627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30628         LDKPhantomRouteHints this_ptr_conv;
30629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30630         this_ptr_conv.is_owned = false;
30631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30632         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
30633 }
30634
30635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30636         LDKPhantomRouteHints this_ptr_conv;
30637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30638         this_ptr_conv.is_owned = false;
30639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30640         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30641         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
30642         return ret_arr;
30643 }
30644
30645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30646         LDKPhantomRouteHints this_ptr_conv;
30647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30648         this_ptr_conv.is_owned = false;
30649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30650         LDKPublicKey val_ref;
30651         CHECK((*env)->GetArrayLength(env, val) == 33);
30652         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30653         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
30654 }
30655
30656 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) {
30657         LDKCVec_ChannelDetailsZ channels_arg_constr;
30658         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
30659         if (channels_arg_constr.datalen > 0)
30660                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
30661         else
30662                 channels_arg_constr.data = NULL;
30663         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
30664         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
30665                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
30666                 LDKChannelDetails channels_arg_conv_16_conv;
30667                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
30668                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
30669                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
30670                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
30671                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
30672         }
30673         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
30674         LDKPublicKey real_node_pubkey_arg_ref;
30675         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
30676         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
30677         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
30678         int64_t ret_ref = 0;
30679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30682         ret_ref = (uintptr_t)ret_var.inner;
30683         if (ret_var.is_owned) {
30684                 ret_ref |= 1;
30685         }
30686         return ret_ref;
30687 }
30688
30689 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
30690         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
30691 int64_t ret_ref = 0;
30692 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30693 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30694 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30695 ret_ref = (uintptr_t)ret_var.inner;
30696 if (ret_var.is_owned) {
30697         ret_ref |= 1;
30698 }
30699         return ret_ref;
30700 }
30701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30702         LDKPhantomRouteHints arg_conv;
30703         arg_conv.inner = (void*)(arg & (~1));
30704         arg_conv.is_owned = false;
30705         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30706         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
30707         return ret_conv;
30708 }
30709
30710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30711         LDKPhantomRouteHints orig_conv;
30712         orig_conv.inner = (void*)(orig & (~1));
30713         orig_conv.is_owned = false;
30714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30715         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
30716         int64_t ret_ref = 0;
30717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30720         ret_ref = (uintptr_t)ret_var.inner;
30721         if (ret_var.is_owned) {
30722                 ret_ref |= 1;
30723         }
30724         return ret_ref;
30725 }
30726
30727 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) {
30728         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
30729         CHECK_ACCESS(fee_est_ptr);
30730         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
30731         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
30732                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30733                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
30734         }
30735         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
30736         CHECK_ACCESS(chain_monitor_ptr);
30737         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30738         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30739                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30740                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30741         }
30742         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
30743         CHECK_ACCESS(tx_broadcaster_ptr);
30744         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30745         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30746                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30747                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30748         }
30749         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
30750         CHECK_ACCESS(logger_ptr);
30751         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30752         if (logger_conv.free == LDKLogger_JCalls_free) {
30753                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30754                 LDKLogger_JCalls_cloned(&logger_conv);
30755         }
30756         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30757         CHECK_ACCESS(keys_manager_ptr);
30758         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30759         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30760                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30761                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30762         }
30763         LDKUserConfig config_conv;
30764         config_conv.inner = (void*)(config & (~1));
30765         config_conv.is_owned = (config & 1) || (config == 0);
30766         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
30767         config_conv = UserConfig_clone(&config_conv);
30768         LDKChainParameters params_conv;
30769         params_conv.inner = (void*)(params & (~1));
30770         params_conv.is_owned = (params & 1) || (params == 0);
30771         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
30772         params_conv = ChainParameters_clone(&params_conv);
30773         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
30774         int64_t ret_ref = 0;
30775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30778         ret_ref = (uintptr_t)ret_var.inner;
30779         if (ret_var.is_owned) {
30780                 ret_ref |= 1;
30781         }
30782         return ret_ref;
30783 }
30784
30785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
30786         LDKChannelManager this_arg_conv;
30787         this_arg_conv.inner = (void*)(this_arg & (~1));
30788         this_arg_conv.is_owned = false;
30789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30790         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
30791         int64_t ret_ref = 0;
30792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30795         ret_ref = (uintptr_t)ret_var.inner;
30796         if (ret_var.is_owned) {
30797                 ret_ref |= 1;
30798         }
30799         return ret_ref;
30800 }
30801
30802 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) {
30803         LDKChannelManager this_arg_conv;
30804         this_arg_conv.inner = (void*)(this_arg & (~1));
30805         this_arg_conv.is_owned = false;
30806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30807         LDKPublicKey their_network_key_ref;
30808         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
30809         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
30810         LDKUserConfig override_config_conv;
30811         override_config_conv.inner = (void*)(override_config & (~1));
30812         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
30813         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
30814         override_config_conv = UserConfig_clone(&override_config_conv);
30815         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
30816         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
30817         return (int64_t)ret_conv;
30818 }
30819
30820 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30821         LDKChannelManager this_arg_conv;
30822         this_arg_conv.inner = (void*)(this_arg & (~1));
30823         this_arg_conv.is_owned = false;
30824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30825         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
30826         int64_tArray ret_arr = NULL;
30827         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30828         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30829         for (size_t q = 0; q < ret_var.datalen; q++) {
30830                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30831                 int64_t ret_conv_16_ref = 0;
30832                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30833                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30834                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30835                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30836                 if (ret_conv_16_var.is_owned) {
30837                         ret_conv_16_ref |= 1;
30838                 }
30839                 ret_arr_ptr[q] = ret_conv_16_ref;
30840         }
30841         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30842         FREE(ret_var.data);
30843         return ret_arr;
30844 }
30845
30846 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30847         LDKChannelManager this_arg_conv;
30848         this_arg_conv.inner = (void*)(this_arg & (~1));
30849         this_arg_conv.is_owned = false;
30850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30851         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
30852         int64_tArray ret_arr = NULL;
30853         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30854         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30855         for (size_t q = 0; q < ret_var.datalen; q++) {
30856                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30857                 int64_t ret_conv_16_ref = 0;
30858                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30859                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30860                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30861                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30862                 if (ret_conv_16_var.is_owned) {
30863                         ret_conv_16_ref |= 1;
30864                 }
30865                 ret_arr_ptr[q] = ret_conv_16_ref;
30866         }
30867         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30868         FREE(ret_var.data);
30869         return ret_arr;
30870 }
30871
30872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30873         LDKChannelManager this_arg_conv;
30874         this_arg_conv.inner = (void*)(this_arg & (~1));
30875         this_arg_conv.is_owned = false;
30876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30877         unsigned char channel_id_arr[32];
30878         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30879         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30880         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30881         LDKPublicKey counterparty_node_id_ref;
30882         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30883         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30884         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30885         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30886         return (int64_t)ret_conv;
30887 }
30888
30889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id, int32_t target_feerate_sats_per_1000_weight) {
30890         LDKChannelManager this_arg_conv;
30891         this_arg_conv.inner = (void*)(this_arg & (~1));
30892         this_arg_conv.is_owned = false;
30893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30894         unsigned char channel_id_arr[32];
30895         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30896         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30897         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30898         LDKPublicKey counterparty_node_id_ref;
30899         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30900         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30901         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30902         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
30903         return (int64_t)ret_conv;
30904 }
30905
30906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30907         LDKChannelManager this_arg_conv;
30908         this_arg_conv.inner = (void*)(this_arg & (~1));
30909         this_arg_conv.is_owned = false;
30910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30911         unsigned char channel_id_arr[32];
30912         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30913         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30914         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30915         LDKPublicKey counterparty_node_id_ref;
30916         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30917         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30918         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30919         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30920         return (int64_t)ret_conv;
30921 }
30922
30923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30924         LDKChannelManager this_arg_conv;
30925         this_arg_conv.inner = (void*)(this_arg & (~1));
30926         this_arg_conv.is_owned = false;
30927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30928         unsigned char channel_id_arr[32];
30929         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30930         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30931         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30932         LDKPublicKey counterparty_node_id_ref;
30933         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30934         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30935         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30936         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30937         return (int64_t)ret_conv;
30938 }
30939
30940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30941         LDKChannelManager this_arg_conv;
30942         this_arg_conv.inner = (void*)(this_arg & (~1));
30943         this_arg_conv.is_owned = false;
30944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30945         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
30946 }
30947
30948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30949         LDKChannelManager this_arg_conv;
30950         this_arg_conv.inner = (void*)(this_arg & (~1));
30951         this_arg_conv.is_owned = false;
30952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30953         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
30954 }
30955
30956 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) {
30957         LDKChannelManager this_arg_conv;
30958         this_arg_conv.inner = (void*)(this_arg & (~1));
30959         this_arg_conv.is_owned = false;
30960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30961         LDKRoute route_conv;
30962         route_conv.inner = (void*)(route & (~1));
30963         route_conv.is_owned = false;
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30965         LDKThirtyTwoBytes payment_hash_ref;
30966         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30967         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30968         LDKThirtyTwoBytes payment_secret_ref;
30969         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
30970         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
30971         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
30972         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
30973         return (int64_t)ret_conv;
30974 }
30975
30976 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) {
30977         LDKChannelManager this_arg_conv;
30978         this_arg_conv.inner = (void*)(this_arg & (~1));
30979         this_arg_conv.is_owned = false;
30980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30981         LDKRoute route_conv;
30982         route_conv.inner = (void*)(route & (~1));
30983         route_conv.is_owned = false;
30984         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30985         LDKThirtyTwoBytes payment_id_ref;
30986         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30987         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30988         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
30989         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
30990         return (int64_t)ret_conv;
30991 }
30992
30993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
30994         LDKChannelManager this_arg_conv;
30995         this_arg_conv.inner = (void*)(this_arg & (~1));
30996         this_arg_conv.is_owned = false;
30997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30998         LDKThirtyTwoBytes payment_id_ref;
30999         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31000         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31001         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
31002 }
31003
31004 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) {
31005         LDKChannelManager this_arg_conv;
31006         this_arg_conv.inner = (void*)(this_arg & (~1));
31007         this_arg_conv.is_owned = false;
31008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31009         LDKRoute route_conv;
31010         route_conv.inner = (void*)(route & (~1));
31011         route_conv.is_owned = false;
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31013         LDKThirtyTwoBytes payment_preimage_ref;
31014         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31015         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31016         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31017         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
31018         return (int64_t)ret_conv;
31019 }
31020
31021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
31022         LDKChannelManager this_arg_conv;
31023         this_arg_conv.inner = (void*)(this_arg & (~1));
31024         this_arg_conv.is_owned = false;
31025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31026         LDKCVec_RouteHopZ hops_constr;
31027         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
31028         if (hops_constr.datalen > 0)
31029                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
31030         else
31031                 hops_constr.data = NULL;
31032         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
31033         for (size_t k = 0; k < hops_constr.datalen; k++) {
31034                 int64_t hops_conv_10 = hops_vals[k];
31035                 LDKRouteHop hops_conv_10_conv;
31036                 hops_conv_10_conv.inner = (void*)(hops_conv_10 & (~1));
31037                 hops_conv_10_conv.is_owned = (hops_conv_10 & 1) || (hops_conv_10 == 0);
31038                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
31039                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
31040                 hops_constr.data[k] = hops_conv_10_conv;
31041         }
31042         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
31043         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31044         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
31045         return (int64_t)ret_conv;
31046 }
31047
31048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray funding_transaction) {
31049         LDKChannelManager this_arg_conv;
31050         this_arg_conv.inner = (void*)(this_arg & (~1));
31051         this_arg_conv.is_owned = false;
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31053         unsigned char temporary_channel_id_arr[32];
31054         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31055         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31056         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31057         LDKPublicKey counterparty_node_id_ref;
31058         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31059         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31060         LDKTransaction funding_transaction_ref;
31061         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
31062         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
31063         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
31064         funding_transaction_ref.data_is_owned = true;
31065         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31066         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
31067         return (int64_t)ret_conv;
31068 }
31069
31070 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) {
31071         LDKChannelManager this_arg_conv;
31072         this_arg_conv.inner = (void*)(this_arg & (~1));
31073         this_arg_conv.is_owned = false;
31074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31075         LDKThreeBytes rgb_ref;
31076         CHECK((*env)->GetArrayLength(env, rgb) == 3);
31077         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
31078         LDKThirtyTwoBytes alias_ref;
31079         CHECK((*env)->GetArrayLength(env, alias) == 32);
31080         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
31081         LDKCVec_NetAddressZ addresses_constr;
31082         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
31083         if (addresses_constr.datalen > 0)
31084                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
31085         else
31086                 addresses_constr.data = NULL;
31087         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
31088         for (size_t m = 0; m < addresses_constr.datalen; m++) {
31089                 int64_t addresses_conv_12 = addresses_vals[m];
31090                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
31091                 CHECK_ACCESS(addresses_conv_12_ptr);
31092                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
31093                 addresses_constr.data[m] = addresses_conv_12_conv;
31094         }
31095         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
31096         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
31097 }
31098
31099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1update_1channel_1config(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray counterparty_node_id, jobjectArray channel_ids, int64_t config) {
31100         LDKChannelManager this_arg_conv;
31101         this_arg_conv.inner = (void*)(this_arg & (~1));
31102         this_arg_conv.is_owned = false;
31103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31104         LDKPublicKey counterparty_node_id_ref;
31105         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31106         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31107         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
31108         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
31109         if (channel_ids_constr.datalen > 0)
31110                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
31111         else
31112                 channel_ids_constr.data = NULL;
31113         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
31114                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
31115                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
31116                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
31117                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
31118                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
31119         }
31120         LDKChannelConfig config_conv;
31121         config_conv.inner = (void*)(config & (~1));
31122         config_conv.is_owned = false;
31123         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
31124         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31125         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
31126         return (int64_t)ret_conv;
31127 }
31128
31129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
31130         LDKChannelManager this_arg_conv;
31131         this_arg_conv.inner = (void*)(this_arg & (~1));
31132         this_arg_conv.is_owned = false;
31133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31134         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
31135 }
31136
31137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
31138         LDKChannelManager this_arg_conv;
31139         this_arg_conv.inner = (void*)(this_arg & (~1));
31140         this_arg_conv.is_owned = false;
31141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31142         ChannelManager_timer_tick_occurred(&this_arg_conv);
31143 }
31144
31145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
31146         LDKChannelManager this_arg_conv;
31147         this_arg_conv.inner = (void*)(this_arg & (~1));
31148         this_arg_conv.is_owned = false;
31149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31150         unsigned char payment_hash_arr[32];
31151         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31152         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
31153         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
31154         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
31155 }
31156
31157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
31158         LDKChannelManager this_arg_conv;
31159         this_arg_conv.inner = (void*)(this_arg & (~1));
31160         this_arg_conv.is_owned = false;
31161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31162         LDKThirtyTwoBytes payment_preimage_ref;
31163         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31164         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31165         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
31166 }
31167
31168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
31169         LDKChannelManager this_arg_conv;
31170         this_arg_conv.inner = (void*)(this_arg & (~1));
31171         this_arg_conv.is_owned = false;
31172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31173         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31174         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
31175         return ret_arr;
31176 }
31177
31178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
31179         LDKChannelManager this_arg_conv;
31180         this_arg_conv.inner = (void*)(this_arg & (~1));
31181         this_arg_conv.is_owned = false;
31182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31183         unsigned char temporary_channel_id_arr[32];
31184         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31185         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31186         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31187         LDKPublicKey counterparty_node_id_ref;
31188         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31189         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31190         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31191         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31192         return (int64_t)ret_conv;
31193 }
31194
31195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel_1from_1trusted_1peer_10conf(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
31196         LDKChannelManager this_arg_conv;
31197         this_arg_conv.inner = (void*)(this_arg & (~1));
31198         this_arg_conv.is_owned = false;
31199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31200         unsigned char temporary_channel_id_arr[32];
31201         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31202         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31203         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31204         LDKPublicKey counterparty_node_id_ref;
31205         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31206         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31207         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31208         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31209         return (int64_t)ret_conv;
31210 }
31211
31212 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) {
31213         LDKChannelManager this_arg_conv;
31214         this_arg_conv.inner = (void*)(this_arg & (~1));
31215         this_arg_conv.is_owned = false;
31216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31217         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31218         CHECK_ACCESS(min_value_msat_ptr);
31219         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31220         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31221         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31222         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31223         return (int64_t)ret_conv;
31224 }
31225
31226 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) {
31227         LDKChannelManager this_arg_conv;
31228         this_arg_conv.inner = (void*)(this_arg & (~1));
31229         this_arg_conv.is_owned = false;
31230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31231         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31232         CHECK_ACCESS(min_value_msat_ptr);
31233         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31234         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31235         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
31236         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31237         return (int64_t)ret_conv;
31238 }
31239
31240 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) {
31241         LDKChannelManager this_arg_conv;
31242         this_arg_conv.inner = (void*)(this_arg & (~1));
31243         this_arg_conv.is_owned = false;
31244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31245         LDKThirtyTwoBytes payment_hash_ref;
31246         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31247         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31248         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31249         CHECK_ACCESS(min_value_msat_ptr);
31250         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31251         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31252         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31253         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31254         return (int64_t)ret_conv;
31255 }
31256
31257 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) {
31258         LDKChannelManager this_arg_conv;
31259         this_arg_conv.inner = (void*)(this_arg & (~1));
31260         this_arg_conv.is_owned = false;
31261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31262         LDKThirtyTwoBytes payment_hash_ref;
31263         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31264         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31265         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31266         CHECK_ACCESS(min_value_msat_ptr);
31267         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31268         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31269         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
31270         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31271         return (int64_t)ret_conv;
31272 }
31273
31274 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) {
31275         LDKChannelManager this_arg_conv;
31276         this_arg_conv.inner = (void*)(this_arg & (~1));
31277         this_arg_conv.is_owned = false;
31278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31279         LDKThirtyTwoBytes payment_hash_ref;
31280         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31281         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31282         LDKThirtyTwoBytes payment_secret_ref;
31283         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
31284         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
31285         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
31286         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
31287         return (int64_t)ret_conv;
31288 }
31289
31290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
31291         LDKChannelManager this_arg_conv;
31292         this_arg_conv.inner = (void*)(this_arg & (~1));
31293         this_arg_conv.is_owned = false;
31294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31295         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
31296         return ret_conv;
31297 }
31298
31299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
31300         LDKChannelManager this_arg_conv;
31301         this_arg_conv.inner = (void*)(this_arg & (~1));
31302         this_arg_conv.is_owned = false;
31303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31304         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
31305         int64_t ret_ref = 0;
31306         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31307         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31309         ret_ref = (uintptr_t)ret_var.inner;
31310         if (ret_var.is_owned) {
31311                 ret_ref |= 1;
31312         }
31313         return ret_ref;
31314 }
31315
31316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31317         LDKChannelManager this_arg_conv;
31318         this_arg_conv.inner = (void*)(this_arg & (~1));
31319         this_arg_conv.is_owned = false;
31320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31321         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31322         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
31323         return (int64_t)ret_ret;
31324 }
31325
31326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31327         LDKChannelManager this_arg_conv;
31328         this_arg_conv.inner = (void*)(this_arg & (~1));
31329         this_arg_conv.is_owned = false;
31330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31331         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
31332         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
31333         return (int64_t)ret_ret;
31334 }
31335
31336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
31337         LDKChannelManager this_arg_conv;
31338         this_arg_conv.inner = (void*)(this_arg & (~1));
31339         this_arg_conv.is_owned = false;
31340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31341         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
31342         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
31343         return (int64_t)ret_ret;
31344 }
31345
31346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
31347         LDKChannelManager this_arg_conv;
31348         this_arg_conv.inner = (void*)(this_arg & (~1));
31349         this_arg_conv.is_owned = false;
31350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31351         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
31352         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
31353         return (int64_t)ret_ret;
31354 }
31355
31356 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) {
31357         LDKChannelManager this_arg_conv;
31358         this_arg_conv.inner = (void*)(this_arg & (~1));
31359         this_arg_conv.is_owned = false;
31360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31361         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
31362         return ret_conv;
31363 }
31364
31365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
31366         LDKChannelManager this_arg_conv;
31367         this_arg_conv.inner = (void*)(this_arg & (~1));
31368         this_arg_conv.is_owned = false;
31369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31370         ChannelManager_await_persistable_update(&this_arg_conv);
31371 }
31372
31373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
31374         LDKChannelManager this_arg_conv;
31375         this_arg_conv.inner = (void*)(this_arg & (~1));
31376         this_arg_conv.is_owned = false;
31377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31378         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
31379         int64_t ret_ref = 0;
31380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31383         ret_ref = (uintptr_t)ret_var.inner;
31384         if (ret_var.is_owned) {
31385                 ret_ref |= 1;
31386         }
31387         return ret_ref;
31388 }
31389
31390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31391         LDKChannelManager this_arg_conv;
31392         this_arg_conv.inner = (void*)(this_arg & (~1));
31393         this_arg_conv.is_owned = false;
31394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31395         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
31396         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
31397         return (int64_t)ret_ret;
31398 }
31399
31400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
31401         LDKCounterpartyForwardingInfo obj_conv;
31402         obj_conv.inner = (void*)(obj & (~1));
31403         obj_conv.is_owned = false;
31404         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31405         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
31406         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31407         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31408         CVec_u8Z_free(ret_var);
31409         return ret_arr;
31410 }
31411
31412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31413         LDKu8slice ser_ref;
31414         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31415         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31416         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
31417         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
31418         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31419         return (int64_t)ret_conv;
31420 }
31421
31422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
31423         LDKChannelCounterparty obj_conv;
31424         obj_conv.inner = (void*)(obj & (~1));
31425         obj_conv.is_owned = false;
31426         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31427         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
31428         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31429         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31430         CVec_u8Z_free(ret_var);
31431         return ret_arr;
31432 }
31433
31434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31435         LDKu8slice ser_ref;
31436         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31437         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31438         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
31439         *ret_conv = ChannelCounterparty_read(ser_ref);
31440         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31441         return (int64_t)ret_conv;
31442 }
31443
31444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
31445         LDKChannelDetails obj_conv;
31446         obj_conv.inner = (void*)(obj & (~1));
31447         obj_conv.is_owned = false;
31448         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31449         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
31450         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31451         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31452         CVec_u8Z_free(ret_var);
31453         return ret_arr;
31454 }
31455
31456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31457         LDKu8slice ser_ref;
31458         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31459         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31460         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
31461         *ret_conv = ChannelDetails_read(ser_ref);
31462         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31463         return (int64_t)ret_conv;
31464 }
31465
31466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
31467         LDKPhantomRouteHints obj_conv;
31468         obj_conv.inner = (void*)(obj & (~1));
31469         obj_conv.is_owned = false;
31470         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31471         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
31472         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31473         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31474         CVec_u8Z_free(ret_var);
31475         return ret_arr;
31476 }
31477
31478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31479         LDKu8slice ser_ref;
31480         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31481         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31482         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
31483         *ret_conv = PhantomRouteHints_read(ser_ref);
31484         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31485         return (int64_t)ret_conv;
31486 }
31487
31488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
31489         LDKChannelManager obj_conv;
31490         obj_conv.inner = (void*)(obj & (~1));
31491         obj_conv.is_owned = false;
31492         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31493         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
31494         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31495         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31496         CVec_u8Z_free(ret_var);
31497         return ret_arr;
31498 }
31499
31500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31501         LDKChannelManagerReadArgs this_obj_conv;
31502         this_obj_conv.inner = (void*)(this_obj & (~1));
31503         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31505         ChannelManagerReadArgs_free(this_obj_conv);
31506 }
31507
31508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
31509         LDKChannelManagerReadArgs this_ptr_conv;
31510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31511         this_ptr_conv.is_owned = false;
31512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31513         // WARNING: This object doesn't live past this scope, needs clone!
31514         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
31515         return ret_ret;
31516 }
31517
31518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31519         LDKChannelManagerReadArgs this_ptr_conv;
31520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31521         this_ptr_conv.is_owned = false;
31522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31523         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31524         CHECK_ACCESS(val_ptr);
31525         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
31526         if (val_conv.free == LDKKeysInterface_JCalls_free) {
31527                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31528                 LDKKeysInterface_JCalls_cloned(&val_conv);
31529         }
31530         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
31531 }
31532
31533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
31534         LDKChannelManagerReadArgs this_ptr_conv;
31535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31536         this_ptr_conv.is_owned = false;
31537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31538         // WARNING: This object doesn't live past this scope, needs clone!
31539         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
31540         return ret_ret;
31541 }
31542
31543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31544         LDKChannelManagerReadArgs this_ptr_conv;
31545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31546         this_ptr_conv.is_owned = false;
31547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31548         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31549         CHECK_ACCESS(val_ptr);
31550         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
31551         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
31552                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31553                 LDKFeeEstimator_JCalls_cloned(&val_conv);
31554         }
31555         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
31556 }
31557
31558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
31559         LDKChannelManagerReadArgs this_ptr_conv;
31560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31561         this_ptr_conv.is_owned = false;
31562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31563         // WARNING: This object doesn't live past this scope, needs clone!
31564         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
31565         return ret_ret;
31566 }
31567
31568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31569         LDKChannelManagerReadArgs this_ptr_conv;
31570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31571         this_ptr_conv.is_owned = false;
31572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31573         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31574         CHECK_ACCESS(val_ptr);
31575         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
31576         if (val_conv.free == LDKWatch_JCalls_free) {
31577                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31578                 LDKWatch_JCalls_cloned(&val_conv);
31579         }
31580         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
31581 }
31582
31583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
31584         LDKChannelManagerReadArgs this_ptr_conv;
31585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31586         this_ptr_conv.is_owned = false;
31587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31588         // WARNING: This object doesn't live past this scope, needs clone!
31589         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
31590         return ret_ret;
31591 }
31592
31593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31594         LDKChannelManagerReadArgs this_ptr_conv;
31595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31596         this_ptr_conv.is_owned = false;
31597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31598         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31599         CHECK_ACCESS(val_ptr);
31600         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
31601         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
31602                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31603                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
31604         }
31605         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
31606 }
31607
31608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
31609         LDKChannelManagerReadArgs this_ptr_conv;
31610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31611         this_ptr_conv.is_owned = false;
31612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31613         // WARNING: This object doesn't live past this scope, needs clone!
31614         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
31615         return ret_ret;
31616 }
31617
31618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31619         LDKChannelManagerReadArgs this_ptr_conv;
31620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31621         this_ptr_conv.is_owned = false;
31622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31623         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31624         CHECK_ACCESS(val_ptr);
31625         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
31626         if (val_conv.free == LDKLogger_JCalls_free) {
31627                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31628                 LDKLogger_JCalls_cloned(&val_conv);
31629         }
31630         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
31631 }
31632
31633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
31634         LDKChannelManagerReadArgs this_ptr_conv;
31635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31636         this_ptr_conv.is_owned = false;
31637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31638         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
31639         int64_t ret_ref = 0;
31640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31643         ret_ref = (uintptr_t)ret_var.inner;
31644         if (ret_var.is_owned) {
31645                 ret_ref |= 1;
31646         }
31647         return ret_ref;
31648 }
31649
31650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31651         LDKChannelManagerReadArgs this_ptr_conv;
31652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31653         this_ptr_conv.is_owned = false;
31654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31655         LDKUserConfig val_conv;
31656         val_conv.inner = (void*)(val & (~1));
31657         val_conv.is_owned = (val & 1) || (val == 0);
31658         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31659         val_conv = UserConfig_clone(&val_conv);
31660         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
31661 }
31662
31663 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) {
31664         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31665         CHECK_ACCESS(keys_manager_ptr);
31666         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
31667         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
31668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31669                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
31670         }
31671         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
31672         CHECK_ACCESS(fee_estimator_ptr);
31673         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
31674         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
31675                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31676                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
31677         }
31678         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
31679         CHECK_ACCESS(chain_monitor_ptr);
31680         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
31681         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
31682                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31683                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
31684         }
31685         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
31686         CHECK_ACCESS(tx_broadcaster_ptr);
31687         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
31688         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
31689                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31690                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
31691         }
31692         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
31693         CHECK_ACCESS(logger_ptr);
31694         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31695         if (logger_conv.free == LDKLogger_JCalls_free) {
31696                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31697                 LDKLogger_JCalls_cloned(&logger_conv);
31698         }
31699         LDKUserConfig default_config_conv;
31700         default_config_conv.inner = (void*)(default_config & (~1));
31701         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
31702         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
31703         default_config_conv = UserConfig_clone(&default_config_conv);
31704         LDKCVec_ChannelMonitorZ channel_monitors_constr;
31705         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
31706         if (channel_monitors_constr.datalen > 0)
31707                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
31708         else
31709                 channel_monitors_constr.data = NULL;
31710         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
31711         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
31712                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
31713                 LDKChannelMonitor channel_monitors_conv_16_conv;
31714                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
31715                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
31716                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
31717                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
31718         }
31719         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
31720         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);
31721         int64_t ret_ref = 0;
31722         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31723         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31725         ret_ref = (uintptr_t)ret_var.inner;
31726         if (ret_var.is_owned) {
31727                 ret_ref |= 1;
31728         }
31729         return ret_ref;
31730 }
31731
31732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31733         LDKu8slice ser_ref;
31734         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31735         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31736         LDKChannelManagerReadArgs arg_conv;
31737         arg_conv.inner = (void*)(arg & (~1));
31738         arg_conv.is_owned = (arg & 1) || (arg == 0);
31739         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31740         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
31741         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
31742         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
31743         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31744         return (int64_t)ret_conv;
31745 }
31746
31747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31748         LDKExpandedKey this_obj_conv;
31749         this_obj_conv.inner = (void*)(this_obj & (~1));
31750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31752         ExpandedKey_free(this_obj_conv);
31753 }
31754
31755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
31756         unsigned char key_material_arr[32];
31757         CHECK((*env)->GetArrayLength(env, key_material) == 32);
31758         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
31759         unsigned char (*key_material_ref)[32] = &key_material_arr;
31760         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
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 int64_t JNICALL Java_org_ldk_impl_bindings_create(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t keys_manager, int64_t current_time) {
31773         LDKExpandedKey keys_conv;
31774         keys_conv.inner = (void*)(keys & (~1));
31775         keys_conv.is_owned = false;
31776         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31777         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31778         CHECK_ACCESS(min_value_msat_ptr);
31779         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31780         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31781         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31782         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
31783         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
31784         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31785         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
31786         return (int64_t)ret_conv;
31787 }
31788
31789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1from_1hash(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time) {
31790         LDKExpandedKey keys_conv;
31791         keys_conv.inner = (void*)(keys & (~1));
31792         keys_conv.is_owned = false;
31793         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31794         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31795         CHECK_ACCESS(min_value_msat_ptr);
31796         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31797         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31798         LDKThirtyTwoBytes payment_hash_ref;
31799         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31800         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31801         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31802         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
31803         return (int64_t)ret_conv;
31804 }
31805
31806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31807         LDKDecodeError this_obj_conv;
31808         this_obj_conv.inner = (void*)(this_obj & (~1));
31809         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31811         DecodeError_free(this_obj_conv);
31812 }
31813
31814 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
31815         LDKDecodeError ret_var = DecodeError_clone(arg);
31816 int64_t ret_ref = 0;
31817 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31818 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31819 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31820 ret_ref = (uintptr_t)ret_var.inner;
31821 if (ret_var.is_owned) {
31822         ret_ref |= 1;
31823 }
31824         return ret_ref;
31825 }
31826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31827         LDKDecodeError arg_conv;
31828         arg_conv.inner = (void*)(arg & (~1));
31829         arg_conv.is_owned = false;
31830         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31831         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
31832         return ret_conv;
31833 }
31834
31835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31836         LDKDecodeError orig_conv;
31837         orig_conv.inner = (void*)(orig & (~1));
31838         orig_conv.is_owned = false;
31839         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31840         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
31841         int64_t ret_ref = 0;
31842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31845         ret_ref = (uintptr_t)ret_var.inner;
31846         if (ret_var.is_owned) {
31847                 ret_ref |= 1;
31848         }
31849         return ret_ref;
31850 }
31851
31852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31853         LDKInit this_obj_conv;
31854         this_obj_conv.inner = (void*)(this_obj & (~1));
31855         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31857         Init_free(this_obj_conv);
31858 }
31859
31860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31861         LDKInit this_ptr_conv;
31862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31863         this_ptr_conv.is_owned = false;
31864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31865         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
31866         int64_t ret_ref = 0;
31867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31870         ret_ref = (uintptr_t)ret_var.inner;
31871         if (ret_var.is_owned) {
31872                 ret_ref |= 1;
31873         }
31874         return ret_ref;
31875 }
31876
31877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31878         LDKInit this_ptr_conv;
31879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31880         this_ptr_conv.is_owned = false;
31881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31882         LDKInitFeatures val_conv;
31883         val_conv.inner = (void*)(val & (~1));
31884         val_conv.is_owned = (val & 1) || (val == 0);
31885         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31886         val_conv = InitFeatures_clone(&val_conv);
31887         Init_set_features(&this_ptr_conv, val_conv);
31888 }
31889
31890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
31891         LDKInit this_ptr_conv;
31892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31893         this_ptr_conv.is_owned = false;
31894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31895         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
31896         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
31897         int64_t ret_ref = (uintptr_t)ret_copy;
31898         return ret_ref;
31899 }
31900
31901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31902         LDKInit this_ptr_conv;
31903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31904         this_ptr_conv.is_owned = false;
31905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31906         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31907         CHECK_ACCESS(val_ptr);
31908         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
31909         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
31910         Init_set_remote_network_address(&this_ptr_conv, val_conv);
31911 }
31912
31913 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) {
31914         LDKInitFeatures features_arg_conv;
31915         features_arg_conv.inner = (void*)(features_arg & (~1));
31916         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
31917         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
31918         features_arg_conv = InitFeatures_clone(&features_arg_conv);
31919         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
31920         CHECK_ACCESS(remote_network_address_arg_ptr);
31921         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
31922         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
31923         int64_t ret_ref = 0;
31924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31927         ret_ref = (uintptr_t)ret_var.inner;
31928         if (ret_var.is_owned) {
31929                 ret_ref |= 1;
31930         }
31931         return ret_ref;
31932 }
31933
31934 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
31935         LDKInit ret_var = Init_clone(arg);
31936 int64_t ret_ref = 0;
31937 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31938 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31939 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31940 ret_ref = (uintptr_t)ret_var.inner;
31941 if (ret_var.is_owned) {
31942         ret_ref |= 1;
31943 }
31944         return ret_ref;
31945 }
31946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31947         LDKInit arg_conv;
31948         arg_conv.inner = (void*)(arg & (~1));
31949         arg_conv.is_owned = false;
31950         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31951         int64_t ret_conv = Init_clone_ptr(&arg_conv);
31952         return ret_conv;
31953 }
31954
31955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31956         LDKInit orig_conv;
31957         orig_conv.inner = (void*)(orig & (~1));
31958         orig_conv.is_owned = false;
31959         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31960         LDKInit ret_var = Init_clone(&orig_conv);
31961         int64_t ret_ref = 0;
31962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31965         ret_ref = (uintptr_t)ret_var.inner;
31966         if (ret_var.is_owned) {
31967                 ret_ref |= 1;
31968         }
31969         return ret_ref;
31970 }
31971
31972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31973         LDKErrorMessage this_obj_conv;
31974         this_obj_conv.inner = (void*)(this_obj & (~1));
31975         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31977         ErrorMessage_free(this_obj_conv);
31978 }
31979
31980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31981         LDKErrorMessage this_ptr_conv;
31982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31983         this_ptr_conv.is_owned = false;
31984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31985         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31986         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
31987         return ret_arr;
31988 }
31989
31990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31991         LDKErrorMessage this_ptr_conv;
31992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31993         this_ptr_conv.is_owned = false;
31994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31995         LDKThirtyTwoBytes val_ref;
31996         CHECK((*env)->GetArrayLength(env, val) == 32);
31997         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31998         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
31999 }
32000
32001 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
32002         LDKErrorMessage this_ptr_conv;
32003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32004         this_ptr_conv.is_owned = false;
32005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32006         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
32007         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32008         Str_free(ret_str);
32009         return ret_conv;
32010 }
32011
32012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
32013         LDKErrorMessage this_ptr_conv;
32014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32015         this_ptr_conv.is_owned = false;
32016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32017         LDKStr val_conv = java_to_owned_str(env, val);
32018         ErrorMessage_set_data(&this_ptr_conv, val_conv);
32019 }
32020
32021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32022         LDKThirtyTwoBytes channel_id_arg_ref;
32023         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32024         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32025         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32026         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
32027         int64_t ret_ref = 0;
32028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32031         ret_ref = (uintptr_t)ret_var.inner;
32032         if (ret_var.is_owned) {
32033                 ret_ref |= 1;
32034         }
32035         return ret_ref;
32036 }
32037
32038 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
32039         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
32040 int64_t ret_ref = 0;
32041 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32042 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32043 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32044 ret_ref = (uintptr_t)ret_var.inner;
32045 if (ret_var.is_owned) {
32046         ret_ref |= 1;
32047 }
32048         return ret_ref;
32049 }
32050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32051         LDKErrorMessage arg_conv;
32052         arg_conv.inner = (void*)(arg & (~1));
32053         arg_conv.is_owned = false;
32054         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32055         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
32056         return ret_conv;
32057 }
32058
32059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32060         LDKErrorMessage orig_conv;
32061         orig_conv.inner = (void*)(orig & (~1));
32062         orig_conv.is_owned = false;
32063         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32064         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
32065         int64_t ret_ref = 0;
32066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32069         ret_ref = (uintptr_t)ret_var.inner;
32070         if (ret_var.is_owned) {
32071                 ret_ref |= 1;
32072         }
32073         return ret_ref;
32074 }
32075
32076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32077         LDKWarningMessage this_obj_conv;
32078         this_obj_conv.inner = (void*)(this_obj & (~1));
32079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32081         WarningMessage_free(this_obj_conv);
32082 }
32083
32084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32085         LDKWarningMessage this_ptr_conv;
32086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32087         this_ptr_conv.is_owned = false;
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32089         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32090         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
32091         return ret_arr;
32092 }
32093
32094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32095         LDKWarningMessage this_ptr_conv;
32096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32097         this_ptr_conv.is_owned = false;
32098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32099         LDKThirtyTwoBytes val_ref;
32100         CHECK((*env)->GetArrayLength(env, val) == 32);
32101         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32102         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
32103 }
32104
32105 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
32106         LDKWarningMessage this_ptr_conv;
32107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32108         this_ptr_conv.is_owned = false;
32109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32110         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
32111         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32112         Str_free(ret_str);
32113         return ret_conv;
32114 }
32115
32116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
32117         LDKWarningMessage this_ptr_conv;
32118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32119         this_ptr_conv.is_owned = false;
32120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32121         LDKStr val_conv = java_to_owned_str(env, val);
32122         WarningMessage_set_data(&this_ptr_conv, val_conv);
32123 }
32124
32125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32126         LDKThirtyTwoBytes channel_id_arg_ref;
32127         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32128         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32129         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32130         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
32131         int64_t ret_ref = 0;
32132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32135         ret_ref = (uintptr_t)ret_var.inner;
32136         if (ret_var.is_owned) {
32137                 ret_ref |= 1;
32138         }
32139         return ret_ref;
32140 }
32141
32142 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
32143         LDKWarningMessage ret_var = WarningMessage_clone(arg);
32144 int64_t ret_ref = 0;
32145 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32146 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32147 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32148 ret_ref = (uintptr_t)ret_var.inner;
32149 if (ret_var.is_owned) {
32150         ret_ref |= 1;
32151 }
32152         return ret_ref;
32153 }
32154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32155         LDKWarningMessage arg_conv;
32156         arg_conv.inner = (void*)(arg & (~1));
32157         arg_conv.is_owned = false;
32158         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32159         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
32160         return ret_conv;
32161 }
32162
32163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32164         LDKWarningMessage orig_conv;
32165         orig_conv.inner = (void*)(orig & (~1));
32166         orig_conv.is_owned = false;
32167         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32168         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
32169         int64_t ret_ref = 0;
32170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32173         ret_ref = (uintptr_t)ret_var.inner;
32174         if (ret_var.is_owned) {
32175                 ret_ref |= 1;
32176         }
32177         return ret_ref;
32178 }
32179
32180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32181         LDKPing this_obj_conv;
32182         this_obj_conv.inner = (void*)(this_obj & (~1));
32183         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32185         Ping_free(this_obj_conv);
32186 }
32187
32188 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32189         LDKPing this_ptr_conv;
32190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32191         this_ptr_conv.is_owned = false;
32192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32193         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
32194         return ret_conv;
32195 }
32196
32197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32198         LDKPing this_ptr_conv;
32199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32200         this_ptr_conv.is_owned = false;
32201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32202         Ping_set_ponglen(&this_ptr_conv, val);
32203 }
32204
32205 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32206         LDKPing this_ptr_conv;
32207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32208         this_ptr_conv.is_owned = false;
32209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32210         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
32211         return ret_conv;
32212 }
32213
32214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32215         LDKPing 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         Ping_set_byteslen(&this_ptr_conv, val);
32220 }
32221
32222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
32223         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
32224         int64_t ret_ref = 0;
32225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32228         ret_ref = (uintptr_t)ret_var.inner;
32229         if (ret_var.is_owned) {
32230                 ret_ref |= 1;
32231         }
32232         return ret_ref;
32233 }
32234
32235 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
32236         LDKPing ret_var = Ping_clone(arg);
32237 int64_t ret_ref = 0;
32238 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32239 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32240 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32241 ret_ref = (uintptr_t)ret_var.inner;
32242 if (ret_var.is_owned) {
32243         ret_ref |= 1;
32244 }
32245         return ret_ref;
32246 }
32247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32248         LDKPing arg_conv;
32249         arg_conv.inner = (void*)(arg & (~1));
32250         arg_conv.is_owned = false;
32251         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32252         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
32253         return ret_conv;
32254 }
32255
32256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32257         LDKPing orig_conv;
32258         orig_conv.inner = (void*)(orig & (~1));
32259         orig_conv.is_owned = false;
32260         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32261         LDKPing ret_var = Ping_clone(&orig_conv);
32262         int64_t ret_ref = 0;
32263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32266         ret_ref = (uintptr_t)ret_var.inner;
32267         if (ret_var.is_owned) {
32268                 ret_ref |= 1;
32269         }
32270         return ret_ref;
32271 }
32272
32273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32274         LDKPong this_obj_conv;
32275         this_obj_conv.inner = (void*)(this_obj & (~1));
32276         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32278         Pong_free(this_obj_conv);
32279 }
32280
32281 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32282         LDKPong this_ptr_conv;
32283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32284         this_ptr_conv.is_owned = false;
32285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32286         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
32287         return ret_conv;
32288 }
32289
32290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32291         LDKPong this_ptr_conv;
32292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32293         this_ptr_conv.is_owned = false;
32294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32295         Pong_set_byteslen(&this_ptr_conv, val);
32296 }
32297
32298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
32299         LDKPong ret_var = Pong_new(byteslen_arg);
32300         int64_t ret_ref = 0;
32301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32304         ret_ref = (uintptr_t)ret_var.inner;
32305         if (ret_var.is_owned) {
32306                 ret_ref |= 1;
32307         }
32308         return ret_ref;
32309 }
32310
32311 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
32312         LDKPong ret_var = Pong_clone(arg);
32313 int64_t ret_ref = 0;
32314 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32315 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32316 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32317 ret_ref = (uintptr_t)ret_var.inner;
32318 if (ret_var.is_owned) {
32319         ret_ref |= 1;
32320 }
32321         return ret_ref;
32322 }
32323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32324         LDKPong arg_conv;
32325         arg_conv.inner = (void*)(arg & (~1));
32326         arg_conv.is_owned = false;
32327         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32328         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
32329         return ret_conv;
32330 }
32331
32332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32333         LDKPong orig_conv;
32334         orig_conv.inner = (void*)(orig & (~1));
32335         orig_conv.is_owned = false;
32336         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32337         LDKPong ret_var = Pong_clone(&orig_conv);
32338         int64_t ret_ref = 0;
32339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32342         ret_ref = (uintptr_t)ret_var.inner;
32343         if (ret_var.is_owned) {
32344                 ret_ref |= 1;
32345         }
32346         return ret_ref;
32347 }
32348
32349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32350         LDKOpenChannel this_obj_conv;
32351         this_obj_conv.inner = (void*)(this_obj & (~1));
32352         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32354         OpenChannel_free(this_obj_conv);
32355 }
32356
32357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32358         LDKOpenChannel this_ptr_conv;
32359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32360         this_ptr_conv.is_owned = false;
32361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32362         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32363         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
32364         return ret_arr;
32365 }
32366
32367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32368         LDKOpenChannel this_ptr_conv;
32369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32370         this_ptr_conv.is_owned = false;
32371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32372         LDKThirtyTwoBytes val_ref;
32373         CHECK((*env)->GetArrayLength(env, val) == 32);
32374         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32375         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
32376 }
32377
32378 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32379         LDKOpenChannel this_ptr_conv;
32380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32381         this_ptr_conv.is_owned = false;
32382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32383         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32384         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
32385         return ret_arr;
32386 }
32387
32388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32389         LDKOpenChannel this_ptr_conv;
32390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32391         this_ptr_conv.is_owned = false;
32392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32393         LDKThirtyTwoBytes val_ref;
32394         CHECK((*env)->GetArrayLength(env, val) == 32);
32395         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32396         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32397 }
32398
32399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32400         LDKOpenChannel 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         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
32405         return ret_conv;
32406 }
32407
32408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32409         LDKOpenChannel this_ptr_conv;
32410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32411         this_ptr_conv.is_owned = false;
32412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32413         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
32414 }
32415
32416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32417         LDKOpenChannel this_ptr_conv;
32418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32419         this_ptr_conv.is_owned = false;
32420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32421         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
32422         return ret_conv;
32423 }
32424
32425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32426         LDKOpenChannel this_ptr_conv;
32427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32428         this_ptr_conv.is_owned = false;
32429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32430         OpenChannel_set_push_msat(&this_ptr_conv, val);
32431 }
32432
32433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32434         LDKOpenChannel this_ptr_conv;
32435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32436         this_ptr_conv.is_owned = false;
32437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32438         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
32439         return ret_conv;
32440 }
32441
32442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32443         LDKOpenChannel this_ptr_conv;
32444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32445         this_ptr_conv.is_owned = false;
32446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32447         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32448 }
32449
32450 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) {
32451         LDKOpenChannel this_ptr_conv;
32452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32453         this_ptr_conv.is_owned = false;
32454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32455         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32456         return ret_conv;
32457 }
32458
32459 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) {
32460         LDKOpenChannel this_ptr_conv;
32461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32462         this_ptr_conv.is_owned = false;
32463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32464         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32465 }
32466
32467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32468         LDKOpenChannel this_ptr_conv;
32469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32470         this_ptr_conv.is_owned = false;
32471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32472         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32473         return ret_conv;
32474 }
32475
32476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32477         LDKOpenChannel this_ptr_conv;
32478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32479         this_ptr_conv.is_owned = false;
32480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32481         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32482 }
32483
32484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32485         LDKOpenChannel this_ptr_conv;
32486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32487         this_ptr_conv.is_owned = false;
32488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32489         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
32490         return ret_conv;
32491 }
32492
32493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32494         LDKOpenChannel this_ptr_conv;
32495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32496         this_ptr_conv.is_owned = false;
32497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32498         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32499 }
32500
32501 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
32502         LDKOpenChannel this_ptr_conv;
32503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32504         this_ptr_conv.is_owned = false;
32505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32506         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
32507         return ret_conv;
32508 }
32509
32510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32511         LDKOpenChannel this_ptr_conv;
32512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32513         this_ptr_conv.is_owned = false;
32514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32515         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
32516 }
32517
32518 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32519         LDKOpenChannel this_ptr_conv;
32520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32521         this_ptr_conv.is_owned = false;
32522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32523         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
32524         return ret_conv;
32525 }
32526
32527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32528         LDKOpenChannel this_ptr_conv;
32529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32530         this_ptr_conv.is_owned = false;
32531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32532         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
32533 }
32534
32535 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32536         LDKOpenChannel this_ptr_conv;
32537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32538         this_ptr_conv.is_owned = false;
32539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32540         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
32541         return ret_conv;
32542 }
32543
32544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32545         LDKOpenChannel this_ptr_conv;
32546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32547         this_ptr_conv.is_owned = false;
32548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32549         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32550 }
32551
32552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32553         LDKOpenChannel this_ptr_conv;
32554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32555         this_ptr_conv.is_owned = false;
32556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32557         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32558         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32559         return ret_arr;
32560 }
32561
32562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32563         LDKOpenChannel this_ptr_conv;
32564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32565         this_ptr_conv.is_owned = false;
32566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32567         LDKPublicKey val_ref;
32568         CHECK((*env)->GetArrayLength(env, val) == 33);
32569         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32570         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32571 }
32572
32573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32574         LDKOpenChannel this_ptr_conv;
32575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32576         this_ptr_conv.is_owned = false;
32577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32578         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32579         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32580         return ret_arr;
32581 }
32582
32583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32584         LDKOpenChannel this_ptr_conv;
32585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32586         this_ptr_conv.is_owned = false;
32587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32588         LDKPublicKey val_ref;
32589         CHECK((*env)->GetArrayLength(env, val) == 33);
32590         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32591         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32592 }
32593
32594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32595         LDKOpenChannel this_ptr_conv;
32596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32597         this_ptr_conv.is_owned = false;
32598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32599         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32600         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
32601         return ret_arr;
32602 }
32603
32604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32605         LDKOpenChannel this_ptr_conv;
32606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32607         this_ptr_conv.is_owned = false;
32608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32609         LDKPublicKey val_ref;
32610         CHECK((*env)->GetArrayLength(env, val) == 33);
32611         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32612         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
32613 }
32614
32615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32616         LDKOpenChannel this_ptr_conv;
32617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32618         this_ptr_conv.is_owned = false;
32619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32620         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32621         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32622         return ret_arr;
32623 }
32624
32625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32626         LDKOpenChannel this_ptr_conv;
32627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32628         this_ptr_conv.is_owned = false;
32629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32630         LDKPublicKey val_ref;
32631         CHECK((*env)->GetArrayLength(env, val) == 33);
32632         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32633         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32634 }
32635
32636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32637         LDKOpenChannel this_ptr_conv;
32638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32639         this_ptr_conv.is_owned = false;
32640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32641         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32642         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32643         return ret_arr;
32644 }
32645
32646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32647         LDKOpenChannel this_ptr_conv;
32648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32649         this_ptr_conv.is_owned = false;
32650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32651         LDKPublicKey val_ref;
32652         CHECK((*env)->GetArrayLength(env, val) == 33);
32653         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32654         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
32655 }
32656
32657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32658         LDKOpenChannel this_ptr_conv;
32659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32660         this_ptr_conv.is_owned = false;
32661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32662         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32663         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
32664         return ret_arr;
32665 }
32666
32667 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) {
32668         LDKOpenChannel this_ptr_conv;
32669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32670         this_ptr_conv.is_owned = false;
32671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32672         LDKPublicKey val_ref;
32673         CHECK((*env)->GetArrayLength(env, val) == 33);
32674         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32675         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
32676 }
32677
32678 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
32679         LDKOpenChannel this_ptr_conv;
32680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32681         this_ptr_conv.is_owned = false;
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32683         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
32684         return ret_conv;
32685 }
32686
32687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
32688         LDKOpenChannel this_ptr_conv;
32689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32690         this_ptr_conv.is_owned = false;
32691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32692         OpenChannel_set_channel_flags(&this_ptr_conv, val);
32693 }
32694
32695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32696         LDKOpenChannel this_ptr_conv;
32697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32698         this_ptr_conv.is_owned = false;
32699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32700         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
32701         int64_t ret_ref = 0;
32702         if ((uintptr_t)ret_var.inner > 4096) {
32703                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32704                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32706                 ret_ref = (uintptr_t)ret_var.inner;
32707                 if (ret_var.is_owned) {
32708                         ret_ref |= 1;
32709                 }
32710         }
32711         return ret_ref;
32712 }
32713
32714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32715         LDKOpenChannel this_ptr_conv;
32716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32717         this_ptr_conv.is_owned = false;
32718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32719         LDKChannelTypeFeatures val_conv;
32720         val_conv.inner = (void*)(val & (~1));
32721         val_conv.is_owned = (val & 1) || (val == 0);
32722         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32723         val_conv = ChannelTypeFeatures_clone(&val_conv);
32724         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
32725 }
32726
32727 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
32728         LDKOpenChannel ret_var = OpenChannel_clone(arg);
32729 int64_t ret_ref = 0;
32730 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32731 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32732 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32733 ret_ref = (uintptr_t)ret_var.inner;
32734 if (ret_var.is_owned) {
32735         ret_ref |= 1;
32736 }
32737         return ret_ref;
32738 }
32739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32740         LDKOpenChannel arg_conv;
32741         arg_conv.inner = (void*)(arg & (~1));
32742         arg_conv.is_owned = false;
32743         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32744         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
32745         return ret_conv;
32746 }
32747
32748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32749         LDKOpenChannel orig_conv;
32750         orig_conv.inner = (void*)(orig & (~1));
32751         orig_conv.is_owned = false;
32752         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32753         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
32754         int64_t ret_ref = 0;
32755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32758         ret_ref = (uintptr_t)ret_var.inner;
32759         if (ret_var.is_owned) {
32760                 ret_ref |= 1;
32761         }
32762         return ret_ref;
32763 }
32764
32765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32766         LDKAcceptChannel this_obj_conv;
32767         this_obj_conv.inner = (void*)(this_obj & (~1));
32768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32770         AcceptChannel_free(this_obj_conv);
32771 }
32772
32773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32774         LDKAcceptChannel this_ptr_conv;
32775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32776         this_ptr_conv.is_owned = false;
32777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32778         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
32780         return ret_arr;
32781 }
32782
32783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32784         LDKAcceptChannel this_ptr_conv;
32785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32786         this_ptr_conv.is_owned = false;
32787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32788         LDKThirtyTwoBytes val_ref;
32789         CHECK((*env)->GetArrayLength(env, val) == 32);
32790         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32791         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32792 }
32793
32794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32795         LDKAcceptChannel this_ptr_conv;
32796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32797         this_ptr_conv.is_owned = false;
32798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32799         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
32800         return ret_conv;
32801 }
32802
32803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32804         LDKAcceptChannel this_ptr_conv;
32805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32806         this_ptr_conv.is_owned = false;
32807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32808         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32809 }
32810
32811 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) {
32812         LDKAcceptChannel this_ptr_conv;
32813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32814         this_ptr_conv.is_owned = false;
32815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32816         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32817         return ret_conv;
32818 }
32819
32820 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) {
32821         LDKAcceptChannel this_ptr_conv;
32822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32823         this_ptr_conv.is_owned = false;
32824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32825         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32826 }
32827
32828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32829         LDKAcceptChannel this_ptr_conv;
32830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32831         this_ptr_conv.is_owned = false;
32832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32833         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32834         return ret_conv;
32835 }
32836
32837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32838         LDKAcceptChannel this_ptr_conv;
32839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32840         this_ptr_conv.is_owned = false;
32841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32842         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32843 }
32844
32845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32846         LDKAcceptChannel this_ptr_conv;
32847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32848         this_ptr_conv.is_owned = false;
32849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32850         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
32851         return ret_conv;
32852 }
32853
32854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32855         LDKAcceptChannel this_ptr_conv;
32856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32857         this_ptr_conv.is_owned = false;
32858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32859         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32860 }
32861
32862 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
32863         LDKAcceptChannel this_ptr_conv;
32864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32865         this_ptr_conv.is_owned = false;
32866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32867         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
32868         return ret_conv;
32869 }
32870
32871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32872         LDKAcceptChannel this_ptr_conv;
32873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32874         this_ptr_conv.is_owned = false;
32875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32876         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
32877 }
32878
32879 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32880         LDKAcceptChannel this_ptr_conv;
32881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32882         this_ptr_conv.is_owned = false;
32883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32884         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
32885         return ret_conv;
32886 }
32887
32888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32889         LDKAcceptChannel this_ptr_conv;
32890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32891         this_ptr_conv.is_owned = false;
32892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32893         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
32894 }
32895
32896 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32897         LDKAcceptChannel this_ptr_conv;
32898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32899         this_ptr_conv.is_owned = false;
32900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32901         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
32902         return ret_conv;
32903 }
32904
32905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32906         LDKAcceptChannel this_ptr_conv;
32907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32908         this_ptr_conv.is_owned = false;
32909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32910         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32911 }
32912
32913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32914         LDKAcceptChannel this_ptr_conv;
32915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32916         this_ptr_conv.is_owned = false;
32917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32918         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32919         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32920         return ret_arr;
32921 }
32922
32923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32924         LDKAcceptChannel this_ptr_conv;
32925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32926         this_ptr_conv.is_owned = false;
32927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32928         LDKPublicKey val_ref;
32929         CHECK((*env)->GetArrayLength(env, val) == 33);
32930         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32931         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32932 }
32933
32934 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32935         LDKAcceptChannel this_ptr_conv;
32936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32937         this_ptr_conv.is_owned = false;
32938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32939         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32940         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32941         return ret_arr;
32942 }
32943
32944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32945         LDKAcceptChannel this_ptr_conv;
32946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32947         this_ptr_conv.is_owned = false;
32948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32949         LDKPublicKey val_ref;
32950         CHECK((*env)->GetArrayLength(env, val) == 33);
32951         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32952         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32953 }
32954
32955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32956         LDKAcceptChannel this_ptr_conv;
32957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32958         this_ptr_conv.is_owned = false;
32959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32960         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
32962         return ret_arr;
32963 }
32964
32965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32966         LDKAcceptChannel this_ptr_conv;
32967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32968         this_ptr_conv.is_owned = false;
32969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32970         LDKPublicKey val_ref;
32971         CHECK((*env)->GetArrayLength(env, val) == 33);
32972         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32973         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
32974 }
32975
32976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32977         LDKAcceptChannel this_ptr_conv;
32978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32979         this_ptr_conv.is_owned = false;
32980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32981         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32982         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32983         return ret_arr;
32984 }
32985
32986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32987         LDKAcceptChannel this_ptr_conv;
32988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32989         this_ptr_conv.is_owned = false;
32990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32991         LDKPublicKey val_ref;
32992         CHECK((*env)->GetArrayLength(env, val) == 33);
32993         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32994         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32995 }
32996
32997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32998         LDKAcceptChannel this_ptr_conv;
32999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33000         this_ptr_conv.is_owned = false;
33001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33002         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33003         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
33004         return ret_arr;
33005 }
33006
33007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33008         LDKAcceptChannel 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         LDKPublicKey val_ref;
33013         CHECK((*env)->GetArrayLength(env, val) == 33);
33014         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33015         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
33016 }
33017
33018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33019         LDKAcceptChannel this_ptr_conv;
33020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33021         this_ptr_conv.is_owned = false;
33022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33023         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33024         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
33025         return ret_arr;
33026 }
33027
33028 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) {
33029         LDKAcceptChannel 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         LDKPublicKey val_ref;
33034         CHECK((*env)->GetArrayLength(env, val) == 33);
33035         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33036         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
33037 }
33038
33039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
33040         LDKAcceptChannel this_ptr_conv;
33041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33042         this_ptr_conv.is_owned = false;
33043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33044         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
33045         int64_t ret_ref = 0;
33046         if ((uintptr_t)ret_var.inner > 4096) {
33047                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33048                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33050                 ret_ref = (uintptr_t)ret_var.inner;
33051                 if (ret_var.is_owned) {
33052                         ret_ref |= 1;
33053                 }
33054         }
33055         return ret_ref;
33056 }
33057
33058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33059         LDKAcceptChannel this_ptr_conv;
33060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33061         this_ptr_conv.is_owned = false;
33062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33063         LDKChannelTypeFeatures val_conv;
33064         val_conv.inner = (void*)(val & (~1));
33065         val_conv.is_owned = (val & 1) || (val == 0);
33066         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33067         val_conv = ChannelTypeFeatures_clone(&val_conv);
33068         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
33069 }
33070
33071 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
33072         LDKAcceptChannel ret_var = AcceptChannel_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_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33084         LDKAcceptChannel 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 = AcceptChannel_clone_ptr(&arg_conv);
33089         return ret_conv;
33090 }
33091
33092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33093         LDKAcceptChannel 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         LDKAcceptChannel ret_var = AcceptChannel_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_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33110         LDKFundingCreated this_obj_conv;
33111         this_obj_conv.inner = (void*)(this_obj & (~1));
33112         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33114         FundingCreated_free(this_obj_conv);
33115 }
33116
33117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33118         LDKFundingCreated this_ptr_conv;
33119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33120         this_ptr_conv.is_owned = false;
33121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33122         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33123         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
33124         return ret_arr;
33125 }
33126
33127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33128         LDKFundingCreated this_ptr_conv;
33129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33130         this_ptr_conv.is_owned = false;
33131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33132         LDKThirtyTwoBytes val_ref;
33133         CHECK((*env)->GetArrayLength(env, val) == 32);
33134         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33135         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
33136 }
33137
33138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33139         LDKFundingCreated this_ptr_conv;
33140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33141         this_ptr_conv.is_owned = false;
33142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33143         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33144         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
33145         return ret_arr;
33146 }
33147
33148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33149         LDKFundingCreated this_ptr_conv;
33150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33151         this_ptr_conv.is_owned = false;
33152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33153         LDKThirtyTwoBytes val_ref;
33154         CHECK((*env)->GetArrayLength(env, val) == 32);
33155         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33156         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
33157 }
33158
33159 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
33160         LDKFundingCreated this_ptr_conv;
33161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33162         this_ptr_conv.is_owned = false;
33163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33164         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
33165         return ret_conv;
33166 }
33167
33168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33169         LDKFundingCreated this_ptr_conv;
33170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33171         this_ptr_conv.is_owned = false;
33172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33173         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
33174 }
33175
33176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33177         LDKFundingCreated this_ptr_conv;
33178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33179         this_ptr_conv.is_owned = false;
33180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33181         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
33183         return ret_arr;
33184 }
33185
33186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33187         LDKFundingCreated this_ptr_conv;
33188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33189         this_ptr_conv.is_owned = false;
33190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33191         LDKSignature val_ref;
33192         CHECK((*env)->GetArrayLength(env, val) == 64);
33193         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33194         FundingCreated_set_signature(&this_ptr_conv, val_ref);
33195 }
33196
33197 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) {
33198         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
33199         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
33200         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
33201         LDKThirtyTwoBytes funding_txid_arg_ref;
33202         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
33203         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
33204         LDKSignature signature_arg_ref;
33205         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33206         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33207         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
33208         int64_t ret_ref = 0;
33209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33212         ret_ref = (uintptr_t)ret_var.inner;
33213         if (ret_var.is_owned) {
33214                 ret_ref |= 1;
33215         }
33216         return ret_ref;
33217 }
33218
33219 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
33220         LDKFundingCreated ret_var = FundingCreated_clone(arg);
33221 int64_t ret_ref = 0;
33222 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33223 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33224 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33225 ret_ref = (uintptr_t)ret_var.inner;
33226 if (ret_var.is_owned) {
33227         ret_ref |= 1;
33228 }
33229         return ret_ref;
33230 }
33231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33232         LDKFundingCreated arg_conv;
33233         arg_conv.inner = (void*)(arg & (~1));
33234         arg_conv.is_owned = false;
33235         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33236         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
33237         return ret_conv;
33238 }
33239
33240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33241         LDKFundingCreated orig_conv;
33242         orig_conv.inner = (void*)(orig & (~1));
33243         orig_conv.is_owned = false;
33244         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33245         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
33246         int64_t ret_ref = 0;
33247         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33248         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33250         ret_ref = (uintptr_t)ret_var.inner;
33251         if (ret_var.is_owned) {
33252                 ret_ref |= 1;
33253         }
33254         return ret_ref;
33255 }
33256
33257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33258         LDKFundingSigned this_obj_conv;
33259         this_obj_conv.inner = (void*)(this_obj & (~1));
33260         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33262         FundingSigned_free(this_obj_conv);
33263 }
33264
33265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33266         LDKFundingSigned this_ptr_conv;
33267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33268         this_ptr_conv.is_owned = false;
33269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33270         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33271         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
33272         return ret_arr;
33273 }
33274
33275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33276         LDKFundingSigned this_ptr_conv;
33277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33278         this_ptr_conv.is_owned = false;
33279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33280         LDKThirtyTwoBytes val_ref;
33281         CHECK((*env)->GetArrayLength(env, val) == 32);
33282         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33283         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
33284 }
33285
33286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33287         LDKFundingSigned this_ptr_conv;
33288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33289         this_ptr_conv.is_owned = false;
33290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33291         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33292         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
33293         return ret_arr;
33294 }
33295
33296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33297         LDKFundingSigned this_ptr_conv;
33298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33299         this_ptr_conv.is_owned = false;
33300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33301         LDKSignature val_ref;
33302         CHECK((*env)->GetArrayLength(env, val) == 64);
33303         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33304         FundingSigned_set_signature(&this_ptr_conv, val_ref);
33305 }
33306
33307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
33308         LDKThirtyTwoBytes channel_id_arg_ref;
33309         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33310         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33311         LDKSignature signature_arg_ref;
33312         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33313         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33314         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
33315         int64_t ret_ref = 0;
33316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33319         ret_ref = (uintptr_t)ret_var.inner;
33320         if (ret_var.is_owned) {
33321                 ret_ref |= 1;
33322         }
33323         return ret_ref;
33324 }
33325
33326 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
33327         LDKFundingSigned ret_var = FundingSigned_clone(arg);
33328 int64_t ret_ref = 0;
33329 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33330 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33331 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33332 ret_ref = (uintptr_t)ret_var.inner;
33333 if (ret_var.is_owned) {
33334         ret_ref |= 1;
33335 }
33336         return ret_ref;
33337 }
33338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33339         LDKFundingSigned arg_conv;
33340         arg_conv.inner = (void*)(arg & (~1));
33341         arg_conv.is_owned = false;
33342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33343         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
33344         return ret_conv;
33345 }
33346
33347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33348         LDKFundingSigned orig_conv;
33349         orig_conv.inner = (void*)(orig & (~1));
33350         orig_conv.is_owned = false;
33351         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33352         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
33353         int64_t ret_ref = 0;
33354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33357         ret_ref = (uintptr_t)ret_var.inner;
33358         if (ret_var.is_owned) {
33359                 ret_ref |= 1;
33360         }
33361         return ret_ref;
33362 }
33363
33364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33365         LDKChannelReady this_obj_conv;
33366         this_obj_conv.inner = (void*)(this_obj & (~1));
33367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33369         ChannelReady_free(this_obj_conv);
33370 }
33371
33372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33373         LDKChannelReady this_ptr_conv;
33374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33375         this_ptr_conv.is_owned = false;
33376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33377         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33378         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
33379         return ret_arr;
33380 }
33381
33382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33383         LDKChannelReady this_ptr_conv;
33384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33385         this_ptr_conv.is_owned = false;
33386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33387         LDKThirtyTwoBytes val_ref;
33388         CHECK((*env)->GetArrayLength(env, val) == 32);
33389         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33390         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
33391 }
33392
33393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33394         LDKChannelReady this_ptr_conv;
33395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33396         this_ptr_conv.is_owned = false;
33397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33398         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33399         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
33400         return ret_arr;
33401 }
33402
33403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33404         LDKChannelReady this_ptr_conv;
33405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33406         this_ptr_conv.is_owned = false;
33407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33408         LDKPublicKey val_ref;
33409         CHECK((*env)->GetArrayLength(env, val) == 33);
33410         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33411         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
33412 }
33413
33414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
33415         LDKChannelReady this_ptr_conv;
33416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33417         this_ptr_conv.is_owned = false;
33418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33419         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33420         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
33421         int64_t ret_ref = (uintptr_t)ret_copy;
33422         return ret_ref;
33423 }
33424
33425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33426         LDKChannelReady this_ptr_conv;
33427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33428         this_ptr_conv.is_owned = false;
33429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33430         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33431         CHECK_ACCESS(val_ptr);
33432         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
33433         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
33434         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
33435 }
33436
33437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
33438         LDKThirtyTwoBytes channel_id_arg_ref;
33439         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33440         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33441         LDKPublicKey next_per_commitment_point_arg_ref;
33442         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
33443         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
33444         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
33445         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
33446         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
33447         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
33448         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
33449         int64_t ret_ref = 0;
33450         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33451         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33453         ret_ref = (uintptr_t)ret_var.inner;
33454         if (ret_var.is_owned) {
33455                 ret_ref |= 1;
33456         }
33457         return ret_ref;
33458 }
33459
33460 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
33461         LDKChannelReady ret_var = ChannelReady_clone(arg);
33462 int64_t ret_ref = 0;
33463 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33464 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33465 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33466 ret_ref = (uintptr_t)ret_var.inner;
33467 if (ret_var.is_owned) {
33468         ret_ref |= 1;
33469 }
33470         return ret_ref;
33471 }
33472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33473         LDKChannelReady arg_conv;
33474         arg_conv.inner = (void*)(arg & (~1));
33475         arg_conv.is_owned = false;
33476         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33477         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
33478         return ret_conv;
33479 }
33480
33481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33482         LDKChannelReady orig_conv;
33483         orig_conv.inner = (void*)(orig & (~1));
33484         orig_conv.is_owned = false;
33485         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33486         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
33487         int64_t ret_ref = 0;
33488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33491         ret_ref = (uintptr_t)ret_var.inner;
33492         if (ret_var.is_owned) {
33493                 ret_ref |= 1;
33494         }
33495         return ret_ref;
33496 }
33497
33498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33499         LDKShutdown this_obj_conv;
33500         this_obj_conv.inner = (void*)(this_obj & (~1));
33501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33503         Shutdown_free(this_obj_conv);
33504 }
33505
33506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33507         LDKShutdown this_ptr_conv;
33508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33509         this_ptr_conv.is_owned = false;
33510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33511         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33512         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
33513         return ret_arr;
33514 }
33515
33516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33517         LDKShutdown this_ptr_conv;
33518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33519         this_ptr_conv.is_owned = false;
33520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33521         LDKThirtyTwoBytes val_ref;
33522         CHECK((*env)->GetArrayLength(env, val) == 32);
33523         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33524         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
33525 }
33526
33527 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33528         LDKShutdown this_ptr_conv;
33529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33530         this_ptr_conv.is_owned = false;
33531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33532         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
33533         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33534         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33535         return ret_arr;
33536 }
33537
33538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33539         LDKShutdown this_ptr_conv;
33540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33541         this_ptr_conv.is_owned = false;
33542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33543         LDKCVec_u8Z val_ref;
33544         val_ref.datalen = (*env)->GetArrayLength(env, val);
33545         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
33546         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
33547         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
33548 }
33549
33550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
33551         LDKThirtyTwoBytes channel_id_arg_ref;
33552         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33553         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33554         LDKCVec_u8Z scriptpubkey_arg_ref;
33555         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
33556         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
33557         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
33558         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
33559         int64_t ret_ref = 0;
33560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33563         ret_ref = (uintptr_t)ret_var.inner;
33564         if (ret_var.is_owned) {
33565                 ret_ref |= 1;
33566         }
33567         return ret_ref;
33568 }
33569
33570 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
33571         LDKShutdown ret_var = Shutdown_clone(arg);
33572 int64_t ret_ref = 0;
33573 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33574 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33575 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33576 ret_ref = (uintptr_t)ret_var.inner;
33577 if (ret_var.is_owned) {
33578         ret_ref |= 1;
33579 }
33580         return ret_ref;
33581 }
33582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33583         LDKShutdown arg_conv;
33584         arg_conv.inner = (void*)(arg & (~1));
33585         arg_conv.is_owned = false;
33586         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33587         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
33588         return ret_conv;
33589 }
33590
33591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33592         LDKShutdown orig_conv;
33593         orig_conv.inner = (void*)(orig & (~1));
33594         orig_conv.is_owned = false;
33595         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33596         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
33597         int64_t ret_ref = 0;
33598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33601         ret_ref = (uintptr_t)ret_var.inner;
33602         if (ret_var.is_owned) {
33603                 ret_ref |= 1;
33604         }
33605         return ret_ref;
33606 }
33607
33608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33609         LDKClosingSignedFeeRange this_obj_conv;
33610         this_obj_conv.inner = (void*)(this_obj & (~1));
33611         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33613         ClosingSignedFeeRange_free(this_obj_conv);
33614 }
33615
33616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33617         LDKClosingSignedFeeRange this_ptr_conv;
33618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33619         this_ptr_conv.is_owned = false;
33620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33621         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
33622         return ret_conv;
33623 }
33624
33625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33626         LDKClosingSignedFeeRange this_ptr_conv;
33627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33628         this_ptr_conv.is_owned = false;
33629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33630         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
33631 }
33632
33633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33634         LDKClosingSignedFeeRange this_ptr_conv;
33635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33636         this_ptr_conv.is_owned = false;
33637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33638         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
33639         return ret_conv;
33640 }
33641
33642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33643         LDKClosingSignedFeeRange this_ptr_conv;
33644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33645         this_ptr_conv.is_owned = false;
33646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33647         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
33648 }
33649
33650 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) {
33651         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
33652         int64_t ret_ref = 0;
33653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33656         ret_ref = (uintptr_t)ret_var.inner;
33657         if (ret_var.is_owned) {
33658                 ret_ref |= 1;
33659         }
33660         return ret_ref;
33661 }
33662
33663 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
33664         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
33665 int64_t ret_ref = 0;
33666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33669 ret_ref = (uintptr_t)ret_var.inner;
33670 if (ret_var.is_owned) {
33671         ret_ref |= 1;
33672 }
33673         return ret_ref;
33674 }
33675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33676         LDKClosingSignedFeeRange arg_conv;
33677         arg_conv.inner = (void*)(arg & (~1));
33678         arg_conv.is_owned = false;
33679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33680         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
33681         return ret_conv;
33682 }
33683
33684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33685         LDKClosingSignedFeeRange orig_conv;
33686         orig_conv.inner = (void*)(orig & (~1));
33687         orig_conv.is_owned = false;
33688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33689         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
33690         int64_t ret_ref = 0;
33691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33694         ret_ref = (uintptr_t)ret_var.inner;
33695         if (ret_var.is_owned) {
33696                 ret_ref |= 1;
33697         }
33698         return ret_ref;
33699 }
33700
33701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33702         LDKClosingSigned this_obj_conv;
33703         this_obj_conv.inner = (void*)(this_obj & (~1));
33704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33706         ClosingSigned_free(this_obj_conv);
33707 }
33708
33709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33710         LDKClosingSigned this_ptr_conv;
33711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33712         this_ptr_conv.is_owned = false;
33713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33714         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
33716         return ret_arr;
33717 }
33718
33719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33720         LDKClosingSigned this_ptr_conv;
33721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33722         this_ptr_conv.is_owned = false;
33723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33724         LDKThirtyTwoBytes val_ref;
33725         CHECK((*env)->GetArrayLength(env, val) == 32);
33726         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33727         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
33728 }
33729
33730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33731         LDKClosingSigned this_ptr_conv;
33732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33733         this_ptr_conv.is_owned = false;
33734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33735         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
33736         return ret_conv;
33737 }
33738
33739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33740         LDKClosingSigned this_ptr_conv;
33741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33742         this_ptr_conv.is_owned = false;
33743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33744         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
33745 }
33746
33747 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33748         LDKClosingSigned this_ptr_conv;
33749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33750         this_ptr_conv.is_owned = false;
33751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33752         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33753         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
33754         return ret_arr;
33755 }
33756
33757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33758         LDKClosingSigned this_ptr_conv;
33759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33760         this_ptr_conv.is_owned = false;
33761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33762         LDKSignature val_ref;
33763         CHECK((*env)->GetArrayLength(env, val) == 64);
33764         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33765         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
33766 }
33767
33768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
33769         LDKClosingSigned this_ptr_conv;
33770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33771         this_ptr_conv.is_owned = false;
33772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33773         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
33774         int64_t ret_ref = 0;
33775         if ((uintptr_t)ret_var.inner > 4096) {
33776                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33777                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33779                 ret_ref = (uintptr_t)ret_var.inner;
33780                 if (ret_var.is_owned) {
33781                         ret_ref |= 1;
33782                 }
33783         }
33784         return ret_ref;
33785 }
33786
33787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33788         LDKClosingSigned this_ptr_conv;
33789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33790         this_ptr_conv.is_owned = false;
33791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33792         LDKClosingSignedFeeRange val_conv;
33793         val_conv.inner = (void*)(val & (~1));
33794         val_conv.is_owned = (val & 1) || (val == 0);
33795         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33796         val_conv = ClosingSignedFeeRange_clone(&val_conv);
33797         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
33798 }
33799
33800 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) {
33801         LDKThirtyTwoBytes channel_id_arg_ref;
33802         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33803         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33804         LDKSignature signature_arg_ref;
33805         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33806         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33807         LDKClosingSignedFeeRange fee_range_arg_conv;
33808         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
33809         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
33810         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
33811         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
33812         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
33813         int64_t ret_ref = 0;
33814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33817         ret_ref = (uintptr_t)ret_var.inner;
33818         if (ret_var.is_owned) {
33819                 ret_ref |= 1;
33820         }
33821         return ret_ref;
33822 }
33823
33824 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
33825         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
33826 int64_t ret_ref = 0;
33827 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33828 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33829 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33830 ret_ref = (uintptr_t)ret_var.inner;
33831 if (ret_var.is_owned) {
33832         ret_ref |= 1;
33833 }
33834         return ret_ref;
33835 }
33836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33837         LDKClosingSigned arg_conv;
33838         arg_conv.inner = (void*)(arg & (~1));
33839         arg_conv.is_owned = false;
33840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33841         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
33842         return ret_conv;
33843 }
33844
33845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33846         LDKClosingSigned orig_conv;
33847         orig_conv.inner = (void*)(orig & (~1));
33848         orig_conv.is_owned = false;
33849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33850         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
33851         int64_t ret_ref = 0;
33852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33855         ret_ref = (uintptr_t)ret_var.inner;
33856         if (ret_var.is_owned) {
33857                 ret_ref |= 1;
33858         }
33859         return ret_ref;
33860 }
33861
33862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33863         LDKUpdateAddHTLC this_obj_conv;
33864         this_obj_conv.inner = (void*)(this_obj & (~1));
33865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33867         UpdateAddHTLC_free(this_obj_conv);
33868 }
33869
33870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33871         LDKUpdateAddHTLC this_ptr_conv;
33872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33873         this_ptr_conv.is_owned = false;
33874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33875         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
33877         return ret_arr;
33878 }
33879
33880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33881         LDKUpdateAddHTLC this_ptr_conv;
33882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33883         this_ptr_conv.is_owned = false;
33884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33885         LDKThirtyTwoBytes val_ref;
33886         CHECK((*env)->GetArrayLength(env, val) == 32);
33887         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33888         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
33889 }
33890
33891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33892         LDKUpdateAddHTLC 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         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
33897         return ret_conv;
33898 }
33899
33900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33901         LDKUpdateAddHTLC this_ptr_conv;
33902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33903         this_ptr_conv.is_owned = false;
33904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33905         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
33906 }
33907
33908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33909         LDKUpdateAddHTLC this_ptr_conv;
33910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33911         this_ptr_conv.is_owned = false;
33912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33913         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
33914         return ret_conv;
33915 }
33916
33917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33918         LDKUpdateAddHTLC this_ptr_conv;
33919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33920         this_ptr_conv.is_owned = false;
33921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33922         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
33923 }
33924
33925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33926         LDKUpdateAddHTLC this_ptr_conv;
33927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33928         this_ptr_conv.is_owned = false;
33929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33930         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33931         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
33932         return ret_arr;
33933 }
33934
33935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33936         LDKUpdateAddHTLC this_ptr_conv;
33937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33938         this_ptr_conv.is_owned = false;
33939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33940         LDKThirtyTwoBytes val_ref;
33941         CHECK((*env)->GetArrayLength(env, val) == 32);
33942         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33943         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
33944 }
33945
33946 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
33947         LDKUpdateAddHTLC 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         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
33952         return ret_conv;
33953 }
33954
33955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33956         LDKUpdateAddHTLC 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         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
33961 }
33962
33963 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
33964         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
33965 int64_t ret_ref = 0;
33966 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33967 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33968 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33969 ret_ref = (uintptr_t)ret_var.inner;
33970 if (ret_var.is_owned) {
33971         ret_ref |= 1;
33972 }
33973         return ret_ref;
33974 }
33975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33976         LDKUpdateAddHTLC arg_conv;
33977         arg_conv.inner = (void*)(arg & (~1));
33978         arg_conv.is_owned = false;
33979         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33980         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
33981         return ret_conv;
33982 }
33983
33984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33985         LDKUpdateAddHTLC orig_conv;
33986         orig_conv.inner = (void*)(orig & (~1));
33987         orig_conv.is_owned = false;
33988         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33989         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
33990         int64_t ret_ref = 0;
33991         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33992         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33994         ret_ref = (uintptr_t)ret_var.inner;
33995         if (ret_var.is_owned) {
33996                 ret_ref |= 1;
33997         }
33998         return ret_ref;
33999 }
34000
34001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34002         LDKUpdateFulfillHTLC this_obj_conv;
34003         this_obj_conv.inner = (void*)(this_obj & (~1));
34004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34006         UpdateFulfillHTLC_free(this_obj_conv);
34007 }
34008
34009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34010         LDKUpdateFulfillHTLC this_ptr_conv;
34011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34012         this_ptr_conv.is_owned = false;
34013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34014         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34015         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
34016         return ret_arr;
34017 }
34018
34019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34020         LDKUpdateFulfillHTLC this_ptr_conv;
34021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34022         this_ptr_conv.is_owned = false;
34023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34024         LDKThirtyTwoBytes val_ref;
34025         CHECK((*env)->GetArrayLength(env, val) == 32);
34026         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34027         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
34028 }
34029
34030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34031         LDKUpdateFulfillHTLC this_ptr_conv;
34032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34033         this_ptr_conv.is_owned = false;
34034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34035         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
34036         return ret_conv;
34037 }
34038
34039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34040         LDKUpdateFulfillHTLC this_ptr_conv;
34041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34042         this_ptr_conv.is_owned = false;
34043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34044         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
34045 }
34046
34047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
34048         LDKUpdateFulfillHTLC this_ptr_conv;
34049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34050         this_ptr_conv.is_owned = false;
34051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34052         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34053         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
34054         return ret_arr;
34055 }
34056
34057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34058         LDKUpdateFulfillHTLC this_ptr_conv;
34059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34060         this_ptr_conv.is_owned = false;
34061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34062         LDKThirtyTwoBytes val_ref;
34063         CHECK((*env)->GetArrayLength(env, val) == 32);
34064         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34065         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
34066 }
34067
34068 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) {
34069         LDKThirtyTwoBytes channel_id_arg_ref;
34070         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34071         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34072         LDKThirtyTwoBytes payment_preimage_arg_ref;
34073         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
34074         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
34075         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
34076         int64_t ret_ref = 0;
34077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34080         ret_ref = (uintptr_t)ret_var.inner;
34081         if (ret_var.is_owned) {
34082                 ret_ref |= 1;
34083         }
34084         return ret_ref;
34085 }
34086
34087 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
34088         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
34089 int64_t ret_ref = 0;
34090 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34091 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34092 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34093 ret_ref = (uintptr_t)ret_var.inner;
34094 if (ret_var.is_owned) {
34095         ret_ref |= 1;
34096 }
34097         return ret_ref;
34098 }
34099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34100         LDKUpdateFulfillHTLC arg_conv;
34101         arg_conv.inner = (void*)(arg & (~1));
34102         arg_conv.is_owned = false;
34103         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34104         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
34105         return ret_conv;
34106 }
34107
34108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34109         LDKUpdateFulfillHTLC orig_conv;
34110         orig_conv.inner = (void*)(orig & (~1));
34111         orig_conv.is_owned = false;
34112         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34113         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
34114         int64_t ret_ref = 0;
34115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34118         ret_ref = (uintptr_t)ret_var.inner;
34119         if (ret_var.is_owned) {
34120                 ret_ref |= 1;
34121         }
34122         return ret_ref;
34123 }
34124
34125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34126         LDKUpdateFailHTLC this_obj_conv;
34127         this_obj_conv.inner = (void*)(this_obj & (~1));
34128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34130         UpdateFailHTLC_free(this_obj_conv);
34131 }
34132
34133 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34134         LDKUpdateFailHTLC this_ptr_conv;
34135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34136         this_ptr_conv.is_owned = false;
34137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34138         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34139         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
34140         return ret_arr;
34141 }
34142
34143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34144         LDKUpdateFailHTLC this_ptr_conv;
34145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34146         this_ptr_conv.is_owned = false;
34147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34148         LDKThirtyTwoBytes val_ref;
34149         CHECK((*env)->GetArrayLength(env, val) == 32);
34150         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34151         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
34152 }
34153
34154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34155         LDKUpdateFailHTLC this_ptr_conv;
34156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34157         this_ptr_conv.is_owned = false;
34158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34159         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
34160         return ret_conv;
34161 }
34162
34163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34164         LDKUpdateFailHTLC this_ptr_conv;
34165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34166         this_ptr_conv.is_owned = false;
34167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34168         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
34169 }
34170
34171 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
34172         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
34173 int64_t ret_ref = 0;
34174 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34175 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34176 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34177 ret_ref = (uintptr_t)ret_var.inner;
34178 if (ret_var.is_owned) {
34179         ret_ref |= 1;
34180 }
34181         return ret_ref;
34182 }
34183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34184         LDKUpdateFailHTLC arg_conv;
34185         arg_conv.inner = (void*)(arg & (~1));
34186         arg_conv.is_owned = false;
34187         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34188         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
34189         return ret_conv;
34190 }
34191
34192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34193         LDKUpdateFailHTLC orig_conv;
34194         orig_conv.inner = (void*)(orig & (~1));
34195         orig_conv.is_owned = false;
34196         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34197         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
34198         int64_t ret_ref = 0;
34199         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34200         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34202         ret_ref = (uintptr_t)ret_var.inner;
34203         if (ret_var.is_owned) {
34204                 ret_ref |= 1;
34205         }
34206         return ret_ref;
34207 }
34208
34209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34210         LDKUpdateFailMalformedHTLC this_obj_conv;
34211         this_obj_conv.inner = (void*)(this_obj & (~1));
34212         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34214         UpdateFailMalformedHTLC_free(this_obj_conv);
34215 }
34216
34217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34218         LDKUpdateFailMalformedHTLC this_ptr_conv;
34219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34220         this_ptr_conv.is_owned = false;
34221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34222         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34223         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
34224         return ret_arr;
34225 }
34226
34227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34228         LDKUpdateFailMalformedHTLC this_ptr_conv;
34229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34230         this_ptr_conv.is_owned = false;
34231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34232         LDKThirtyTwoBytes val_ref;
34233         CHECK((*env)->GetArrayLength(env, val) == 32);
34234         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34235         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
34236 }
34237
34238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34239         LDKUpdateFailMalformedHTLC this_ptr_conv;
34240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34241         this_ptr_conv.is_owned = false;
34242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34243         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
34244         return ret_conv;
34245 }
34246
34247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34248         LDKUpdateFailMalformedHTLC this_ptr_conv;
34249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34250         this_ptr_conv.is_owned = false;
34251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34252         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
34253 }
34254
34255 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
34256         LDKUpdateFailMalformedHTLC this_ptr_conv;
34257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34258         this_ptr_conv.is_owned = false;
34259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34260         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
34261         return ret_conv;
34262 }
34263
34264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34265         LDKUpdateFailMalformedHTLC this_ptr_conv;
34266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34267         this_ptr_conv.is_owned = false;
34268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34269         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
34270 }
34271
34272 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
34273         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
34274 int64_t ret_ref = 0;
34275 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34276 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34277 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34278 ret_ref = (uintptr_t)ret_var.inner;
34279 if (ret_var.is_owned) {
34280         ret_ref |= 1;
34281 }
34282         return ret_ref;
34283 }
34284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34285         LDKUpdateFailMalformedHTLC arg_conv;
34286         arg_conv.inner = (void*)(arg & (~1));
34287         arg_conv.is_owned = false;
34288         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34289         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
34290         return ret_conv;
34291 }
34292
34293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34294         LDKUpdateFailMalformedHTLC orig_conv;
34295         orig_conv.inner = (void*)(orig & (~1));
34296         orig_conv.is_owned = false;
34297         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34298         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
34299         int64_t ret_ref = 0;
34300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34303         ret_ref = (uintptr_t)ret_var.inner;
34304         if (ret_var.is_owned) {
34305                 ret_ref |= 1;
34306         }
34307         return ret_ref;
34308 }
34309
34310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34311         LDKCommitmentSigned this_obj_conv;
34312         this_obj_conv.inner = (void*)(this_obj & (~1));
34313         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34315         CommitmentSigned_free(this_obj_conv);
34316 }
34317
34318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34319         LDKCommitmentSigned this_ptr_conv;
34320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34321         this_ptr_conv.is_owned = false;
34322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34323         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34324         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
34325         return ret_arr;
34326 }
34327
34328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34329         LDKCommitmentSigned this_ptr_conv;
34330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34331         this_ptr_conv.is_owned = false;
34332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34333         LDKThirtyTwoBytes val_ref;
34334         CHECK((*env)->GetArrayLength(env, val) == 32);
34335         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34336         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
34337 }
34338
34339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34340         LDKCommitmentSigned this_ptr_conv;
34341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34342         this_ptr_conv.is_owned = false;
34343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34344         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34345         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
34346         return ret_arr;
34347 }
34348
34349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34350         LDKCommitmentSigned this_ptr_conv;
34351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34352         this_ptr_conv.is_owned = false;
34353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34354         LDKSignature val_ref;
34355         CHECK((*env)->GetArrayLength(env, val) == 64);
34356         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34357         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
34358 }
34359
34360 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
34361         LDKCommitmentSigned this_ptr_conv;
34362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34363         this_ptr_conv.is_owned = false;
34364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34365         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
34366         jobjectArray ret_arr = NULL;
34367         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
34368         ;
34369         for (size_t i = 0; i < ret_var.datalen; i++) {
34370                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
34371                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
34372                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
34373         }
34374         
34375         FREE(ret_var.data);
34376         return ret_arr;
34377 }
34378
34379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
34380         LDKCommitmentSigned this_ptr_conv;
34381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34382         this_ptr_conv.is_owned = false;
34383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34384         LDKCVec_SignatureZ val_constr;
34385         val_constr.datalen = (*env)->GetArrayLength(env, val);
34386         if (val_constr.datalen > 0)
34387                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34388         else
34389                 val_constr.data = NULL;
34390         for (size_t i = 0; i < val_constr.datalen; i++) {
34391                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
34392                 LDKSignature val_conv_8_ref;
34393                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
34394                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
34395                 val_constr.data[i] = val_conv_8_ref;
34396         }
34397         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
34398 }
34399
34400 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) {
34401         LDKThirtyTwoBytes channel_id_arg_ref;
34402         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34403         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34404         LDKSignature signature_arg_ref;
34405         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34406         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34407         LDKCVec_SignatureZ htlc_signatures_arg_constr;
34408         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
34409         if (htlc_signatures_arg_constr.datalen > 0)
34410                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34411         else
34412                 htlc_signatures_arg_constr.data = NULL;
34413         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
34414                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
34415                 LDKSignature htlc_signatures_arg_conv_8_ref;
34416                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
34417                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
34418                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
34419         }
34420         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_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 CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
34433         LDKCommitmentSigned ret_var = CommitmentSigned_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_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34445         LDKCommitmentSigned 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 = CommitmentSigned_clone_ptr(&arg_conv);
34450         return ret_conv;
34451 }
34452
34453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34454         LDKCommitmentSigned 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         LDKCommitmentSigned ret_var = CommitmentSigned_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_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34471         LDKRevokeAndACK 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         RevokeAndACK_free(this_obj_conv);
34476 }
34477
34478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34479         LDKRevokeAndACK 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, *RevokeAndACK_get_channel_id(&this_ptr_conv));
34485         return ret_arr;
34486 }
34487
34488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34489         LDKRevokeAndACK 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         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
34497 }
34498
34499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
34500         LDKRevokeAndACK 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34505         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
34506         return ret_arr;
34507 }
34508
34509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34510         LDKRevokeAndACK this_ptr_conv;
34511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34512         this_ptr_conv.is_owned = false;
34513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34514         LDKThirtyTwoBytes val_ref;
34515         CHECK((*env)->GetArrayLength(env, val) == 32);
34516         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34517         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
34518 }
34519
34520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34521         LDKRevokeAndACK this_ptr_conv;
34522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34523         this_ptr_conv.is_owned = false;
34524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34525         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34526         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
34527         return ret_arr;
34528 }
34529
34530 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) {
34531         LDKRevokeAndACK this_ptr_conv;
34532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34533         this_ptr_conv.is_owned = false;
34534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34535         LDKPublicKey val_ref;
34536         CHECK((*env)->GetArrayLength(env, val) == 33);
34537         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34538         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
34539 }
34540
34541 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) {
34542         LDKThirtyTwoBytes channel_id_arg_ref;
34543         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34544         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34545         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
34546         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
34547         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
34548         LDKPublicKey next_per_commitment_point_arg_ref;
34549         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
34550         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
34551         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
34552         int64_t ret_ref = 0;
34553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34556         ret_ref = (uintptr_t)ret_var.inner;
34557         if (ret_var.is_owned) {
34558                 ret_ref |= 1;
34559         }
34560         return ret_ref;
34561 }
34562
34563 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
34564         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
34565 int64_t ret_ref = 0;
34566 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34567 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34568 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34569 ret_ref = (uintptr_t)ret_var.inner;
34570 if (ret_var.is_owned) {
34571         ret_ref |= 1;
34572 }
34573         return ret_ref;
34574 }
34575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34576         LDKRevokeAndACK arg_conv;
34577         arg_conv.inner = (void*)(arg & (~1));
34578         arg_conv.is_owned = false;
34579         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34580         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
34581         return ret_conv;
34582 }
34583
34584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34585         LDKRevokeAndACK orig_conv;
34586         orig_conv.inner = (void*)(orig & (~1));
34587         orig_conv.is_owned = false;
34588         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34589         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
34590         int64_t ret_ref = 0;
34591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34594         ret_ref = (uintptr_t)ret_var.inner;
34595         if (ret_var.is_owned) {
34596                 ret_ref |= 1;
34597         }
34598         return ret_ref;
34599 }
34600
34601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34602         LDKUpdateFee this_obj_conv;
34603         this_obj_conv.inner = (void*)(this_obj & (~1));
34604         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34606         UpdateFee_free(this_obj_conv);
34607 }
34608
34609 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34610         LDKUpdateFee this_ptr_conv;
34611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34612         this_ptr_conv.is_owned = false;
34613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34614         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34615         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
34616         return ret_arr;
34617 }
34618
34619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34620         LDKUpdateFee this_ptr_conv;
34621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34622         this_ptr_conv.is_owned = false;
34623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34624         LDKThirtyTwoBytes val_ref;
34625         CHECK((*env)->GetArrayLength(env, val) == 32);
34626         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34627         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
34628 }
34629
34630 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
34631         LDKUpdateFee this_ptr_conv;
34632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34633         this_ptr_conv.is_owned = false;
34634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34635         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
34636         return ret_conv;
34637 }
34638
34639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34640         LDKUpdateFee this_ptr_conv;
34641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34642         this_ptr_conv.is_owned = false;
34643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34644         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
34645 }
34646
34647 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) {
34648         LDKThirtyTwoBytes channel_id_arg_ref;
34649         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34650         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34651         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
34652         int64_t ret_ref = 0;
34653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34656         ret_ref = (uintptr_t)ret_var.inner;
34657         if (ret_var.is_owned) {
34658                 ret_ref |= 1;
34659         }
34660         return ret_ref;
34661 }
34662
34663 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
34664         LDKUpdateFee ret_var = UpdateFee_clone(arg);
34665 int64_t ret_ref = 0;
34666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34669 ret_ref = (uintptr_t)ret_var.inner;
34670 if (ret_var.is_owned) {
34671         ret_ref |= 1;
34672 }
34673         return ret_ref;
34674 }
34675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34676         LDKUpdateFee arg_conv;
34677         arg_conv.inner = (void*)(arg & (~1));
34678         arg_conv.is_owned = false;
34679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34680         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
34681         return ret_conv;
34682 }
34683
34684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34685         LDKUpdateFee orig_conv;
34686         orig_conv.inner = (void*)(orig & (~1));
34687         orig_conv.is_owned = false;
34688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34689         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
34690         int64_t ret_ref = 0;
34691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34694         ret_ref = (uintptr_t)ret_var.inner;
34695         if (ret_var.is_owned) {
34696                 ret_ref |= 1;
34697         }
34698         return ret_ref;
34699 }
34700
34701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34702         LDKDataLossProtect this_obj_conv;
34703         this_obj_conv.inner = (void*)(this_obj & (~1));
34704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34706         DataLossProtect_free(this_obj_conv);
34707 }
34708
34709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
34710         LDKDataLossProtect this_ptr_conv;
34711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34712         this_ptr_conv.is_owned = false;
34713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34714         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
34716         return ret_arr;
34717 }
34718
34719 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) {
34720         LDKDataLossProtect this_ptr_conv;
34721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34722         this_ptr_conv.is_owned = false;
34723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34724         LDKThirtyTwoBytes val_ref;
34725         CHECK((*env)->GetArrayLength(env, val) == 32);
34726         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34727         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
34728 }
34729
34730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34731         LDKDataLossProtect this_ptr_conv;
34732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34733         this_ptr_conv.is_owned = false;
34734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34735         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
34737         return ret_arr;
34738 }
34739
34740 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) {
34741         LDKDataLossProtect 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         LDKPublicKey val_ref;
34746         CHECK((*env)->GetArrayLength(env, val) == 33);
34747         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34748         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
34749 }
34750
34751 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) {
34752         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
34753         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
34754         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
34755         LDKPublicKey my_current_per_commitment_point_arg_ref;
34756         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
34757         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
34758         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
34759         int64_t ret_ref = 0;
34760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34763         ret_ref = (uintptr_t)ret_var.inner;
34764         if (ret_var.is_owned) {
34765                 ret_ref |= 1;
34766         }
34767         return ret_ref;
34768 }
34769
34770 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
34771         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
34772 int64_t ret_ref = 0;
34773 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34774 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34775 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34776 ret_ref = (uintptr_t)ret_var.inner;
34777 if (ret_var.is_owned) {
34778         ret_ref |= 1;
34779 }
34780         return ret_ref;
34781 }
34782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34783         LDKDataLossProtect arg_conv;
34784         arg_conv.inner = (void*)(arg & (~1));
34785         arg_conv.is_owned = false;
34786         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34787         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
34788         return ret_conv;
34789 }
34790
34791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34792         LDKDataLossProtect orig_conv;
34793         orig_conv.inner = (void*)(orig & (~1));
34794         orig_conv.is_owned = false;
34795         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34796         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
34797         int64_t ret_ref = 0;
34798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34801         ret_ref = (uintptr_t)ret_var.inner;
34802         if (ret_var.is_owned) {
34803                 ret_ref |= 1;
34804         }
34805         return ret_ref;
34806 }
34807
34808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34809         LDKChannelReestablish this_obj_conv;
34810         this_obj_conv.inner = (void*)(this_obj & (~1));
34811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34813         ChannelReestablish_free(this_obj_conv);
34814 }
34815
34816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34817         LDKChannelReestablish this_ptr_conv;
34818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34819         this_ptr_conv.is_owned = false;
34820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34821         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34822         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
34823         return ret_arr;
34824 }
34825
34826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34827         LDKChannelReestablish this_ptr_conv;
34828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34829         this_ptr_conv.is_owned = false;
34830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34831         LDKThirtyTwoBytes val_ref;
34832         CHECK((*env)->GetArrayLength(env, val) == 32);
34833         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34834         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
34835 }
34836
34837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34838         LDKChannelReestablish this_ptr_conv;
34839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34840         this_ptr_conv.is_owned = false;
34841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34842         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
34843         return ret_conv;
34844 }
34845
34846 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) {
34847         LDKChannelReestablish this_ptr_conv;
34848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34849         this_ptr_conv.is_owned = false;
34850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34851         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
34852 }
34853
34854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34855         LDKChannelReestablish this_ptr_conv;
34856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34857         this_ptr_conv.is_owned = false;
34858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34859         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
34860         return ret_conv;
34861 }
34862
34863 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) {
34864         LDKChannelReestablish this_ptr_conv;
34865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34866         this_ptr_conv.is_owned = false;
34867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34868         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
34869 }
34870
34871 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
34872         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
34873 int64_t ret_ref = 0;
34874 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34875 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34876 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34877 ret_ref = (uintptr_t)ret_var.inner;
34878 if (ret_var.is_owned) {
34879         ret_ref |= 1;
34880 }
34881         return ret_ref;
34882 }
34883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34884         LDKChannelReestablish arg_conv;
34885         arg_conv.inner = (void*)(arg & (~1));
34886         arg_conv.is_owned = false;
34887         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34888         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
34889         return ret_conv;
34890 }
34891
34892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34893         LDKChannelReestablish orig_conv;
34894         orig_conv.inner = (void*)(orig & (~1));
34895         orig_conv.is_owned = false;
34896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34897         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
34898         int64_t ret_ref = 0;
34899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34902         ret_ref = (uintptr_t)ret_var.inner;
34903         if (ret_var.is_owned) {
34904                 ret_ref |= 1;
34905         }
34906         return ret_ref;
34907 }
34908
34909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34910         LDKAnnouncementSignatures this_obj_conv;
34911         this_obj_conv.inner = (void*)(this_obj & (~1));
34912         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34914         AnnouncementSignatures_free(this_obj_conv);
34915 }
34916
34917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34918         LDKAnnouncementSignatures this_ptr_conv;
34919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34920         this_ptr_conv.is_owned = false;
34921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34922         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
34924         return ret_arr;
34925 }
34926
34927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34928         LDKAnnouncementSignatures this_ptr_conv;
34929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34930         this_ptr_conv.is_owned = false;
34931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34932         LDKThirtyTwoBytes val_ref;
34933         CHECK((*env)->GetArrayLength(env, val) == 32);
34934         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34935         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
34936 }
34937
34938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34939         LDKAnnouncementSignatures this_ptr_conv;
34940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34941         this_ptr_conv.is_owned = false;
34942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34943         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
34944         return ret_conv;
34945 }
34946
34947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34948         LDKAnnouncementSignatures this_ptr_conv;
34949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34950         this_ptr_conv.is_owned = false;
34951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34952         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
34953 }
34954
34955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34956         LDKAnnouncementSignatures this_ptr_conv;
34957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34958         this_ptr_conv.is_owned = false;
34959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34960         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
34962         return ret_arr;
34963 }
34964
34965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34966         LDKAnnouncementSignatures this_ptr_conv;
34967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34968         this_ptr_conv.is_owned = false;
34969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34970         LDKSignature val_ref;
34971         CHECK((*env)->GetArrayLength(env, val) == 64);
34972         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34973         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
34974 }
34975
34976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34977         LDKAnnouncementSignatures this_ptr_conv;
34978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34979         this_ptr_conv.is_owned = false;
34980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34981         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34982         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
34983         return ret_arr;
34984 }
34985
34986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34987         LDKAnnouncementSignatures this_ptr_conv;
34988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34989         this_ptr_conv.is_owned = false;
34990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34991         LDKSignature val_ref;
34992         CHECK((*env)->GetArrayLength(env, val) == 64);
34993         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34994         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
34995 }
34996
34997 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) {
34998         LDKThirtyTwoBytes channel_id_arg_ref;
34999         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35000         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35001         LDKSignature node_signature_arg_ref;
35002         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
35003         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
35004         LDKSignature bitcoin_signature_arg_ref;
35005         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
35006         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
35007         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
35008         int64_t ret_ref = 0;
35009         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35010         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35012         ret_ref = (uintptr_t)ret_var.inner;
35013         if (ret_var.is_owned) {
35014                 ret_ref |= 1;
35015         }
35016         return ret_ref;
35017 }
35018
35019 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
35020         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
35021 int64_t ret_ref = 0;
35022 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35023 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35024 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35025 ret_ref = (uintptr_t)ret_var.inner;
35026 if (ret_var.is_owned) {
35027         ret_ref |= 1;
35028 }
35029         return ret_ref;
35030 }
35031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35032         LDKAnnouncementSignatures arg_conv;
35033         arg_conv.inner = (void*)(arg & (~1));
35034         arg_conv.is_owned = false;
35035         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35036         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
35037         return ret_conv;
35038 }
35039
35040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35041         LDKAnnouncementSignatures orig_conv;
35042         orig_conv.inner = (void*)(orig & (~1));
35043         orig_conv.is_owned = false;
35044         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35045         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
35046         int64_t ret_ref = 0;
35047         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35048         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35050         ret_ref = (uintptr_t)ret_var.inner;
35051         if (ret_var.is_owned) {
35052                 ret_ref |= 1;
35053         }
35054         return ret_ref;
35055 }
35056
35057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35058         if ((this_ptr & 1) != 0) return;
35059         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35060         CHECK_ACCESS(this_ptr_ptr);
35061         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
35062         FREE((void*)this_ptr);
35063         NetAddress_free(this_ptr_conv);
35064 }
35065
35066 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
35067         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35068         *ret_copy = NetAddress_clone(arg);
35069 int64_t ret_ref = (uintptr_t)ret_copy;
35070         return ret_ref;
35071 }
35072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35073         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
35074         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
35075         return ret_conv;
35076 }
35077
35078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35079         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
35080         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35081         *ret_copy = NetAddress_clone(orig_conv);
35082         int64_t ret_ref = (uintptr_t)ret_copy;
35083         return ret_ref;
35084 }
35085
35086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35087         LDKFourBytes addr_ref;
35088         CHECK((*env)->GetArrayLength(env, addr) == 4);
35089         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
35090         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35091         *ret_copy = NetAddress_ipv4(addr_ref, port);
35092         int64_t ret_ref = (uintptr_t)ret_copy;
35093         return ret_ref;
35094 }
35095
35096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35097         LDKSixteenBytes addr_ref;
35098         CHECK((*env)->GetArrayLength(env, addr) == 16);
35099         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
35100         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35101         *ret_copy = NetAddress_ipv6(addr_ref, port);
35102         int64_t ret_ref = (uintptr_t)ret_copy;
35103         return ret_ref;
35104 }
35105
35106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
35107         LDKTwelveBytes a_ref;
35108         CHECK((*env)->GetArrayLength(env, a) == 12);
35109         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
35110         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35111         *ret_copy = NetAddress_onion_v2(a_ref);
35112         int64_t ret_ref = (uintptr_t)ret_copy;
35113         return ret_ref;
35114 }
35115
35116 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) {
35117         LDKThirtyTwoBytes ed25519_pubkey_ref;
35118         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
35119         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
35120         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35121         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
35122         int64_t ret_ref = (uintptr_t)ret_copy;
35123         return ret_ref;
35124 }
35125
35126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
35127         LDKHostname hostname_conv;
35128         hostname_conv.inner = (void*)(hostname & (~1));
35129         hostname_conv.is_owned = (hostname & 1) || (hostname == 0);
35130         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
35131         hostname_conv = Hostname_clone(&hostname_conv);
35132         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35133         *ret_copy = NetAddress_hostname(hostname_conv, port);
35134         int64_t ret_ref = (uintptr_t)ret_copy;
35135         return ret_ref;
35136 }
35137
35138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
35139         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
35140         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
35141         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35142         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35143         CVec_u8Z_free(ret_var);
35144         return ret_arr;
35145 }
35146
35147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35148         LDKu8slice ser_ref;
35149         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35150         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35151         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
35152         *ret_conv = NetAddress_read(ser_ref);
35153         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35154         return (int64_t)ret_conv;
35155 }
35156
35157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35158         LDKUnsignedNodeAnnouncement this_obj_conv;
35159         this_obj_conv.inner = (void*)(this_obj & (~1));
35160         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35162         UnsignedNodeAnnouncement_free(this_obj_conv);
35163 }
35164
35165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35166         LDKUnsignedNodeAnnouncement this_ptr_conv;
35167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35168         this_ptr_conv.is_owned = false;
35169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35170         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
35171         int64_t ret_ref = 0;
35172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35175         ret_ref = (uintptr_t)ret_var.inner;
35176         if (ret_var.is_owned) {
35177                 ret_ref |= 1;
35178         }
35179         return ret_ref;
35180 }
35181
35182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35183         LDKUnsignedNodeAnnouncement this_ptr_conv;
35184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35185         this_ptr_conv.is_owned = false;
35186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35187         LDKNodeFeatures val_conv;
35188         val_conv.inner = (void*)(val & (~1));
35189         val_conv.is_owned = (val & 1) || (val == 0);
35190         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35191         val_conv = NodeFeatures_clone(&val_conv);
35192         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
35193 }
35194
35195 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35196         LDKUnsignedNodeAnnouncement this_ptr_conv;
35197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35198         this_ptr_conv.is_owned = false;
35199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35200         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
35201         return ret_conv;
35202 }
35203
35204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35205         LDKUnsignedNodeAnnouncement this_ptr_conv;
35206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35207         this_ptr_conv.is_owned = false;
35208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35209         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
35210 }
35211
35212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35213         LDKUnsignedNodeAnnouncement this_ptr_conv;
35214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35215         this_ptr_conv.is_owned = false;
35216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35217         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
35219         return ret_arr;
35220 }
35221
35222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35223         LDKUnsignedNodeAnnouncement this_ptr_conv;
35224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35225         this_ptr_conv.is_owned = false;
35226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35227         LDKPublicKey val_ref;
35228         CHECK((*env)->GetArrayLength(env, val) == 33);
35229         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35230         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
35231 }
35232
35233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
35234         LDKUnsignedNodeAnnouncement this_ptr_conv;
35235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35236         this_ptr_conv.is_owned = false;
35237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35238         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
35239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
35240         return ret_arr;
35241 }
35242
35243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35244         LDKUnsignedNodeAnnouncement this_ptr_conv;
35245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35246         this_ptr_conv.is_owned = false;
35247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35248         LDKThreeBytes val_ref;
35249         CHECK((*env)->GetArrayLength(env, val) == 3);
35250         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
35251         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
35252 }
35253
35254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
35255         LDKUnsignedNodeAnnouncement this_ptr_conv;
35256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35257         this_ptr_conv.is_owned = false;
35258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35259         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
35261         return ret_arr;
35262 }
35263
35264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35265         LDKUnsignedNodeAnnouncement this_ptr_conv;
35266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35267         this_ptr_conv.is_owned = false;
35268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35269         LDKThirtyTwoBytes val_ref;
35270         CHECK((*env)->GetArrayLength(env, val) == 32);
35271         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35272         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
35273 }
35274
35275 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
35276         LDKUnsignedNodeAnnouncement this_ptr_conv;
35277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35278         this_ptr_conv.is_owned = false;
35279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35280         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
35281         int64_tArray ret_arr = NULL;
35282         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35283         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35284         for (size_t m = 0; m < ret_var.datalen; m++) {
35285                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35286                 *ret_conv_12_copy = ret_var.data[m];
35287                 int64_t ret_conv_12_ref = (uintptr_t)ret_conv_12_copy;
35288                 ret_arr_ptr[m] = ret_conv_12_ref;
35289         }
35290         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35291         FREE(ret_var.data);
35292         return ret_arr;
35293 }
35294
35295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35296         LDKUnsignedNodeAnnouncement this_ptr_conv;
35297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35298         this_ptr_conv.is_owned = false;
35299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35300         LDKCVec_NetAddressZ val_constr;
35301         val_constr.datalen = (*env)->GetArrayLength(env, val);
35302         if (val_constr.datalen > 0)
35303                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35304         else
35305                 val_constr.data = NULL;
35306         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35307         for (size_t m = 0; m < val_constr.datalen; m++) {
35308                 int64_t val_conv_12 = val_vals[m];
35309                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
35310                 CHECK_ACCESS(val_conv_12_ptr);
35311                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
35312                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
35313                 val_constr.data[m] = val_conv_12_conv;
35314         }
35315         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35316         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
35317 }
35318
35319 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
35320         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
35321 int64_t ret_ref = 0;
35322 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35323 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35324 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35325 ret_ref = (uintptr_t)ret_var.inner;
35326 if (ret_var.is_owned) {
35327         ret_ref |= 1;
35328 }
35329         return ret_ref;
35330 }
35331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35332         LDKUnsignedNodeAnnouncement arg_conv;
35333         arg_conv.inner = (void*)(arg & (~1));
35334         arg_conv.is_owned = false;
35335         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35336         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
35337         return ret_conv;
35338 }
35339
35340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35341         LDKUnsignedNodeAnnouncement orig_conv;
35342         orig_conv.inner = (void*)(orig & (~1));
35343         orig_conv.is_owned = false;
35344         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35345         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
35346         int64_t ret_ref = 0;
35347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35350         ret_ref = (uintptr_t)ret_var.inner;
35351         if (ret_var.is_owned) {
35352                 ret_ref |= 1;
35353         }
35354         return ret_ref;
35355 }
35356
35357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35358         LDKNodeAnnouncement this_obj_conv;
35359         this_obj_conv.inner = (void*)(this_obj & (~1));
35360         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35362         NodeAnnouncement_free(this_obj_conv);
35363 }
35364
35365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35366         LDKNodeAnnouncement this_ptr_conv;
35367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35368         this_ptr_conv.is_owned = false;
35369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35370         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35371         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
35372         return ret_arr;
35373 }
35374
35375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35376         LDKNodeAnnouncement this_ptr_conv;
35377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35378         this_ptr_conv.is_owned = false;
35379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35380         LDKSignature val_ref;
35381         CHECK((*env)->GetArrayLength(env, val) == 64);
35382         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35383         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
35384 }
35385
35386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35387         LDKNodeAnnouncement this_ptr_conv;
35388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35389         this_ptr_conv.is_owned = false;
35390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35391         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
35392         int64_t ret_ref = 0;
35393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35396         ret_ref = (uintptr_t)ret_var.inner;
35397         if (ret_var.is_owned) {
35398                 ret_ref |= 1;
35399         }
35400         return ret_ref;
35401 }
35402
35403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35404         LDKNodeAnnouncement this_ptr_conv;
35405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35406         this_ptr_conv.is_owned = false;
35407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35408         LDKUnsignedNodeAnnouncement val_conv;
35409         val_conv.inner = (void*)(val & (~1));
35410         val_conv.is_owned = (val & 1) || (val == 0);
35411         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35412         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
35413         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
35414 }
35415
35416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
35417         LDKSignature signature_arg_ref;
35418         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35419         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35420         LDKUnsignedNodeAnnouncement contents_arg_conv;
35421         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35422         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35423         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35424         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
35425         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
35426         int64_t ret_ref = 0;
35427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35430         ret_ref = (uintptr_t)ret_var.inner;
35431         if (ret_var.is_owned) {
35432                 ret_ref |= 1;
35433         }
35434         return ret_ref;
35435 }
35436
35437 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
35438         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
35439 int64_t ret_ref = 0;
35440 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35441 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35442 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35443 ret_ref = (uintptr_t)ret_var.inner;
35444 if (ret_var.is_owned) {
35445         ret_ref |= 1;
35446 }
35447         return ret_ref;
35448 }
35449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35450         LDKNodeAnnouncement arg_conv;
35451         arg_conv.inner = (void*)(arg & (~1));
35452         arg_conv.is_owned = false;
35453         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35454         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
35455         return ret_conv;
35456 }
35457
35458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35459         LDKNodeAnnouncement orig_conv;
35460         orig_conv.inner = (void*)(orig & (~1));
35461         orig_conv.is_owned = false;
35462         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35463         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
35464         int64_t ret_ref = 0;
35465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35468         ret_ref = (uintptr_t)ret_var.inner;
35469         if (ret_var.is_owned) {
35470                 ret_ref |= 1;
35471         }
35472         return ret_ref;
35473 }
35474
35475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35476         LDKUnsignedChannelAnnouncement this_obj_conv;
35477         this_obj_conv.inner = (void*)(this_obj & (~1));
35478         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35480         UnsignedChannelAnnouncement_free(this_obj_conv);
35481 }
35482
35483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35484         LDKUnsignedChannelAnnouncement this_ptr_conv;
35485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35486         this_ptr_conv.is_owned = false;
35487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35488         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
35489         int64_t ret_ref = 0;
35490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35493         ret_ref = (uintptr_t)ret_var.inner;
35494         if (ret_var.is_owned) {
35495                 ret_ref |= 1;
35496         }
35497         return ret_ref;
35498 }
35499
35500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35501         LDKUnsignedChannelAnnouncement this_ptr_conv;
35502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35503         this_ptr_conv.is_owned = false;
35504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35505         LDKChannelFeatures val_conv;
35506         val_conv.inner = (void*)(val & (~1));
35507         val_conv.is_owned = (val & 1) || (val == 0);
35508         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35509         val_conv = ChannelFeatures_clone(&val_conv);
35510         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
35511 }
35512
35513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35514         LDKUnsignedChannelAnnouncement this_ptr_conv;
35515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35516         this_ptr_conv.is_owned = false;
35517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35518         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35519         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
35520         return ret_arr;
35521 }
35522
35523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35524         LDKUnsignedChannelAnnouncement this_ptr_conv;
35525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35526         this_ptr_conv.is_owned = false;
35527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35528         LDKThirtyTwoBytes val_ref;
35529         CHECK((*env)->GetArrayLength(env, val) == 32);
35530         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35531         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
35532 }
35533
35534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35535         LDKUnsignedChannelAnnouncement this_ptr_conv;
35536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35537         this_ptr_conv.is_owned = false;
35538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35539         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
35540         return ret_conv;
35541 }
35542
35543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35544         LDKUnsignedChannelAnnouncement this_ptr_conv;
35545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35546         this_ptr_conv.is_owned = false;
35547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35548         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
35549 }
35550
35551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35552         LDKUnsignedChannelAnnouncement this_ptr_conv;
35553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35554         this_ptr_conv.is_owned = false;
35555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35556         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35557         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
35558         return ret_arr;
35559 }
35560
35561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35562         LDKUnsignedChannelAnnouncement this_ptr_conv;
35563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35564         this_ptr_conv.is_owned = false;
35565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35566         LDKPublicKey val_ref;
35567         CHECK((*env)->GetArrayLength(env, val) == 33);
35568         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35569         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
35570 }
35571
35572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35573         LDKUnsignedChannelAnnouncement this_ptr_conv;
35574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35575         this_ptr_conv.is_owned = false;
35576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35577         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35578         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
35579         return ret_arr;
35580 }
35581
35582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35583         LDKUnsignedChannelAnnouncement this_ptr_conv;
35584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35585         this_ptr_conv.is_owned = false;
35586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35587         LDKPublicKey val_ref;
35588         CHECK((*env)->GetArrayLength(env, val) == 33);
35589         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35590         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
35591 }
35592
35593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35594         LDKUnsignedChannelAnnouncement this_ptr_conv;
35595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35596         this_ptr_conv.is_owned = false;
35597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35598         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35599         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
35600         return ret_arr;
35601 }
35602
35603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35604         LDKUnsignedChannelAnnouncement this_ptr_conv;
35605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35606         this_ptr_conv.is_owned = false;
35607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35608         LDKPublicKey val_ref;
35609         CHECK((*env)->GetArrayLength(env, val) == 33);
35610         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35611         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
35612 }
35613
35614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35615         LDKUnsignedChannelAnnouncement this_ptr_conv;
35616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35617         this_ptr_conv.is_owned = false;
35618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35619         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35620         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
35621         return ret_arr;
35622 }
35623
35624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35625         LDKUnsignedChannelAnnouncement this_ptr_conv;
35626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35627         this_ptr_conv.is_owned = false;
35628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35629         LDKPublicKey val_ref;
35630         CHECK((*env)->GetArrayLength(env, val) == 33);
35631         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35632         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
35633 }
35634
35635 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
35636         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
35637 int64_t ret_ref = 0;
35638 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35639 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35640 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35641 ret_ref = (uintptr_t)ret_var.inner;
35642 if (ret_var.is_owned) {
35643         ret_ref |= 1;
35644 }
35645         return ret_ref;
35646 }
35647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35648         LDKUnsignedChannelAnnouncement arg_conv;
35649         arg_conv.inner = (void*)(arg & (~1));
35650         arg_conv.is_owned = false;
35651         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35652         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
35653         return ret_conv;
35654 }
35655
35656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35657         LDKUnsignedChannelAnnouncement orig_conv;
35658         orig_conv.inner = (void*)(orig & (~1));
35659         orig_conv.is_owned = false;
35660         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35661         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
35662         int64_t ret_ref = 0;
35663         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35664         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35666         ret_ref = (uintptr_t)ret_var.inner;
35667         if (ret_var.is_owned) {
35668                 ret_ref |= 1;
35669         }
35670         return ret_ref;
35671 }
35672
35673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35674         LDKChannelAnnouncement this_obj_conv;
35675         this_obj_conv.inner = (void*)(this_obj & (~1));
35676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35678         ChannelAnnouncement_free(this_obj_conv);
35679 }
35680
35681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35682         LDKChannelAnnouncement this_ptr_conv;
35683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35684         this_ptr_conv.is_owned = false;
35685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35686         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
35688         return ret_arr;
35689 }
35690
35691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35692         LDKChannelAnnouncement this_ptr_conv;
35693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35694         this_ptr_conv.is_owned = false;
35695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35696         LDKSignature val_ref;
35697         CHECK((*env)->GetArrayLength(env, val) == 64);
35698         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35699         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
35700 }
35701
35702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35703         LDKChannelAnnouncement this_ptr_conv;
35704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35705         this_ptr_conv.is_owned = false;
35706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35707         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
35709         return ret_arr;
35710 }
35711
35712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35713         LDKChannelAnnouncement this_ptr_conv;
35714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35715         this_ptr_conv.is_owned = false;
35716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35717         LDKSignature val_ref;
35718         CHECK((*env)->GetArrayLength(env, val) == 64);
35719         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35720         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
35721 }
35722
35723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35724         LDKChannelAnnouncement this_ptr_conv;
35725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35726         this_ptr_conv.is_owned = false;
35727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35728         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35729         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
35730         return ret_arr;
35731 }
35732
35733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35734         LDKChannelAnnouncement this_ptr_conv;
35735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35736         this_ptr_conv.is_owned = false;
35737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35738         LDKSignature val_ref;
35739         CHECK((*env)->GetArrayLength(env, val) == 64);
35740         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35741         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
35742 }
35743
35744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35745         LDKChannelAnnouncement this_ptr_conv;
35746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35747         this_ptr_conv.is_owned = false;
35748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35749         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35750         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
35751         return ret_arr;
35752 }
35753
35754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35755         LDKChannelAnnouncement this_ptr_conv;
35756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35757         this_ptr_conv.is_owned = false;
35758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35759         LDKSignature val_ref;
35760         CHECK((*env)->GetArrayLength(env, val) == 64);
35761         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35762         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
35763 }
35764
35765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35766         LDKChannelAnnouncement this_ptr_conv;
35767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35768         this_ptr_conv.is_owned = false;
35769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35770         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
35771         int64_t ret_ref = 0;
35772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35775         ret_ref = (uintptr_t)ret_var.inner;
35776         if (ret_var.is_owned) {
35777                 ret_ref |= 1;
35778         }
35779         return ret_ref;
35780 }
35781
35782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35783         LDKChannelAnnouncement this_ptr_conv;
35784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35785         this_ptr_conv.is_owned = false;
35786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35787         LDKUnsignedChannelAnnouncement val_conv;
35788         val_conv.inner = (void*)(val & (~1));
35789         val_conv.is_owned = (val & 1) || (val == 0);
35790         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35791         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
35792         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
35793 }
35794
35795 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) {
35796         LDKSignature node_signature_1_arg_ref;
35797         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
35798         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
35799         LDKSignature node_signature_2_arg_ref;
35800         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
35801         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
35802         LDKSignature bitcoin_signature_1_arg_ref;
35803         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
35804         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
35805         LDKSignature bitcoin_signature_2_arg_ref;
35806         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
35807         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
35808         LDKUnsignedChannelAnnouncement contents_arg_conv;
35809         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35810         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35811         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35812         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
35813         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);
35814         int64_t ret_ref = 0;
35815         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35816         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35818         ret_ref = (uintptr_t)ret_var.inner;
35819         if (ret_var.is_owned) {
35820                 ret_ref |= 1;
35821         }
35822         return ret_ref;
35823 }
35824
35825 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
35826         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
35827 int64_t ret_ref = 0;
35828 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35829 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35830 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35831 ret_ref = (uintptr_t)ret_var.inner;
35832 if (ret_var.is_owned) {
35833         ret_ref |= 1;
35834 }
35835         return ret_ref;
35836 }
35837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35838         LDKChannelAnnouncement arg_conv;
35839         arg_conv.inner = (void*)(arg & (~1));
35840         arg_conv.is_owned = false;
35841         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35842         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
35843         return ret_conv;
35844 }
35845
35846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35847         LDKChannelAnnouncement orig_conv;
35848         orig_conv.inner = (void*)(orig & (~1));
35849         orig_conv.is_owned = false;
35850         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35851         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
35852         int64_t ret_ref = 0;
35853         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35854         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35856         ret_ref = (uintptr_t)ret_var.inner;
35857         if (ret_var.is_owned) {
35858                 ret_ref |= 1;
35859         }
35860         return ret_ref;
35861 }
35862
35863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35864         LDKUnsignedChannelUpdate this_obj_conv;
35865         this_obj_conv.inner = (void*)(this_obj & (~1));
35866         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35868         UnsignedChannelUpdate_free(this_obj_conv);
35869 }
35870
35871 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35872         LDKUnsignedChannelUpdate this_ptr_conv;
35873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35874         this_ptr_conv.is_owned = false;
35875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35876         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35877         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
35878         return ret_arr;
35879 }
35880
35881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35882         LDKUnsignedChannelUpdate this_ptr_conv;
35883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35884         this_ptr_conv.is_owned = false;
35885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35886         LDKThirtyTwoBytes val_ref;
35887         CHECK((*env)->GetArrayLength(env, val) == 32);
35888         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35889         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
35890 }
35891
35892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35893         LDKUnsignedChannelUpdate this_ptr_conv;
35894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35895         this_ptr_conv.is_owned = false;
35896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35897         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
35898         return ret_conv;
35899 }
35900
35901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35902         LDKUnsignedChannelUpdate this_ptr_conv;
35903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35904         this_ptr_conv.is_owned = false;
35905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35906         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
35907 }
35908
35909 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35910         LDKUnsignedChannelUpdate this_ptr_conv;
35911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35912         this_ptr_conv.is_owned = false;
35913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35914         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
35915         return ret_conv;
35916 }
35917
35918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35919         LDKUnsignedChannelUpdate this_ptr_conv;
35920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35921         this_ptr_conv.is_owned = false;
35922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35923         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
35924 }
35925
35926 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35927         LDKUnsignedChannelUpdate this_ptr_conv;
35928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35929         this_ptr_conv.is_owned = false;
35930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35931         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
35932         return ret_conv;
35933 }
35934
35935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35936         LDKUnsignedChannelUpdate this_ptr_conv;
35937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35938         this_ptr_conv.is_owned = false;
35939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35940         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
35941 }
35942
35943 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
35944         LDKUnsignedChannelUpdate this_ptr_conv;
35945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35946         this_ptr_conv.is_owned = false;
35947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35948         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
35949         return ret_conv;
35950 }
35951
35952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35953         LDKUnsignedChannelUpdate this_ptr_conv;
35954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35955         this_ptr_conv.is_owned = false;
35956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35957         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
35958 }
35959
35960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35961         LDKUnsignedChannelUpdate this_ptr_conv;
35962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35963         this_ptr_conv.is_owned = false;
35964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35965         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
35966         return ret_conv;
35967 }
35968
35969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35970         LDKUnsignedChannelUpdate this_ptr_conv;
35971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35972         this_ptr_conv.is_owned = false;
35973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35974         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
35975 }
35976
35977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35978         LDKUnsignedChannelUpdate this_ptr_conv;
35979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35980         this_ptr_conv.is_owned = false;
35981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35982         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
35983         return ret_conv;
35984 }
35985
35986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35987         LDKUnsignedChannelUpdate this_ptr_conv;
35988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35989         this_ptr_conv.is_owned = false;
35990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35991         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
35992 }
35993
35994 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35995         LDKUnsignedChannelUpdate this_ptr_conv;
35996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35997         this_ptr_conv.is_owned = false;
35998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35999         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
36000         return ret_conv;
36001 }
36002
36003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36004         LDKUnsignedChannelUpdate this_ptr_conv;
36005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36006         this_ptr_conv.is_owned = false;
36007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36008         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
36009 }
36010
36011 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
36012         LDKUnsignedChannelUpdate this_ptr_conv;
36013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36014         this_ptr_conv.is_owned = false;
36015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36016         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
36017         return ret_conv;
36018 }
36019
36020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36021         LDKUnsignedChannelUpdate this_ptr_conv;
36022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36023         this_ptr_conv.is_owned = false;
36024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36025         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
36026 }
36027
36028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
36029         LDKUnsignedChannelUpdate this_ptr_conv;
36030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36031         this_ptr_conv.is_owned = false;
36032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36033         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
36034         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36035         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36036         CVec_u8Z_free(ret_var);
36037         return ret_arr;
36038 }
36039
36040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36041         LDKUnsignedChannelUpdate this_ptr_conv;
36042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36043         this_ptr_conv.is_owned = false;
36044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36045         LDKCVec_u8Z val_ref;
36046         val_ref.datalen = (*env)->GetArrayLength(env, val);
36047         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
36048         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
36049         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
36050 }
36051
36052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int64_t short_channel_id_arg, int32_t timestamp_arg, int8_t flags_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int8_tArray excess_data_arg) {
36053         LDKThirtyTwoBytes chain_hash_arg_ref;
36054         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36055         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36056         LDKCVec_u8Z excess_data_arg_ref;
36057         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
36058         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
36059         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
36060         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_new(chain_hash_arg_ref, short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg_ref);
36061         int64_t ret_ref = 0;
36062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36065         ret_ref = (uintptr_t)ret_var.inner;
36066         if (ret_var.is_owned) {
36067                 ret_ref |= 1;
36068         }
36069         return ret_ref;
36070 }
36071
36072 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
36073         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
36074 int64_t ret_ref = 0;
36075 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36076 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36077 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36078 ret_ref = (uintptr_t)ret_var.inner;
36079 if (ret_var.is_owned) {
36080         ret_ref |= 1;
36081 }
36082         return ret_ref;
36083 }
36084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36085         LDKUnsignedChannelUpdate arg_conv;
36086         arg_conv.inner = (void*)(arg & (~1));
36087         arg_conv.is_owned = false;
36088         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36089         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
36090         return ret_conv;
36091 }
36092
36093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36094         LDKUnsignedChannelUpdate orig_conv;
36095         orig_conv.inner = (void*)(orig & (~1));
36096         orig_conv.is_owned = false;
36097         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36098         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
36099         int64_t ret_ref = 0;
36100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36103         ret_ref = (uintptr_t)ret_var.inner;
36104         if (ret_var.is_owned) {
36105                 ret_ref |= 1;
36106         }
36107         return ret_ref;
36108 }
36109
36110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36111         LDKChannelUpdate this_obj_conv;
36112         this_obj_conv.inner = (void*)(this_obj & (~1));
36113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36115         ChannelUpdate_free(this_obj_conv);
36116 }
36117
36118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36119         LDKChannelUpdate this_ptr_conv;
36120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36121         this_ptr_conv.is_owned = false;
36122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36123         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36124         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
36125         return ret_arr;
36126 }
36127
36128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36129         LDKChannelUpdate this_ptr_conv;
36130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36131         this_ptr_conv.is_owned = false;
36132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36133         LDKSignature val_ref;
36134         CHECK((*env)->GetArrayLength(env, val) == 64);
36135         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36136         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
36137 }
36138
36139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
36140         LDKChannelUpdate this_ptr_conv;
36141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36142         this_ptr_conv.is_owned = false;
36143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36144         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
36145         int64_t ret_ref = 0;
36146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36149         ret_ref = (uintptr_t)ret_var.inner;
36150         if (ret_var.is_owned) {
36151                 ret_ref |= 1;
36152         }
36153         return ret_ref;
36154 }
36155
36156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36157         LDKChannelUpdate this_ptr_conv;
36158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36159         this_ptr_conv.is_owned = false;
36160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36161         LDKUnsignedChannelUpdate val_conv;
36162         val_conv.inner = (void*)(val & (~1));
36163         val_conv.is_owned = (val & 1) || (val == 0);
36164         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36165         val_conv = UnsignedChannelUpdate_clone(&val_conv);
36166         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
36167 }
36168
36169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
36170         LDKSignature signature_arg_ref;
36171         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36172         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36173         LDKUnsignedChannelUpdate contents_arg_conv;
36174         contents_arg_conv.inner = (void*)(contents_arg & (~1));
36175         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
36176         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
36177         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
36178         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
36179         int64_t ret_ref = 0;
36180         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36181         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36183         ret_ref = (uintptr_t)ret_var.inner;
36184         if (ret_var.is_owned) {
36185                 ret_ref |= 1;
36186         }
36187         return ret_ref;
36188 }
36189
36190 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
36191         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
36192 int64_t ret_ref = 0;
36193 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36194 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36195 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36196 ret_ref = (uintptr_t)ret_var.inner;
36197 if (ret_var.is_owned) {
36198         ret_ref |= 1;
36199 }
36200         return ret_ref;
36201 }
36202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36203         LDKChannelUpdate arg_conv;
36204         arg_conv.inner = (void*)(arg & (~1));
36205         arg_conv.is_owned = false;
36206         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36207         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
36208         return ret_conv;
36209 }
36210
36211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36212         LDKChannelUpdate orig_conv;
36213         orig_conv.inner = (void*)(orig & (~1));
36214         orig_conv.is_owned = false;
36215         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36216         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
36217         int64_t ret_ref = 0;
36218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36221         ret_ref = (uintptr_t)ret_var.inner;
36222         if (ret_var.is_owned) {
36223                 ret_ref |= 1;
36224         }
36225         return ret_ref;
36226 }
36227
36228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36229         LDKQueryChannelRange this_obj_conv;
36230         this_obj_conv.inner = (void*)(this_obj & (~1));
36231         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36233         QueryChannelRange_free(this_obj_conv);
36234 }
36235
36236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36237         LDKQueryChannelRange this_ptr_conv;
36238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36239         this_ptr_conv.is_owned = false;
36240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36241         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
36243         return ret_arr;
36244 }
36245
36246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36247         LDKQueryChannelRange this_ptr_conv;
36248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36249         this_ptr_conv.is_owned = false;
36250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36251         LDKThirtyTwoBytes val_ref;
36252         CHECK((*env)->GetArrayLength(env, val) == 32);
36253         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36254         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36255 }
36256
36257 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36258         LDKQueryChannelRange this_ptr_conv;
36259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36260         this_ptr_conv.is_owned = false;
36261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36262         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
36263         return ret_conv;
36264 }
36265
36266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36267         LDKQueryChannelRange this_ptr_conv;
36268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36269         this_ptr_conv.is_owned = false;
36270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36271         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
36272 }
36273
36274 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36275         LDKQueryChannelRange this_ptr_conv;
36276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36277         this_ptr_conv.is_owned = false;
36278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36279         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
36280         return ret_conv;
36281 }
36282
36283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36284         LDKQueryChannelRange this_ptr_conv;
36285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36286         this_ptr_conv.is_owned = false;
36287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36288         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36289 }
36290
36291 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) {
36292         LDKThirtyTwoBytes chain_hash_arg_ref;
36293         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36294         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36295         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
36296         int64_t ret_ref = 0;
36297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36300         ret_ref = (uintptr_t)ret_var.inner;
36301         if (ret_var.is_owned) {
36302                 ret_ref |= 1;
36303         }
36304         return ret_ref;
36305 }
36306
36307 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
36308         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
36309 int64_t ret_ref = 0;
36310 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36311 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36312 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36313 ret_ref = (uintptr_t)ret_var.inner;
36314 if (ret_var.is_owned) {
36315         ret_ref |= 1;
36316 }
36317         return ret_ref;
36318 }
36319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36320         LDKQueryChannelRange arg_conv;
36321         arg_conv.inner = (void*)(arg & (~1));
36322         arg_conv.is_owned = false;
36323         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36324         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
36325         return ret_conv;
36326 }
36327
36328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36329         LDKQueryChannelRange orig_conv;
36330         orig_conv.inner = (void*)(orig & (~1));
36331         orig_conv.is_owned = false;
36332         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36333         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
36334         int64_t ret_ref = 0;
36335         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36336         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36338         ret_ref = (uintptr_t)ret_var.inner;
36339         if (ret_var.is_owned) {
36340                 ret_ref |= 1;
36341         }
36342         return ret_ref;
36343 }
36344
36345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36346         LDKReplyChannelRange this_obj_conv;
36347         this_obj_conv.inner = (void*)(this_obj & (~1));
36348         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36350         ReplyChannelRange_free(this_obj_conv);
36351 }
36352
36353 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36354         LDKReplyChannelRange this_ptr_conv;
36355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36356         this_ptr_conv.is_owned = false;
36357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36358         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36359         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
36360         return ret_arr;
36361 }
36362
36363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36364         LDKReplyChannelRange this_ptr_conv;
36365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36366         this_ptr_conv.is_owned = false;
36367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36368         LDKThirtyTwoBytes val_ref;
36369         CHECK((*env)->GetArrayLength(env, val) == 32);
36370         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36371         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36372 }
36373
36374 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36375         LDKReplyChannelRange this_ptr_conv;
36376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36377         this_ptr_conv.is_owned = false;
36378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36379         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
36380         return ret_conv;
36381 }
36382
36383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36384         LDKReplyChannelRange this_ptr_conv;
36385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36386         this_ptr_conv.is_owned = false;
36387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36388         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
36389 }
36390
36391 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36392         LDKReplyChannelRange this_ptr_conv;
36393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36394         this_ptr_conv.is_owned = false;
36395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36396         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
36397         return ret_conv;
36398 }
36399
36400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36401         LDKReplyChannelRange this_ptr_conv;
36402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36403         this_ptr_conv.is_owned = false;
36404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36405         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36406 }
36407
36408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
36409         LDKReplyChannelRange this_ptr_conv;
36410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36411         this_ptr_conv.is_owned = false;
36412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36413         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
36414         return ret_conv;
36415 }
36416
36417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36418         LDKReplyChannelRange this_ptr_conv;
36419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36420         this_ptr_conv.is_owned = false;
36421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36422         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
36423 }
36424
36425 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
36426         LDKReplyChannelRange this_ptr_conv;
36427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36428         this_ptr_conv.is_owned = false;
36429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36430         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
36431         int64_tArray ret_arr = NULL;
36432         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36433         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36434         for (size_t g = 0; g < ret_var.datalen; g++) {
36435                 int64_t ret_conv_6_conv = ret_var.data[g];
36436                 ret_arr_ptr[g] = ret_conv_6_conv;
36437         }
36438         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36439         FREE(ret_var.data);
36440         return ret_arr;
36441 }
36442
36443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36444         LDKReplyChannelRange this_ptr_conv;
36445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36446         this_ptr_conv.is_owned = false;
36447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36448         LDKCVec_u64Z val_constr;
36449         val_constr.datalen = (*env)->GetArrayLength(env, val);
36450         if (val_constr.datalen > 0)
36451                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36452         else
36453                 val_constr.data = NULL;
36454         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36455         for (size_t g = 0; g < val_constr.datalen; g++) {
36456                 int64_t val_conv_6 = val_vals[g];
36457                 val_constr.data[g] = val_conv_6;
36458         }
36459         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36460         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
36461 }
36462
36463 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) {
36464         LDKThirtyTwoBytes chain_hash_arg_ref;
36465         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36466         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36467         LDKCVec_u64Z short_channel_ids_arg_constr;
36468         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36469         if (short_channel_ids_arg_constr.datalen > 0)
36470                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36471         else
36472                 short_channel_ids_arg_constr.data = NULL;
36473         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36474         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36475                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36476                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36477         }
36478         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36479         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
36480         int64_t ret_ref = 0;
36481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36484         ret_ref = (uintptr_t)ret_var.inner;
36485         if (ret_var.is_owned) {
36486                 ret_ref |= 1;
36487         }
36488         return ret_ref;
36489 }
36490
36491 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
36492         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
36493 int64_t ret_ref = 0;
36494 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36495 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36496 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36497 ret_ref = (uintptr_t)ret_var.inner;
36498 if (ret_var.is_owned) {
36499         ret_ref |= 1;
36500 }
36501         return ret_ref;
36502 }
36503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36504         LDKReplyChannelRange arg_conv;
36505         arg_conv.inner = (void*)(arg & (~1));
36506         arg_conv.is_owned = false;
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36508         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
36509         return ret_conv;
36510 }
36511
36512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36513         LDKReplyChannelRange orig_conv;
36514         orig_conv.inner = (void*)(orig & (~1));
36515         orig_conv.is_owned = false;
36516         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36517         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
36518         int64_t ret_ref = 0;
36519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36522         ret_ref = (uintptr_t)ret_var.inner;
36523         if (ret_var.is_owned) {
36524                 ret_ref |= 1;
36525         }
36526         return ret_ref;
36527 }
36528
36529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36530         LDKQueryShortChannelIds this_obj_conv;
36531         this_obj_conv.inner = (void*)(this_obj & (~1));
36532         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36534         QueryShortChannelIds_free(this_obj_conv);
36535 }
36536
36537 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36538         LDKQueryShortChannelIds this_ptr_conv;
36539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36540         this_ptr_conv.is_owned = false;
36541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36542         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36543         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
36544         return ret_arr;
36545 }
36546
36547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36548         LDKQueryShortChannelIds this_ptr_conv;
36549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36550         this_ptr_conv.is_owned = false;
36551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36552         LDKThirtyTwoBytes val_ref;
36553         CHECK((*env)->GetArrayLength(env, val) == 32);
36554         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36555         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
36556 }
36557
36558 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
36559         LDKQueryShortChannelIds this_ptr_conv;
36560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36561         this_ptr_conv.is_owned = false;
36562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36563         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
36564         int64_tArray ret_arr = NULL;
36565         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36566         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36567         for (size_t g = 0; g < ret_var.datalen; g++) {
36568                 int64_t ret_conv_6_conv = ret_var.data[g];
36569                 ret_arr_ptr[g] = ret_conv_6_conv;
36570         }
36571         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36572         FREE(ret_var.data);
36573         return ret_arr;
36574 }
36575
36576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36577         LDKQueryShortChannelIds this_ptr_conv;
36578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36579         this_ptr_conv.is_owned = false;
36580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36581         LDKCVec_u64Z val_constr;
36582         val_constr.datalen = (*env)->GetArrayLength(env, val);
36583         if (val_constr.datalen > 0)
36584                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36585         else
36586                 val_constr.data = NULL;
36587         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36588         for (size_t g = 0; g < val_constr.datalen; g++) {
36589                 int64_t val_conv_6 = val_vals[g];
36590                 val_constr.data[g] = val_conv_6;
36591         }
36592         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36593         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
36594 }
36595
36596 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) {
36597         LDKThirtyTwoBytes chain_hash_arg_ref;
36598         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36599         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36600         LDKCVec_u64Z short_channel_ids_arg_constr;
36601         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36602         if (short_channel_ids_arg_constr.datalen > 0)
36603                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36604         else
36605                 short_channel_ids_arg_constr.data = NULL;
36606         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36607         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36608                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36609                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36610         }
36611         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36612         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
36613         int64_t ret_ref = 0;
36614         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36615         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36617         ret_ref = (uintptr_t)ret_var.inner;
36618         if (ret_var.is_owned) {
36619                 ret_ref |= 1;
36620         }
36621         return ret_ref;
36622 }
36623
36624 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
36625         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
36626 int64_t ret_ref = 0;
36627 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36628 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36629 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36630 ret_ref = (uintptr_t)ret_var.inner;
36631 if (ret_var.is_owned) {
36632         ret_ref |= 1;
36633 }
36634         return ret_ref;
36635 }
36636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36637         LDKQueryShortChannelIds arg_conv;
36638         arg_conv.inner = (void*)(arg & (~1));
36639         arg_conv.is_owned = false;
36640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36641         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
36642         return ret_conv;
36643 }
36644
36645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36646         LDKQueryShortChannelIds orig_conv;
36647         orig_conv.inner = (void*)(orig & (~1));
36648         orig_conv.is_owned = false;
36649         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36650         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
36651         int64_t ret_ref = 0;
36652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36655         ret_ref = (uintptr_t)ret_var.inner;
36656         if (ret_var.is_owned) {
36657                 ret_ref |= 1;
36658         }
36659         return ret_ref;
36660 }
36661
36662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36663         LDKReplyShortChannelIdsEnd this_obj_conv;
36664         this_obj_conv.inner = (void*)(this_obj & (~1));
36665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36667         ReplyShortChannelIdsEnd_free(this_obj_conv);
36668 }
36669
36670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36671         LDKReplyShortChannelIdsEnd this_ptr_conv;
36672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36673         this_ptr_conv.is_owned = false;
36674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36675         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36676         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
36677         return ret_arr;
36678 }
36679
36680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36681         LDKReplyShortChannelIdsEnd this_ptr_conv;
36682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36683         this_ptr_conv.is_owned = false;
36684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36685         LDKThirtyTwoBytes val_ref;
36686         CHECK((*env)->GetArrayLength(env, val) == 32);
36687         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36688         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
36689 }
36690
36691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
36692         LDKReplyShortChannelIdsEnd this_ptr_conv;
36693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36694         this_ptr_conv.is_owned = false;
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36696         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
36697         return ret_conv;
36698 }
36699
36700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36701         LDKReplyShortChannelIdsEnd this_ptr_conv;
36702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36703         this_ptr_conv.is_owned = false;
36704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36705         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
36706 }
36707
36708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
36709         LDKThirtyTwoBytes chain_hash_arg_ref;
36710         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36711         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36712         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
36713         int64_t ret_ref = 0;
36714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36717         ret_ref = (uintptr_t)ret_var.inner;
36718         if (ret_var.is_owned) {
36719                 ret_ref |= 1;
36720         }
36721         return ret_ref;
36722 }
36723
36724 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
36725         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
36726 int64_t ret_ref = 0;
36727 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36728 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36729 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36730 ret_ref = (uintptr_t)ret_var.inner;
36731 if (ret_var.is_owned) {
36732         ret_ref |= 1;
36733 }
36734         return ret_ref;
36735 }
36736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36737         LDKReplyShortChannelIdsEnd arg_conv;
36738         arg_conv.inner = (void*)(arg & (~1));
36739         arg_conv.is_owned = false;
36740         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36741         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
36742         return ret_conv;
36743 }
36744
36745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36746         LDKReplyShortChannelIdsEnd orig_conv;
36747         orig_conv.inner = (void*)(orig & (~1));
36748         orig_conv.is_owned = false;
36749         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36750         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
36751         int64_t ret_ref = 0;
36752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36755         ret_ref = (uintptr_t)ret_var.inner;
36756         if (ret_var.is_owned) {
36757                 ret_ref |= 1;
36758         }
36759         return ret_ref;
36760 }
36761
36762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36763         LDKGossipTimestampFilter this_obj_conv;
36764         this_obj_conv.inner = (void*)(this_obj & (~1));
36765         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36767         GossipTimestampFilter_free(this_obj_conv);
36768 }
36769
36770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36771         LDKGossipTimestampFilter this_ptr_conv;
36772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36773         this_ptr_conv.is_owned = false;
36774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36775         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36776         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
36777         return ret_arr;
36778 }
36779
36780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36781         LDKGossipTimestampFilter this_ptr_conv;
36782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36783         this_ptr_conv.is_owned = false;
36784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36785         LDKThirtyTwoBytes val_ref;
36786         CHECK((*env)->GetArrayLength(env, val) == 32);
36787         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36788         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
36789 }
36790
36791 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
36792         LDKGossipTimestampFilter this_ptr_conv;
36793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36794         this_ptr_conv.is_owned = false;
36795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36796         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
36797         return ret_conv;
36798 }
36799
36800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36801         LDKGossipTimestampFilter this_ptr_conv;
36802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36803         this_ptr_conv.is_owned = false;
36804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36805         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
36806 }
36807
36808 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
36809         LDKGossipTimestampFilter this_ptr_conv;
36810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36811         this_ptr_conv.is_owned = false;
36812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36813         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
36814         return ret_conv;
36815 }
36816
36817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36818         LDKGossipTimestampFilter this_ptr_conv;
36819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36820         this_ptr_conv.is_owned = false;
36821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36822         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
36823 }
36824
36825 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) {
36826         LDKThirtyTwoBytes chain_hash_arg_ref;
36827         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36828         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36829         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
36830         int64_t ret_ref = 0;
36831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36834         ret_ref = (uintptr_t)ret_var.inner;
36835         if (ret_var.is_owned) {
36836                 ret_ref |= 1;
36837         }
36838         return ret_ref;
36839 }
36840
36841 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
36842         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
36843 int64_t ret_ref = 0;
36844 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36845 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36846 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36847 ret_ref = (uintptr_t)ret_var.inner;
36848 if (ret_var.is_owned) {
36849         ret_ref |= 1;
36850 }
36851         return ret_ref;
36852 }
36853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36854         LDKGossipTimestampFilter arg_conv;
36855         arg_conv.inner = (void*)(arg & (~1));
36856         arg_conv.is_owned = false;
36857         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36858         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
36859         return ret_conv;
36860 }
36861
36862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36863         LDKGossipTimestampFilter orig_conv;
36864         orig_conv.inner = (void*)(orig & (~1));
36865         orig_conv.is_owned = false;
36866         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36867         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
36868         int64_t ret_ref = 0;
36869         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36870         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36872         ret_ref = (uintptr_t)ret_var.inner;
36873         if (ret_var.is_owned) {
36874                 ret_ref |= 1;
36875         }
36876         return ret_ref;
36877 }
36878
36879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36880         if ((this_ptr & 1) != 0) return;
36881         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36882         CHECK_ACCESS(this_ptr_ptr);
36883         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
36884         FREE((void*)this_ptr);
36885         ErrorAction_free(this_ptr_conv);
36886 }
36887
36888 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
36889         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36890         *ret_copy = ErrorAction_clone(arg);
36891 int64_t ret_ref = (uintptr_t)ret_copy;
36892         return ret_ref;
36893 }
36894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36895         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
36896         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
36897         return ret_conv;
36898 }
36899
36900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36901         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
36902         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36903         *ret_copy = ErrorAction_clone(orig_conv);
36904         int64_t ret_ref = (uintptr_t)ret_copy;
36905         return ret_ref;
36906 }
36907
36908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
36909         LDKErrorMessage msg_conv;
36910         msg_conv.inner = (void*)(msg & (~1));
36911         msg_conv.is_owned = (msg & 1) || (msg == 0);
36912         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36913         msg_conv = ErrorMessage_clone(&msg_conv);
36914         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36915         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
36916         int64_t ret_ref = (uintptr_t)ret_copy;
36917         return ret_ref;
36918 }
36919
36920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
36921         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36922         *ret_copy = ErrorAction_ignore_error();
36923         int64_t ret_ref = (uintptr_t)ret_copy;
36924         return ret_ref;
36925 }
36926
36927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
36928         LDKLevel a_conv = LDKLevel_from_java(env, a);
36929         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36930         *ret_copy = ErrorAction_ignore_and_log(a_conv);
36931         int64_t ret_ref = (uintptr_t)ret_copy;
36932         return ret_ref;
36933 }
36934
36935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
36936         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36937         *ret_copy = ErrorAction_ignore_duplicate_gossip();
36938         int64_t ret_ref = (uintptr_t)ret_copy;
36939         return ret_ref;
36940 }
36941
36942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
36943         LDKErrorMessage msg_conv;
36944         msg_conv.inner = (void*)(msg & (~1));
36945         msg_conv.is_owned = (msg & 1) || (msg == 0);
36946         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36947         msg_conv = ErrorMessage_clone(&msg_conv);
36948         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36949         *ret_copy = ErrorAction_send_error_message(msg_conv);
36950         int64_t ret_ref = (uintptr_t)ret_copy;
36951         return ret_ref;
36952 }
36953
36954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
36955         LDKWarningMessage msg_conv;
36956         msg_conv.inner = (void*)(msg & (~1));
36957         msg_conv.is_owned = (msg & 1) || (msg == 0);
36958         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36959         msg_conv = WarningMessage_clone(&msg_conv);
36960         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
36961         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36962         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
36963         int64_t ret_ref = (uintptr_t)ret_copy;
36964         return ret_ref;
36965 }
36966
36967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36968         LDKLightningError this_obj_conv;
36969         this_obj_conv.inner = (void*)(this_obj & (~1));
36970         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36972         LightningError_free(this_obj_conv);
36973 }
36974
36975 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
36976         LDKLightningError this_ptr_conv;
36977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36978         this_ptr_conv.is_owned = false;
36979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36980         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
36981         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
36982         Str_free(ret_str);
36983         return ret_conv;
36984 }
36985
36986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
36987         LDKLightningError this_ptr_conv;
36988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36989         this_ptr_conv.is_owned = false;
36990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36991         LDKStr val_conv = java_to_owned_str(env, val);
36992         LightningError_set_err(&this_ptr_conv, val_conv);
36993 }
36994
36995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
36996         LDKLightningError this_ptr_conv;
36997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36998         this_ptr_conv.is_owned = false;
36999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37000         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37001         *ret_copy = LightningError_get_action(&this_ptr_conv);
37002         int64_t ret_ref = (uintptr_t)ret_copy;
37003         return ret_ref;
37004 }
37005
37006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37007         LDKLightningError this_ptr_conv;
37008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37009         this_ptr_conv.is_owned = false;
37010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37011         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37012         CHECK_ACCESS(val_ptr);
37013         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
37014         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
37015         LightningError_set_action(&this_ptr_conv, val_conv);
37016 }
37017
37018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
37019         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
37020         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
37021         CHECK_ACCESS(action_arg_ptr);
37022         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
37023         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
37024         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
37025         int64_t ret_ref = 0;
37026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37029         ret_ref = (uintptr_t)ret_var.inner;
37030         if (ret_var.is_owned) {
37031                 ret_ref |= 1;
37032         }
37033         return ret_ref;
37034 }
37035
37036 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
37037         LDKLightningError ret_var = LightningError_clone(arg);
37038 int64_t ret_ref = 0;
37039 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37040 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37041 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37042 ret_ref = (uintptr_t)ret_var.inner;
37043 if (ret_var.is_owned) {
37044         ret_ref |= 1;
37045 }
37046         return ret_ref;
37047 }
37048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37049         LDKLightningError arg_conv;
37050         arg_conv.inner = (void*)(arg & (~1));
37051         arg_conv.is_owned = false;
37052         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37053         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
37054         return ret_conv;
37055 }
37056
37057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37058         LDKLightningError orig_conv;
37059         orig_conv.inner = (void*)(orig & (~1));
37060         orig_conv.is_owned = false;
37061         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37062         LDKLightningError ret_var = LightningError_clone(&orig_conv);
37063         int64_t ret_ref = 0;
37064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37067         ret_ref = (uintptr_t)ret_var.inner;
37068         if (ret_var.is_owned) {
37069                 ret_ref |= 1;
37070         }
37071         return ret_ref;
37072 }
37073
37074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37075         LDKCommitmentUpdate this_obj_conv;
37076         this_obj_conv.inner = (void*)(this_obj & (~1));
37077         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37079         CommitmentUpdate_free(this_obj_conv);
37080 }
37081
37082 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37083         LDKCommitmentUpdate this_ptr_conv;
37084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37085         this_ptr_conv.is_owned = false;
37086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37087         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
37088         int64_tArray ret_arr = NULL;
37089         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37090         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37091         for (size_t p = 0; p < ret_var.datalen; p++) {
37092                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
37093                 int64_t ret_conv_15_ref = 0;
37094                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37095                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37096                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
37097                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
37098                 if (ret_conv_15_var.is_owned) {
37099                         ret_conv_15_ref |= 1;
37100                 }
37101                 ret_arr_ptr[p] = ret_conv_15_ref;
37102         }
37103         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37104         FREE(ret_var.data);
37105         return ret_arr;
37106 }
37107
37108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37109         LDKCommitmentUpdate this_ptr_conv;
37110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37111         this_ptr_conv.is_owned = false;
37112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37113         LDKCVec_UpdateAddHTLCZ val_constr;
37114         val_constr.datalen = (*env)->GetArrayLength(env, val);
37115         if (val_constr.datalen > 0)
37116                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37117         else
37118                 val_constr.data = NULL;
37119         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37120         for (size_t p = 0; p < val_constr.datalen; p++) {
37121                 int64_t val_conv_15 = val_vals[p];
37122                 LDKUpdateAddHTLC val_conv_15_conv;
37123                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
37124                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
37125                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
37126                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
37127                 val_constr.data[p] = val_conv_15_conv;
37128         }
37129         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37130         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
37131 }
37132
37133 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37134         LDKCommitmentUpdate this_ptr_conv;
37135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37136         this_ptr_conv.is_owned = false;
37137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37138         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
37139         int64_tArray ret_arr = NULL;
37140         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37141         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37142         for (size_t t = 0; t < ret_var.datalen; t++) {
37143                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
37144                 int64_t ret_conv_19_ref = 0;
37145                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37146                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37147                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
37148                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
37149                 if (ret_conv_19_var.is_owned) {
37150                         ret_conv_19_ref |= 1;
37151                 }
37152                 ret_arr_ptr[t] = ret_conv_19_ref;
37153         }
37154         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37155         FREE(ret_var.data);
37156         return ret_arr;
37157 }
37158
37159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37160         LDKCommitmentUpdate this_ptr_conv;
37161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37162         this_ptr_conv.is_owned = false;
37163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37164         LDKCVec_UpdateFulfillHTLCZ val_constr;
37165         val_constr.datalen = (*env)->GetArrayLength(env, val);
37166         if (val_constr.datalen > 0)
37167                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37168         else
37169                 val_constr.data = NULL;
37170         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37171         for (size_t t = 0; t < val_constr.datalen; t++) {
37172                 int64_t val_conv_19 = val_vals[t];
37173                 LDKUpdateFulfillHTLC val_conv_19_conv;
37174                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
37175                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
37176                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
37177                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
37178                 val_constr.data[t] = val_conv_19_conv;
37179         }
37180         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37181         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
37182 }
37183
37184 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37185         LDKCommitmentUpdate this_ptr_conv;
37186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37187         this_ptr_conv.is_owned = false;
37188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37189         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
37190         int64_tArray ret_arr = NULL;
37191         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37192         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37193         for (size_t q = 0; q < ret_var.datalen; q++) {
37194                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
37195                 int64_t ret_conv_16_ref = 0;
37196                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37197                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37198                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
37199                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
37200                 if (ret_conv_16_var.is_owned) {
37201                         ret_conv_16_ref |= 1;
37202                 }
37203                 ret_arr_ptr[q] = ret_conv_16_ref;
37204         }
37205         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37206         FREE(ret_var.data);
37207         return ret_arr;
37208 }
37209
37210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37211         LDKCommitmentUpdate this_ptr_conv;
37212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37213         this_ptr_conv.is_owned = false;
37214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37215         LDKCVec_UpdateFailHTLCZ val_constr;
37216         val_constr.datalen = (*env)->GetArrayLength(env, val);
37217         if (val_constr.datalen > 0)
37218                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37219         else
37220                 val_constr.data = NULL;
37221         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37222         for (size_t q = 0; q < val_constr.datalen; q++) {
37223                 int64_t val_conv_16 = val_vals[q];
37224                 LDKUpdateFailHTLC val_conv_16_conv;
37225                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
37226                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
37227                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
37228                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
37229                 val_constr.data[q] = val_conv_16_conv;
37230         }
37231         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37232         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
37233 }
37234
37235 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37236         LDKCommitmentUpdate this_ptr_conv;
37237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37238         this_ptr_conv.is_owned = false;
37239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37240         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
37241         int64_tArray ret_arr = NULL;
37242         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37243         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37244         for (size_t z = 0; z < ret_var.datalen; z++) {
37245                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
37246                 int64_t ret_conv_25_ref = 0;
37247                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37248                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37249                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
37250                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
37251                 if (ret_conv_25_var.is_owned) {
37252                         ret_conv_25_ref |= 1;
37253                 }
37254                 ret_arr_ptr[z] = ret_conv_25_ref;
37255         }
37256         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37257         FREE(ret_var.data);
37258         return ret_arr;
37259 }
37260
37261 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) {
37262         LDKCommitmentUpdate this_ptr_conv;
37263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37264         this_ptr_conv.is_owned = false;
37265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37266         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
37267         val_constr.datalen = (*env)->GetArrayLength(env, val);
37268         if (val_constr.datalen > 0)
37269                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37270         else
37271                 val_constr.data = NULL;
37272         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37273         for (size_t z = 0; z < val_constr.datalen; z++) {
37274                 int64_t val_conv_25 = val_vals[z];
37275                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
37276                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
37277                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
37278                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
37279                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
37280                 val_constr.data[z] = val_conv_25_conv;
37281         }
37282         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37283         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
37284 }
37285
37286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
37287         LDKCommitmentUpdate this_ptr_conv;
37288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37289         this_ptr_conv.is_owned = false;
37290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37291         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
37292         int64_t ret_ref = 0;
37293         if ((uintptr_t)ret_var.inner > 4096) {
37294                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37295                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37297                 ret_ref = (uintptr_t)ret_var.inner;
37298                 if (ret_var.is_owned) {
37299                         ret_ref |= 1;
37300                 }
37301         }
37302         return ret_ref;
37303 }
37304
37305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37306         LDKCommitmentUpdate this_ptr_conv;
37307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37308         this_ptr_conv.is_owned = false;
37309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37310         LDKUpdateFee val_conv;
37311         val_conv.inner = (void*)(val & (~1));
37312         val_conv.is_owned = (val & 1) || (val == 0);
37313         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37314         val_conv = UpdateFee_clone(&val_conv);
37315         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
37316 }
37317
37318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
37319         LDKCommitmentUpdate this_ptr_conv;
37320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37321         this_ptr_conv.is_owned = false;
37322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37323         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
37324         int64_t ret_ref = 0;
37325         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37326         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37328         ret_ref = (uintptr_t)ret_var.inner;
37329         if (ret_var.is_owned) {
37330                 ret_ref |= 1;
37331         }
37332         return ret_ref;
37333 }
37334
37335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37336         LDKCommitmentUpdate this_ptr_conv;
37337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37338         this_ptr_conv.is_owned = false;
37339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37340         LDKCommitmentSigned val_conv;
37341         val_conv.inner = (void*)(val & (~1));
37342         val_conv.is_owned = (val & 1) || (val == 0);
37343         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37344         val_conv = CommitmentSigned_clone(&val_conv);
37345         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
37346 }
37347
37348 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) {
37349         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
37350         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
37351         if (update_add_htlcs_arg_constr.datalen > 0)
37352                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37353         else
37354                 update_add_htlcs_arg_constr.data = NULL;
37355         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
37356         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
37357                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
37358                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
37359                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
37360                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
37361                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
37362                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
37363                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
37364         }
37365         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
37366         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
37367         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
37368         if (update_fulfill_htlcs_arg_constr.datalen > 0)
37369                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37370         else
37371                 update_fulfill_htlcs_arg_constr.data = NULL;
37372         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
37373         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
37374                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
37375                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
37376                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
37377                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
37378                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
37379                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
37380                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
37381         }
37382         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
37383         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
37384         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
37385         if (update_fail_htlcs_arg_constr.datalen > 0)
37386                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37387         else
37388                 update_fail_htlcs_arg_constr.data = NULL;
37389         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
37390         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
37391                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
37392                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
37393                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
37394                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
37395                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
37396                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
37397                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
37398         }
37399         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
37400         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
37401         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
37402         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
37403                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37404         else
37405                 update_fail_malformed_htlcs_arg_constr.data = NULL;
37406         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
37407         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
37408                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
37409                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
37410                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
37411                 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);
37412                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
37413                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
37414                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
37415         }
37416         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
37417         LDKUpdateFee update_fee_arg_conv;
37418         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
37419         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
37420         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
37421         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
37422         LDKCommitmentSigned commitment_signed_arg_conv;
37423         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
37424         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
37425         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
37426         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
37427         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);
37428         int64_t ret_ref = 0;
37429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37432         ret_ref = (uintptr_t)ret_var.inner;
37433         if (ret_var.is_owned) {
37434                 ret_ref |= 1;
37435         }
37436         return ret_ref;
37437 }
37438
37439 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
37440         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
37441 int64_t ret_ref = 0;
37442 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37443 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37444 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37445 ret_ref = (uintptr_t)ret_var.inner;
37446 if (ret_var.is_owned) {
37447         ret_ref |= 1;
37448 }
37449         return ret_ref;
37450 }
37451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37452         LDKCommitmentUpdate arg_conv;
37453         arg_conv.inner = (void*)(arg & (~1));
37454         arg_conv.is_owned = false;
37455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37456         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
37457         return ret_conv;
37458 }
37459
37460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37461         LDKCommitmentUpdate orig_conv;
37462         orig_conv.inner = (void*)(orig & (~1));
37463         orig_conv.is_owned = false;
37464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37465         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
37466         int64_t ret_ref = 0;
37467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37470         ret_ref = (uintptr_t)ret_var.inner;
37471         if (ret_var.is_owned) {
37472                 ret_ref |= 1;
37473         }
37474         return ret_ref;
37475 }
37476
37477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37478         if ((this_ptr & 1) != 0) return;
37479         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37480         CHECK_ACCESS(this_ptr_ptr);
37481         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
37482         FREE((void*)this_ptr);
37483         ChannelMessageHandler_free(this_ptr_conv);
37484 }
37485
37486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37487         if ((this_ptr & 1) != 0) return;
37488         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37489         CHECK_ACCESS(this_ptr_ptr);
37490         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
37491         FREE((void*)this_ptr);
37492         RoutingMessageHandler_free(this_ptr_conv);
37493 }
37494
37495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
37496         LDKAcceptChannel obj_conv;
37497         obj_conv.inner = (void*)(obj & (~1));
37498         obj_conv.is_owned = false;
37499         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37500         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
37501         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37502         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37503         CVec_u8Z_free(ret_var);
37504         return ret_arr;
37505 }
37506
37507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37508         LDKu8slice ser_ref;
37509         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37510         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37511         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
37512         *ret_conv = AcceptChannel_read(ser_ref);
37513         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37514         return (int64_t)ret_conv;
37515 }
37516
37517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
37518         LDKAnnouncementSignatures obj_conv;
37519         obj_conv.inner = (void*)(obj & (~1));
37520         obj_conv.is_owned = false;
37521         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37522         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
37523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37525         CVec_u8Z_free(ret_var);
37526         return ret_arr;
37527 }
37528
37529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37530         LDKu8slice ser_ref;
37531         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37532         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37533         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
37534         *ret_conv = AnnouncementSignatures_read(ser_ref);
37535         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37536         return (int64_t)ret_conv;
37537 }
37538
37539 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
37540         LDKChannelReestablish obj_conv;
37541         obj_conv.inner = (void*)(obj & (~1));
37542         obj_conv.is_owned = false;
37543         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37544         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
37545         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37546         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37547         CVec_u8Z_free(ret_var);
37548         return ret_arr;
37549 }
37550
37551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37552         LDKu8slice ser_ref;
37553         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37554         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37555         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
37556         *ret_conv = ChannelReestablish_read(ser_ref);
37557         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37558         return (int64_t)ret_conv;
37559 }
37560
37561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37562         LDKClosingSigned obj_conv;
37563         obj_conv.inner = (void*)(obj & (~1));
37564         obj_conv.is_owned = false;
37565         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37566         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
37567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37569         CVec_u8Z_free(ret_var);
37570         return ret_arr;
37571 }
37572
37573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37574         LDKu8slice ser_ref;
37575         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37576         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37577         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
37578         *ret_conv = ClosingSigned_read(ser_ref);
37579         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37580         return (int64_t)ret_conv;
37581 }
37582
37583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
37584         LDKClosingSignedFeeRange obj_conv;
37585         obj_conv.inner = (void*)(obj & (~1));
37586         obj_conv.is_owned = false;
37587         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37588         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
37589         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37590         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37591         CVec_u8Z_free(ret_var);
37592         return ret_arr;
37593 }
37594
37595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37596         LDKu8slice ser_ref;
37597         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37598         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37599         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
37600         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
37601         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37602         return (int64_t)ret_conv;
37603 }
37604
37605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37606         LDKCommitmentSigned obj_conv;
37607         obj_conv.inner = (void*)(obj & (~1));
37608         obj_conv.is_owned = false;
37609         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37610         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
37611         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37612         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37613         CVec_u8Z_free(ret_var);
37614         return ret_arr;
37615 }
37616
37617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37618         LDKu8slice ser_ref;
37619         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37620         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37621         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
37622         *ret_conv = CommitmentSigned_read(ser_ref);
37623         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37624         return (int64_t)ret_conv;
37625 }
37626
37627 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
37628         LDKFundingCreated obj_conv;
37629         obj_conv.inner = (void*)(obj & (~1));
37630         obj_conv.is_owned = false;
37631         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37632         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
37633         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37634         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37635         CVec_u8Z_free(ret_var);
37636         return ret_arr;
37637 }
37638
37639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37640         LDKu8slice ser_ref;
37641         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37642         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37643         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
37644         *ret_conv = FundingCreated_read(ser_ref);
37645         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37646         return (int64_t)ret_conv;
37647 }
37648
37649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37650         LDKFundingSigned obj_conv;
37651         obj_conv.inner = (void*)(obj & (~1));
37652         obj_conv.is_owned = false;
37653         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37654         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
37655         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37656         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37657         CVec_u8Z_free(ret_var);
37658         return ret_arr;
37659 }
37660
37661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37662         LDKu8slice ser_ref;
37663         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37664         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37665         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
37666         *ret_conv = FundingSigned_read(ser_ref);
37667         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37668         return (int64_t)ret_conv;
37669 }
37670
37671 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
37672         LDKChannelReady obj_conv;
37673         obj_conv.inner = (void*)(obj & (~1));
37674         obj_conv.is_owned = false;
37675         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37676         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
37677         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37678         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37679         CVec_u8Z_free(ret_var);
37680         return ret_arr;
37681 }
37682
37683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37684         LDKu8slice ser_ref;
37685         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37686         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37687         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
37688         *ret_conv = ChannelReady_read(ser_ref);
37689         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37690         return (int64_t)ret_conv;
37691 }
37692
37693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
37694         LDKInit obj_conv;
37695         obj_conv.inner = (void*)(obj & (~1));
37696         obj_conv.is_owned = false;
37697         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37698         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
37699         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37700         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37701         CVec_u8Z_free(ret_var);
37702         return ret_arr;
37703 }
37704
37705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37706         LDKu8slice ser_ref;
37707         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37708         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37709         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
37710         *ret_conv = Init_read(ser_ref);
37711         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37712         return (int64_t)ret_conv;
37713 }
37714
37715 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
37716         LDKOpenChannel obj_conv;
37717         obj_conv.inner = (void*)(obj & (~1));
37718         obj_conv.is_owned = false;
37719         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37720         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
37721         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37722         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37723         CVec_u8Z_free(ret_var);
37724         return ret_arr;
37725 }
37726
37727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37728         LDKu8slice ser_ref;
37729         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37730         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37731         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
37732         *ret_conv = OpenChannel_read(ser_ref);
37733         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37734         return (int64_t)ret_conv;
37735 }
37736
37737 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
37738         LDKRevokeAndACK obj_conv;
37739         obj_conv.inner = (void*)(obj & (~1));
37740         obj_conv.is_owned = false;
37741         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37742         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
37743         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37744         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37745         CVec_u8Z_free(ret_var);
37746         return ret_arr;
37747 }
37748
37749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37750         LDKu8slice ser_ref;
37751         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37752         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37753         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
37754         *ret_conv = RevokeAndACK_read(ser_ref);
37755         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37756         return (int64_t)ret_conv;
37757 }
37758
37759 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
37760         LDKShutdown obj_conv;
37761         obj_conv.inner = (void*)(obj & (~1));
37762         obj_conv.is_owned = false;
37763         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37764         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
37765         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37766         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37767         CVec_u8Z_free(ret_var);
37768         return ret_arr;
37769 }
37770
37771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37772         LDKu8slice ser_ref;
37773         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37774         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37775         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
37776         *ret_conv = Shutdown_read(ser_ref);
37777         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37778         return (int64_t)ret_conv;
37779 }
37780
37781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37782         LDKUpdateFailHTLC obj_conv;
37783         obj_conv.inner = (void*)(obj & (~1));
37784         obj_conv.is_owned = false;
37785         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37786         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
37787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37789         CVec_u8Z_free(ret_var);
37790         return ret_arr;
37791 }
37792
37793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37794         LDKu8slice ser_ref;
37795         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37796         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37797         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
37798         *ret_conv = UpdateFailHTLC_read(ser_ref);
37799         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37800         return (int64_t)ret_conv;
37801 }
37802
37803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37804         LDKUpdateFailMalformedHTLC obj_conv;
37805         obj_conv.inner = (void*)(obj & (~1));
37806         obj_conv.is_owned = false;
37807         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37808         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
37809         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37810         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37811         CVec_u8Z_free(ret_var);
37812         return ret_arr;
37813 }
37814
37815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37816         LDKu8slice ser_ref;
37817         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37818         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37819         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
37820         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
37821         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37822         return (int64_t)ret_conv;
37823 }
37824
37825 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
37826         LDKUpdateFee obj_conv;
37827         obj_conv.inner = (void*)(obj & (~1));
37828         obj_conv.is_owned = false;
37829         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37830         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
37831         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37832         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37833         CVec_u8Z_free(ret_var);
37834         return ret_arr;
37835 }
37836
37837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37838         LDKu8slice ser_ref;
37839         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37840         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37841         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
37842         *ret_conv = UpdateFee_read(ser_ref);
37843         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37844         return (int64_t)ret_conv;
37845 }
37846
37847 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37848         LDKUpdateFulfillHTLC obj_conv;
37849         obj_conv.inner = (void*)(obj & (~1));
37850         obj_conv.is_owned = false;
37851         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37852         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
37853         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37854         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37855         CVec_u8Z_free(ret_var);
37856         return ret_arr;
37857 }
37858
37859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37860         LDKu8slice ser_ref;
37861         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37862         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37863         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
37864         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
37865         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37866         return (int64_t)ret_conv;
37867 }
37868
37869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37870         LDKUpdateAddHTLC obj_conv;
37871         obj_conv.inner = (void*)(obj & (~1));
37872         obj_conv.is_owned = false;
37873         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37874         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
37875         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37876         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37877         CVec_u8Z_free(ret_var);
37878         return ret_arr;
37879 }
37880
37881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37882         LDKu8slice ser_ref;
37883         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37884         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37885         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
37886         *ret_conv = UpdateAddHTLC_read(ser_ref);
37887         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37888         return (int64_t)ret_conv;
37889 }
37890
37891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
37892         LDKPing obj_conv;
37893         obj_conv.inner = (void*)(obj & (~1));
37894         obj_conv.is_owned = false;
37895         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37896         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
37897         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37898         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37899         CVec_u8Z_free(ret_var);
37900         return ret_arr;
37901 }
37902
37903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37904         LDKu8slice ser_ref;
37905         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37906         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37907         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
37908         *ret_conv = Ping_read(ser_ref);
37909         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37910         return (int64_t)ret_conv;
37911 }
37912
37913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
37914         LDKPong obj_conv;
37915         obj_conv.inner = (void*)(obj & (~1));
37916         obj_conv.is_owned = false;
37917         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37918         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
37919         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37920         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37921         CVec_u8Z_free(ret_var);
37922         return ret_arr;
37923 }
37924
37925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37926         LDKu8slice ser_ref;
37927         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37928         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37929         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
37930         *ret_conv = Pong_read(ser_ref);
37931         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37932         return (int64_t)ret_conv;
37933 }
37934
37935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37936         LDKUnsignedChannelAnnouncement obj_conv;
37937         obj_conv.inner = (void*)(obj & (~1));
37938         obj_conv.is_owned = false;
37939         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37940         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
37941         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37942         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37943         CVec_u8Z_free(ret_var);
37944         return ret_arr;
37945 }
37946
37947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37948         LDKu8slice ser_ref;
37949         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37950         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37951         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
37952         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
37953         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37954         return (int64_t)ret_conv;
37955 }
37956
37957 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37958         LDKChannelAnnouncement obj_conv;
37959         obj_conv.inner = (void*)(obj & (~1));
37960         obj_conv.is_owned = false;
37961         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37962         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
37963         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37964         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37965         CVec_u8Z_free(ret_var);
37966         return ret_arr;
37967 }
37968
37969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37970         LDKu8slice ser_ref;
37971         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37972         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37973         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
37974         *ret_conv = ChannelAnnouncement_read(ser_ref);
37975         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37976         return (int64_t)ret_conv;
37977 }
37978
37979 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37980         LDKUnsignedChannelUpdate obj_conv;
37981         obj_conv.inner = (void*)(obj & (~1));
37982         obj_conv.is_owned = false;
37983         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37984         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
37985         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37986         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37987         CVec_u8Z_free(ret_var);
37988         return ret_arr;
37989 }
37990
37991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37992         LDKu8slice ser_ref;
37993         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37994         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37995         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
37996         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
37997         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37998         return (int64_t)ret_conv;
37999 }
38000
38001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
38002         LDKChannelUpdate obj_conv;
38003         obj_conv.inner = (void*)(obj & (~1));
38004         obj_conv.is_owned = false;
38005         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38006         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
38007         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38008         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38009         CVec_u8Z_free(ret_var);
38010         return ret_arr;
38011 }
38012
38013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38014         LDKu8slice ser_ref;
38015         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38016         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38017         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
38018         *ret_conv = ChannelUpdate_read(ser_ref);
38019         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38020         return (int64_t)ret_conv;
38021 }
38022
38023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38024         LDKErrorMessage obj_conv;
38025         obj_conv.inner = (void*)(obj & (~1));
38026         obj_conv.is_owned = false;
38027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38028         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
38029         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38030         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38031         CVec_u8Z_free(ret_var);
38032         return ret_arr;
38033 }
38034
38035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38036         LDKu8slice ser_ref;
38037         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38038         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38039         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
38040         *ret_conv = ErrorMessage_read(ser_ref);
38041         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38042         return (int64_t)ret_conv;
38043 }
38044
38045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38046         LDKWarningMessage obj_conv;
38047         obj_conv.inner = (void*)(obj & (~1));
38048         obj_conv.is_owned = false;
38049         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38050         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
38051         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38052         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38053         CVec_u8Z_free(ret_var);
38054         return ret_arr;
38055 }
38056
38057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38058         LDKu8slice ser_ref;
38059         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38060         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38061         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
38062         *ret_conv = WarningMessage_read(ser_ref);
38063         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38064         return (int64_t)ret_conv;
38065 }
38066
38067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
38068         LDKUnsignedNodeAnnouncement obj_conv;
38069         obj_conv.inner = (void*)(obj & (~1));
38070         obj_conv.is_owned = false;
38071         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38072         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
38073         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38074         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38075         CVec_u8Z_free(ret_var);
38076         return ret_arr;
38077 }
38078
38079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38080         LDKu8slice ser_ref;
38081         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38082         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38083         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
38084         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
38085         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38086         return (int64_t)ret_conv;
38087 }
38088
38089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
38090         LDKNodeAnnouncement obj_conv;
38091         obj_conv.inner = (void*)(obj & (~1));
38092         obj_conv.is_owned = false;
38093         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38094         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
38095         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38096         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38097         CVec_u8Z_free(ret_var);
38098         return ret_arr;
38099 }
38100
38101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38102         LDKu8slice ser_ref;
38103         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38104         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38105         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
38106         *ret_conv = NodeAnnouncement_read(ser_ref);
38107         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38108         return (int64_t)ret_conv;
38109 }
38110
38111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38112         LDKu8slice ser_ref;
38113         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38114         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38115         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
38116         *ret_conv = QueryShortChannelIds_read(ser_ref);
38117         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38118         return (int64_t)ret_conv;
38119 }
38120
38121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
38122         LDKQueryShortChannelIds obj_conv;
38123         obj_conv.inner = (void*)(obj & (~1));
38124         obj_conv.is_owned = false;
38125         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38126         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
38127         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38128         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38129         CVec_u8Z_free(ret_var);
38130         return ret_arr;
38131 }
38132
38133 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
38134         LDKReplyShortChannelIdsEnd obj_conv;
38135         obj_conv.inner = (void*)(obj & (~1));
38136         obj_conv.is_owned = false;
38137         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38138         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
38139         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38140         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38141         CVec_u8Z_free(ret_var);
38142         return ret_arr;
38143 }
38144
38145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38146         LDKu8slice ser_ref;
38147         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38148         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38149         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
38150         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
38151         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38152         return (int64_t)ret_conv;
38153 }
38154
38155 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
38156         LDKQueryChannelRange this_arg_conv;
38157         this_arg_conv.inner = (void*)(this_arg & (~1));
38158         this_arg_conv.is_owned = false;
38159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38160         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
38161         return ret_conv;
38162 }
38163
38164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38165         LDKQueryChannelRange obj_conv;
38166         obj_conv.inner = (void*)(obj & (~1));
38167         obj_conv.is_owned = false;
38168         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38169         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
38170         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38171         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38172         CVec_u8Z_free(ret_var);
38173         return ret_arr;
38174 }
38175
38176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38177         LDKu8slice ser_ref;
38178         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38179         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38180         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
38181         *ret_conv = QueryChannelRange_read(ser_ref);
38182         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38183         return (int64_t)ret_conv;
38184 }
38185
38186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38187         LDKu8slice ser_ref;
38188         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38189         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38190         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
38191         *ret_conv = ReplyChannelRange_read(ser_ref);
38192         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38193         return (int64_t)ret_conv;
38194 }
38195
38196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38197         LDKReplyChannelRange obj_conv;
38198         obj_conv.inner = (void*)(obj & (~1));
38199         obj_conv.is_owned = false;
38200         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38201         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
38202         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38203         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38204         CVec_u8Z_free(ret_var);
38205         return ret_arr;
38206 }
38207
38208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
38209         LDKGossipTimestampFilter obj_conv;
38210         obj_conv.inner = (void*)(obj & (~1));
38211         obj_conv.is_owned = false;
38212         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38213         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
38214         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38215         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38216         CVec_u8Z_free(ret_var);
38217         return ret_arr;
38218 }
38219
38220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38221         LDKu8slice ser_ref;
38222         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38223         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38224         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
38225         *ret_conv = GossipTimestampFilter_read(ser_ref);
38226         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38227         return (int64_t)ret_conv;
38228 }
38229
38230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38231         if ((this_ptr & 1) != 0) return;
38232         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38233         CHECK_ACCESS(this_ptr_ptr);
38234         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
38235         FREE((void*)this_ptr);
38236         CustomMessageHandler_free(this_ptr_conv);
38237 }
38238
38239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38240         LDKIgnoringMessageHandler this_obj_conv;
38241         this_obj_conv.inner = (void*)(this_obj & (~1));
38242         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38244         IgnoringMessageHandler_free(this_obj_conv);
38245 }
38246
38247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
38248         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
38249         int64_t ret_ref = 0;
38250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38253         ret_ref = (uintptr_t)ret_var.inner;
38254         if (ret_var.is_owned) {
38255                 ret_ref |= 1;
38256         }
38257         return ret_ref;
38258 }
38259
38260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38261         LDKIgnoringMessageHandler this_arg_conv;
38262         this_arg_conv.inner = (void*)(this_arg & (~1));
38263         this_arg_conv.is_owned = false;
38264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38265         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38266         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38267         return (int64_t)ret_ret;
38268 }
38269
38270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38271         LDKIgnoringMessageHandler this_arg_conv;
38272         this_arg_conv.inner = (void*)(this_arg & (~1));
38273         this_arg_conv.is_owned = false;
38274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38275         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
38276         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
38277         return (int64_t)ret_ret;
38278 }
38279
38280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
38281         LDKIgnoringMessageHandler this_arg_conv;
38282         this_arg_conv.inner = (void*)(this_arg & (~1));
38283         this_arg_conv.is_owned = false;
38284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38285         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
38286         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
38287         return (int64_t)ret_ret;
38288 }
38289
38290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38291         LDKIgnoringMessageHandler this_arg_conv;
38292         this_arg_conv.inner = (void*)(this_arg & (~1));
38293         this_arg_conv.is_owned = false;
38294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38295         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
38296         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
38297         return (int64_t)ret_ret;
38298 }
38299
38300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38301         LDKErroringMessageHandler this_obj_conv;
38302         this_obj_conv.inner = (void*)(this_obj & (~1));
38303         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38305         ErroringMessageHandler_free(this_obj_conv);
38306 }
38307
38308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
38309         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
38310         int64_t ret_ref = 0;
38311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38314         ret_ref = (uintptr_t)ret_var.inner;
38315         if (ret_var.is_owned) {
38316                 ret_ref |= 1;
38317         }
38318         return ret_ref;
38319 }
38320
38321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38322         LDKErroringMessageHandler this_arg_conv;
38323         this_arg_conv.inner = (void*)(this_arg & (~1));
38324         this_arg_conv.is_owned = false;
38325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38326         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38327         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38328         return (int64_t)ret_ret;
38329 }
38330
38331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38332         LDKErroringMessageHandler this_arg_conv;
38333         this_arg_conv.inner = (void*)(this_arg & (~1));
38334         this_arg_conv.is_owned = false;
38335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38336         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
38337         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
38338         return (int64_t)ret_ret;
38339 }
38340
38341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38342         LDKMessageHandler this_obj_conv;
38343         this_obj_conv.inner = (void*)(this_obj & (~1));
38344         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38346         MessageHandler_free(this_obj_conv);
38347 }
38348
38349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38350         LDKMessageHandler this_ptr_conv;
38351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38352         this_ptr_conv.is_owned = false;
38353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38354         // WARNING: This object doesn't live past this scope, needs clone!
38355         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
38356         return ret_ret;
38357 }
38358
38359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38360         LDKMessageHandler this_ptr_conv;
38361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38362         this_ptr_conv.is_owned = false;
38363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38364         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38365         CHECK_ACCESS(val_ptr);
38366         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
38367         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
38368                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38369                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
38370         }
38371         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
38372 }
38373
38374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38375         LDKMessageHandler this_ptr_conv;
38376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38377         this_ptr_conv.is_owned = false;
38378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38379         // WARNING: This object doesn't live past this scope, needs clone!
38380         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
38381         return ret_ret;
38382 }
38383
38384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38385         LDKMessageHandler this_ptr_conv;
38386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38387         this_ptr_conv.is_owned = false;
38388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38389         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38390         CHECK_ACCESS(val_ptr);
38391         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
38392         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38393                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38394                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
38395         }
38396         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
38397 }
38398
38399 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) {
38400         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
38401         CHECK_ACCESS(chan_handler_arg_ptr);
38402         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
38403         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
38404                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38405                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
38406         }
38407         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
38408         CHECK_ACCESS(route_handler_arg_ptr);
38409         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
38410         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38411                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38412                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
38413         }
38414         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
38415         int64_t ret_ref = 0;
38416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38419         ret_ref = (uintptr_t)ret_var.inner;
38420         if (ret_var.is_owned) {
38421                 ret_ref |= 1;
38422         }
38423         return ret_ref;
38424 }
38425
38426 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
38427         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38428         *ret_ret = SocketDescriptor_clone(arg);
38429         return (int64_t)ret_ret;
38430 }
38431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38432         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
38433         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
38434         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
38435         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
38436         return ret_conv;
38437 }
38438
38439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38440         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
38441         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
38442         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
38443         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38444         *ret_ret = SocketDescriptor_clone(orig_conv);
38445         return (int64_t)ret_ret;
38446 }
38447
38448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38449         if ((this_ptr & 1) != 0) return;
38450         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38451         CHECK_ACCESS(this_ptr_ptr);
38452         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
38453         FREE((void*)this_ptr);
38454         SocketDescriptor_free(this_ptr_conv);
38455 }
38456
38457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38458         LDKPeerHandleError this_obj_conv;
38459         this_obj_conv.inner = (void*)(this_obj & (~1));
38460         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38462         PeerHandleError_free(this_obj_conv);
38463 }
38464
38465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
38466         LDKPeerHandleError this_ptr_conv;
38467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38468         this_ptr_conv.is_owned = false;
38469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38470         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
38471         return ret_conv;
38472 }
38473
38474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38475         LDKPeerHandleError this_ptr_conv;
38476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38477         this_ptr_conv.is_owned = false;
38478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38479         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
38480 }
38481
38482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
38483         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
38484         int64_t ret_ref = 0;
38485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38488         ret_ref = (uintptr_t)ret_var.inner;
38489         if (ret_var.is_owned) {
38490                 ret_ref |= 1;
38491         }
38492         return ret_ref;
38493 }
38494
38495 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
38496         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
38497 int64_t ret_ref = 0;
38498 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38499 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38500 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38501 ret_ref = (uintptr_t)ret_var.inner;
38502 if (ret_var.is_owned) {
38503         ret_ref |= 1;
38504 }
38505         return ret_ref;
38506 }
38507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38508         LDKPeerHandleError arg_conv;
38509         arg_conv.inner = (void*)(arg & (~1));
38510         arg_conv.is_owned = false;
38511         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38512         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
38513         return ret_conv;
38514 }
38515
38516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38517         LDKPeerHandleError orig_conv;
38518         orig_conv.inner = (void*)(orig & (~1));
38519         orig_conv.is_owned = false;
38520         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38521         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
38522         int64_t ret_ref = 0;
38523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38526         ret_ref = (uintptr_t)ret_var.inner;
38527         if (ret_var.is_owned) {
38528                 ret_ref |= 1;
38529         }
38530         return ret_ref;
38531 }
38532
38533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38534         LDKPeerManager this_obj_conv;
38535         this_obj_conv.inner = (void*)(this_obj & (~1));
38536         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38538         PeerManager_free(this_obj_conv);
38539 }
38540
38541 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) {
38542         LDKMessageHandler message_handler_conv;
38543         message_handler_conv.inner = (void*)(message_handler & (~1));
38544         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
38545         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
38546         // WARNING: we need a move here but no clone is available for LDKMessageHandler
38547         LDKSecretKey our_node_secret_ref;
38548         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
38549         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
38550         unsigned char ephemeral_random_data_arr[32];
38551         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
38552         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
38553         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
38554         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38555         CHECK_ACCESS(logger_ptr);
38556         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38557         if (logger_conv.free == LDKLogger_JCalls_free) {
38558                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38559                 LDKLogger_JCalls_cloned(&logger_conv);
38560         }
38561         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
38562         CHECK_ACCESS(custom_message_handler_ptr);
38563         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
38564         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
38565                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38566                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
38567         }
38568         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
38569         int64_t ret_ref = 0;
38570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38573         ret_ref = (uintptr_t)ret_var.inner;
38574         if (ret_var.is_owned) {
38575                 ret_ref |= 1;
38576         }
38577         return ret_ref;
38578 }
38579
38580 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
38581         LDKPeerManager this_arg_conv;
38582         this_arg_conv.inner = (void*)(this_arg & (~1));
38583         this_arg_conv.is_owned = false;
38584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38585         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
38586         jobjectArray ret_arr = NULL;
38587         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
38588         ;
38589         for (size_t i = 0; i < ret_var.datalen; i++) {
38590                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
38591                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
38592                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
38593         }
38594         
38595         FREE(ret_var.data);
38596         return ret_arr;
38597 }
38598
38599 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) {
38600         LDKPeerManager this_arg_conv;
38601         this_arg_conv.inner = (void*)(this_arg & (~1));
38602         this_arg_conv.is_owned = false;
38603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38604         LDKPublicKey their_node_id_ref;
38605         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
38606         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
38607         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38608         CHECK_ACCESS(descriptor_ptr);
38609         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
38610         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
38611                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38612                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
38613         }
38614         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
38615         CHECK_ACCESS(remote_network_address_ptr);
38616         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
38617         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
38618         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
38619         return (int64_t)ret_conv;
38620 }
38621
38622 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) {
38623         LDKPeerManager this_arg_conv;
38624         this_arg_conv.inner = (void*)(this_arg & (~1));
38625         this_arg_conv.is_owned = false;
38626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38627         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38628         CHECK_ACCESS(descriptor_ptr);
38629         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
38630         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
38631                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38632                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
38633         }
38634         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
38635         CHECK_ACCESS(remote_network_address_ptr);
38636         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
38637         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
38638         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
38639         return (int64_t)ret_conv;
38640 }
38641
38642 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) {
38643         LDKPeerManager this_arg_conv;
38644         this_arg_conv.inner = (void*)(this_arg & (~1));
38645         this_arg_conv.is_owned = false;
38646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38647         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38648         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
38649         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
38650         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
38651         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
38652         return (int64_t)ret_conv;
38653 }
38654
38655 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) {
38656         LDKPeerManager this_arg_conv;
38657         this_arg_conv.inner = (void*)(this_arg & (~1));
38658         this_arg_conv.is_owned = false;
38659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38660         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
38661         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
38662         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
38663         LDKu8slice data_ref;
38664         data_ref.datalen = (*env)->GetArrayLength(env, data);
38665         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
38666         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
38667         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
38668         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
38669         return (int64_t)ret_conv;
38670 }
38671
38672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
38673         LDKPeerManager this_arg_conv;
38674         this_arg_conv.inner = (void*)(this_arg & (~1));
38675         this_arg_conv.is_owned = false;
38676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38677         PeerManager_process_events(&this_arg_conv);
38678 }
38679
38680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
38681         LDKPeerManager this_arg_conv;
38682         this_arg_conv.inner = (void*)(this_arg & (~1));
38683         this_arg_conv.is_owned = false;
38684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38685         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38686         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
38687         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
38688         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
38689 }
38690
38691 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) {
38692         LDKPeerManager this_arg_conv;
38693         this_arg_conv.inner = (void*)(this_arg & (~1));
38694         this_arg_conv.is_owned = false;
38695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38696         LDKPublicKey node_id_ref;
38697         CHECK((*env)->GetArrayLength(env, node_id) == 33);
38698         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
38699         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
38700 }
38701
38702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
38703         LDKPeerManager this_arg_conv;
38704         this_arg_conv.inner = (void*)(this_arg & (~1));
38705         this_arg_conv.is_owned = false;
38706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38707         PeerManager_disconnect_all_peers(&this_arg_conv);
38708 }
38709
38710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
38711         LDKPeerManager this_arg_conv;
38712         this_arg_conv.inner = (void*)(this_arg & (~1));
38713         this_arg_conv.is_owned = false;
38714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38715         PeerManager_timer_tick_occurred(&this_arg_conv);
38716 }
38717
38718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
38719         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
38720         return ret_conv;
38721 }
38722
38723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
38724         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
38725         return ret_conv;
38726 }
38727
38728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
38729         unsigned char commitment_seed_arr[32];
38730         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
38731         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
38732         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
38733         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38734         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
38735         return ret_arr;
38736 }
38737
38738 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) {
38739         LDKCVec_u8Z to_holder_script_ref;
38740         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
38741         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
38742         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
38743         LDKCVec_u8Z to_counterparty_script_ref;
38744         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
38745         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
38746         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
38747         LDKOutPoint funding_outpoint_conv;
38748         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38749         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38750         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38751         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38752         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);
38753         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38754         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38755         Transaction_free(ret_var);
38756         return ret_arr;
38757 }
38758
38759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38760         LDKCounterpartyCommitmentSecrets this_obj_conv;
38761         this_obj_conv.inner = (void*)(this_obj & (~1));
38762         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38764         CounterpartyCommitmentSecrets_free(this_obj_conv);
38765 }
38766
38767 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
38768         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
38769 int64_t ret_ref = 0;
38770 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38771 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38772 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38773 ret_ref = (uintptr_t)ret_var.inner;
38774 if (ret_var.is_owned) {
38775         ret_ref |= 1;
38776 }
38777         return ret_ref;
38778 }
38779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38780         LDKCounterpartyCommitmentSecrets arg_conv;
38781         arg_conv.inner = (void*)(arg & (~1));
38782         arg_conv.is_owned = false;
38783         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38784         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
38785         return ret_conv;
38786 }
38787
38788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38789         LDKCounterpartyCommitmentSecrets orig_conv;
38790         orig_conv.inner = (void*)(orig & (~1));
38791         orig_conv.is_owned = false;
38792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38793         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
38794         int64_t ret_ref = 0;
38795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38798         ret_ref = (uintptr_t)ret_var.inner;
38799         if (ret_var.is_owned) {
38800                 ret_ref |= 1;
38801         }
38802         return ret_ref;
38803 }
38804
38805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
38806         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
38807         int64_t ret_ref = 0;
38808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38811         ret_ref = (uintptr_t)ret_var.inner;
38812         if (ret_var.is_owned) {
38813                 ret_ref |= 1;
38814         }
38815         return ret_ref;
38816 }
38817
38818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
38819         LDKCounterpartyCommitmentSecrets this_arg_conv;
38820         this_arg_conv.inner = (void*)(this_arg & (~1));
38821         this_arg_conv.is_owned = false;
38822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38823         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
38824         return ret_conv;
38825 }
38826
38827 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) {
38828         LDKCounterpartyCommitmentSecrets this_arg_conv;
38829         this_arg_conv.inner = (void*)(this_arg & (~1));
38830         this_arg_conv.is_owned = false;
38831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38832         LDKThirtyTwoBytes secret_ref;
38833         CHECK((*env)->GetArrayLength(env, secret) == 32);
38834         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
38835         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
38836         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
38837         return (int64_t)ret_conv;
38838 }
38839
38840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
38841         LDKCounterpartyCommitmentSecrets this_arg_conv;
38842         this_arg_conv.inner = (void*)(this_arg & (~1));
38843         this_arg_conv.is_owned = false;
38844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38845         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38846         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
38847         return ret_arr;
38848 }
38849
38850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
38851         LDKCounterpartyCommitmentSecrets obj_conv;
38852         obj_conv.inner = (void*)(obj & (~1));
38853         obj_conv.is_owned = false;
38854         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38855         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
38856         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38857         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38858         CVec_u8Z_free(ret_var);
38859         return ret_arr;
38860 }
38861
38862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38863         LDKu8slice ser_ref;
38864         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38865         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38866         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
38867         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
38868         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38869         return (int64_t)ret_conv;
38870 }
38871
38872 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) {
38873         LDKPublicKey per_commitment_point_ref;
38874         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38875         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38876         unsigned char base_secret_arr[32];
38877         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
38878         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
38879         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
38880         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38881         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
38882         return (int64_t)ret_conv;
38883 }
38884
38885 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) {
38886         LDKPublicKey per_commitment_point_ref;
38887         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38888         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38889         LDKPublicKey base_point_ref;
38890         CHECK((*env)->GetArrayLength(env, base_point) == 33);
38891         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
38892         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38893         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
38894         return (int64_t)ret_conv;
38895 }
38896
38897 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) {
38898         unsigned char per_commitment_secret_arr[32];
38899         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
38900         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
38901         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
38902         unsigned char countersignatory_revocation_base_secret_arr[32];
38903         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
38904         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
38905         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
38906         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38907         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
38908         return (int64_t)ret_conv;
38909 }
38910
38911 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) {
38912         LDKPublicKey per_commitment_point_ref;
38913         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38914         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38915         LDKPublicKey countersignatory_revocation_base_point_ref;
38916         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
38917         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
38918         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38919         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
38920         return (int64_t)ret_conv;
38921 }
38922
38923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38924         LDKTxCreationKeys this_obj_conv;
38925         this_obj_conv.inner = (void*)(this_obj & (~1));
38926         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38928         TxCreationKeys_free(this_obj_conv);
38929 }
38930
38931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
38932         LDKTxCreationKeys this_ptr_conv;
38933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38934         this_ptr_conv.is_owned = false;
38935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38936         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
38938         return ret_arr;
38939 }
38940
38941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38942         LDKTxCreationKeys this_ptr_conv;
38943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38944         this_ptr_conv.is_owned = false;
38945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38946         LDKPublicKey val_ref;
38947         CHECK((*env)->GetArrayLength(env, val) == 33);
38948         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38949         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
38950 }
38951
38952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38953         LDKTxCreationKeys this_ptr_conv;
38954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38955         this_ptr_conv.is_owned = false;
38956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38957         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38958         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
38959         return ret_arr;
38960 }
38961
38962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38963         LDKTxCreationKeys this_ptr_conv;
38964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38965         this_ptr_conv.is_owned = false;
38966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38967         LDKPublicKey val_ref;
38968         CHECK((*env)->GetArrayLength(env, val) == 33);
38969         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38970         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
38971 }
38972
38973 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38974         LDKTxCreationKeys this_ptr_conv;
38975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38976         this_ptr_conv.is_owned = false;
38977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38978         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38979         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
38980         return ret_arr;
38981 }
38982
38983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38984         LDKTxCreationKeys this_ptr_conv;
38985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38986         this_ptr_conv.is_owned = false;
38987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38988         LDKPublicKey val_ref;
38989         CHECK((*env)->GetArrayLength(env, val) == 33);
38990         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38991         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
38992 }
38993
38994 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38995         LDKTxCreationKeys this_ptr_conv;
38996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38997         this_ptr_conv.is_owned = false;
38998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38999         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39000         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
39001         return ret_arr;
39002 }
39003
39004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39005         LDKTxCreationKeys this_ptr_conv;
39006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39007         this_ptr_conv.is_owned = false;
39008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39009         LDKPublicKey val_ref;
39010         CHECK((*env)->GetArrayLength(env, val) == 33);
39011         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39012         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
39013 }
39014
39015 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
39016         LDKTxCreationKeys this_ptr_conv;
39017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39018         this_ptr_conv.is_owned = false;
39019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39020         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39021         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
39022         return ret_arr;
39023 }
39024
39025 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) {
39026         LDKTxCreationKeys this_ptr_conv;
39027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39028         this_ptr_conv.is_owned = false;
39029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39030         LDKPublicKey val_ref;
39031         CHECK((*env)->GetArrayLength(env, val) == 33);
39032         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39033         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
39034 }
39035
39036 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) {
39037         LDKPublicKey per_commitment_point_arg_ref;
39038         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
39039         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
39040         LDKPublicKey revocation_key_arg_ref;
39041         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
39042         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
39043         LDKPublicKey broadcaster_htlc_key_arg_ref;
39044         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
39045         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
39046         LDKPublicKey countersignatory_htlc_key_arg_ref;
39047         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
39048         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
39049         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
39050         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
39051         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
39052         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);
39053         int64_t ret_ref = 0;
39054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39057         ret_ref = (uintptr_t)ret_var.inner;
39058         if (ret_var.is_owned) {
39059                 ret_ref |= 1;
39060         }
39061         return ret_ref;
39062 }
39063
39064 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
39065         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
39066 int64_t ret_ref = 0;
39067 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39068 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39069 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39070 ret_ref = (uintptr_t)ret_var.inner;
39071 if (ret_var.is_owned) {
39072         ret_ref |= 1;
39073 }
39074         return ret_ref;
39075 }
39076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39077         LDKTxCreationKeys arg_conv;
39078         arg_conv.inner = (void*)(arg & (~1));
39079         arg_conv.is_owned = false;
39080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39081         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
39082         return ret_conv;
39083 }
39084
39085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39086         LDKTxCreationKeys orig_conv;
39087         orig_conv.inner = (void*)(orig & (~1));
39088         orig_conv.is_owned = false;
39089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39090         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
39091         int64_t ret_ref = 0;
39092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39095         ret_ref = (uintptr_t)ret_var.inner;
39096         if (ret_var.is_owned) {
39097                 ret_ref |= 1;
39098         }
39099         return ret_ref;
39100 }
39101
39102 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
39103         LDKTxCreationKeys obj_conv;
39104         obj_conv.inner = (void*)(obj & (~1));
39105         obj_conv.is_owned = false;
39106         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39107         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
39108         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39109         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39110         CVec_u8Z_free(ret_var);
39111         return ret_arr;
39112 }
39113
39114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39115         LDKu8slice ser_ref;
39116         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39117         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39118         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
39119         *ret_conv = TxCreationKeys_read(ser_ref);
39120         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39121         return (int64_t)ret_conv;
39122 }
39123
39124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39125         LDKChannelPublicKeys this_obj_conv;
39126         this_obj_conv.inner = (void*)(this_obj & (~1));
39127         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39129         ChannelPublicKeys_free(this_obj_conv);
39130 }
39131
39132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
39133         LDKChannelPublicKeys this_ptr_conv;
39134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39135         this_ptr_conv.is_owned = false;
39136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39137         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39138         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
39139         return ret_arr;
39140 }
39141
39142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39143         LDKChannelPublicKeys this_ptr_conv;
39144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39145         this_ptr_conv.is_owned = false;
39146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39147         LDKPublicKey val_ref;
39148         CHECK((*env)->GetArrayLength(env, val) == 33);
39149         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39150         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
39151 }
39152
39153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39154         LDKChannelPublicKeys this_ptr_conv;
39155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39156         this_ptr_conv.is_owned = false;
39157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39158         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39159         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
39160         return ret_arr;
39161 }
39162
39163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39164         LDKChannelPublicKeys this_ptr_conv;
39165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39166         this_ptr_conv.is_owned = false;
39167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39168         LDKPublicKey val_ref;
39169         CHECK((*env)->GetArrayLength(env, val) == 33);
39170         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39171         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
39172 }
39173
39174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
39175         LDKChannelPublicKeys this_ptr_conv;
39176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39177         this_ptr_conv.is_owned = false;
39178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39179         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39180         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
39181         return ret_arr;
39182 }
39183
39184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39185         LDKChannelPublicKeys this_ptr_conv;
39186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39187         this_ptr_conv.is_owned = false;
39188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39189         LDKPublicKey val_ref;
39190         CHECK((*env)->GetArrayLength(env, val) == 33);
39191         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39192         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
39193 }
39194
39195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39196         LDKChannelPublicKeys this_ptr_conv;
39197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39198         this_ptr_conv.is_owned = false;
39199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39200         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
39202         return ret_arr;
39203 }
39204
39205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39206         LDKChannelPublicKeys this_ptr_conv;
39207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39208         this_ptr_conv.is_owned = false;
39209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39210         LDKPublicKey val_ref;
39211         CHECK((*env)->GetArrayLength(env, val) == 33);
39212         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39213         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
39214 }
39215
39216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39217         LDKChannelPublicKeys this_ptr_conv;
39218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39219         this_ptr_conv.is_owned = false;
39220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39221         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39222         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
39223         return ret_arr;
39224 }
39225
39226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39227         LDKChannelPublicKeys this_ptr_conv;
39228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39229         this_ptr_conv.is_owned = false;
39230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39231         LDKPublicKey val_ref;
39232         CHECK((*env)->GetArrayLength(env, val) == 33);
39233         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39234         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
39235 }
39236
39237 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) {
39238         LDKPublicKey funding_pubkey_arg_ref;
39239         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
39240         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
39241         LDKPublicKey revocation_basepoint_arg_ref;
39242         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
39243         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
39244         LDKPublicKey payment_point_arg_ref;
39245         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
39246         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
39247         LDKPublicKey delayed_payment_basepoint_arg_ref;
39248         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
39249         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
39250         LDKPublicKey htlc_basepoint_arg_ref;
39251         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
39252         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
39253         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);
39254         int64_t ret_ref = 0;
39255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39258         ret_ref = (uintptr_t)ret_var.inner;
39259         if (ret_var.is_owned) {
39260                 ret_ref |= 1;
39261         }
39262         return ret_ref;
39263 }
39264
39265 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
39266         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
39267 int64_t ret_ref = 0;
39268 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39269 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39270 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39271 ret_ref = (uintptr_t)ret_var.inner;
39272 if (ret_var.is_owned) {
39273         ret_ref |= 1;
39274 }
39275         return ret_ref;
39276 }
39277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39278         LDKChannelPublicKeys arg_conv;
39279         arg_conv.inner = (void*)(arg & (~1));
39280         arg_conv.is_owned = false;
39281         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39282         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
39283         return ret_conv;
39284 }
39285
39286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39287         LDKChannelPublicKeys orig_conv;
39288         orig_conv.inner = (void*)(orig & (~1));
39289         orig_conv.is_owned = false;
39290         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39291         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
39292         int64_t ret_ref = 0;
39293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39296         ret_ref = (uintptr_t)ret_var.inner;
39297         if (ret_var.is_owned) {
39298                 ret_ref |= 1;
39299         }
39300         return ret_ref;
39301 }
39302
39303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
39304         LDKChannelPublicKeys obj_conv;
39305         obj_conv.inner = (void*)(obj & (~1));
39306         obj_conv.is_owned = false;
39307         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39308         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
39309         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39310         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39311         CVec_u8Z_free(ret_var);
39312         return ret_arr;
39313 }
39314
39315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39316         LDKu8slice ser_ref;
39317         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39318         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39319         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
39320         *ret_conv = ChannelPublicKeys_read(ser_ref);
39321         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39322         return (int64_t)ret_conv;
39323 }
39324
39325 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) {
39326         LDKPublicKey per_commitment_point_ref;
39327         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39328         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39329         LDKPublicKey broadcaster_delayed_payment_base_ref;
39330         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
39331         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
39332         LDKPublicKey broadcaster_htlc_base_ref;
39333         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
39334         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
39335         LDKPublicKey countersignatory_revocation_base_ref;
39336         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
39337         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
39338         LDKPublicKey countersignatory_htlc_base_ref;
39339         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
39340         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
39341         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39342         *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);
39343         return (int64_t)ret_conv;
39344 }
39345
39346 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) {
39347         LDKPublicKey per_commitment_point_ref;
39348         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39349         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39350         LDKChannelPublicKeys broadcaster_keys_conv;
39351         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
39352         broadcaster_keys_conv.is_owned = false;
39353         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
39354         LDKChannelPublicKeys countersignatory_keys_conv;
39355         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
39356         countersignatory_keys_conv.is_owned = false;
39357         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
39358         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39359         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
39360         return (int64_t)ret_conv;
39361 }
39362
39363 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) {
39364         LDKPublicKey revocation_key_ref;
39365         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
39366         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
39367         LDKPublicKey broadcaster_delayed_payment_key_ref;
39368         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
39369         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
39370         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
39371         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39372         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39373         CVec_u8Z_free(ret_var);
39374         return ret_arr;
39375 }
39376
39377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39378         LDKHTLCOutputInCommitment this_obj_conv;
39379         this_obj_conv.inner = (void*)(this_obj & (~1));
39380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39382         HTLCOutputInCommitment_free(this_obj_conv);
39383 }
39384
39385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
39386         LDKHTLCOutputInCommitment this_ptr_conv;
39387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39388         this_ptr_conv.is_owned = false;
39389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39390         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
39391         return ret_conv;
39392 }
39393
39394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39395         LDKHTLCOutputInCommitment this_ptr_conv;
39396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39397         this_ptr_conv.is_owned = false;
39398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39399         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
39400 }
39401
39402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39403         LDKHTLCOutputInCommitment this_ptr_conv;
39404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39405         this_ptr_conv.is_owned = false;
39406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39407         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
39408         return ret_conv;
39409 }
39410
39411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39412         LDKHTLCOutputInCommitment this_ptr_conv;
39413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39414         this_ptr_conv.is_owned = false;
39415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39416         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
39417 }
39418
39419 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
39420         LDKHTLCOutputInCommitment this_ptr_conv;
39421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39422         this_ptr_conv.is_owned = false;
39423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39424         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
39425         return ret_conv;
39426 }
39427
39428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39429         LDKHTLCOutputInCommitment this_ptr_conv;
39430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39431         this_ptr_conv.is_owned = false;
39432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39433         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
39434 }
39435
39436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39437         LDKHTLCOutputInCommitment this_ptr_conv;
39438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39439         this_ptr_conv.is_owned = false;
39440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39441         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39442         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
39443         return ret_arr;
39444 }
39445
39446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39447         LDKHTLCOutputInCommitment this_ptr_conv;
39448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39449         this_ptr_conv.is_owned = false;
39450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39451         LDKThirtyTwoBytes val_ref;
39452         CHECK((*env)->GetArrayLength(env, val) == 32);
39453         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39454         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
39455 }
39456
39457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
39458         LDKHTLCOutputInCommitment this_ptr_conv;
39459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39460         this_ptr_conv.is_owned = false;
39461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39462         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
39463         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
39464         int64_t ret_ref = (uintptr_t)ret_copy;
39465         return ret_ref;
39466 }
39467
39468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39469         LDKHTLCOutputInCommitment this_ptr_conv;
39470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39471         this_ptr_conv.is_owned = false;
39472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39473         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39474         CHECK_ACCESS(val_ptr);
39475         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
39476         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
39477         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
39478 }
39479
39480 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) {
39481         LDKThirtyTwoBytes payment_hash_arg_ref;
39482         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
39483         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
39484         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
39485         CHECK_ACCESS(transaction_output_index_arg_ptr);
39486         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
39487         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
39488         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
39489         int64_t ret_ref = 0;
39490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39493         ret_ref = (uintptr_t)ret_var.inner;
39494         if (ret_var.is_owned) {
39495                 ret_ref |= 1;
39496         }
39497         return ret_ref;
39498 }
39499
39500 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
39501         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
39502 int64_t ret_ref = 0;
39503 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39504 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39505 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39506 ret_ref = (uintptr_t)ret_var.inner;
39507 if (ret_var.is_owned) {
39508         ret_ref |= 1;
39509 }
39510         return ret_ref;
39511 }
39512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39513         LDKHTLCOutputInCommitment arg_conv;
39514         arg_conv.inner = (void*)(arg & (~1));
39515         arg_conv.is_owned = false;
39516         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39517         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
39518         return ret_conv;
39519 }
39520
39521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39522         LDKHTLCOutputInCommitment orig_conv;
39523         orig_conv.inner = (void*)(orig & (~1));
39524         orig_conv.is_owned = false;
39525         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39526         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
39527         int64_t ret_ref = 0;
39528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39531         ret_ref = (uintptr_t)ret_var.inner;
39532         if (ret_var.is_owned) {
39533                 ret_ref |= 1;
39534         }
39535         return ret_ref;
39536 }
39537
39538 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
39539         LDKHTLCOutputInCommitment obj_conv;
39540         obj_conv.inner = (void*)(obj & (~1));
39541         obj_conv.is_owned = false;
39542         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39543         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
39544         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39545         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39546         CVec_u8Z_free(ret_var);
39547         return ret_arr;
39548 }
39549
39550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39551         LDKu8slice ser_ref;
39552         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39553         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39554         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
39555         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
39556         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39557         return (int64_t)ret_conv;
39558 }
39559
39560 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) {
39561         LDKHTLCOutputInCommitment htlc_conv;
39562         htlc_conv.inner = (void*)(htlc & (~1));
39563         htlc_conv.is_owned = false;
39564         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
39565         LDKTxCreationKeys keys_conv;
39566         keys_conv.inner = (void*)(keys & (~1));
39567         keys_conv.is_owned = false;
39568         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
39569         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
39570         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39571         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39572         CVec_u8Z_free(ret_var);
39573         return ret_arr;
39574 }
39575
39576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
39577         LDKPublicKey broadcaster_ref;
39578         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
39579         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
39580         LDKPublicKey countersignatory_ref;
39581         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
39582         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
39583         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
39584         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39585         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39586         CVec_u8Z_free(ret_var);
39587         return ret_arr;
39588 }
39589
39590 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) {
39591         unsigned char commitment_txid_arr[32];
39592         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
39593         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
39594         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
39595         LDKHTLCOutputInCommitment htlc_conv;
39596         htlc_conv.inner = (void*)(htlc & (~1));
39597         htlc_conv.is_owned = false;
39598         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
39599         LDKPublicKey broadcaster_delayed_payment_key_ref;
39600         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
39601         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
39602         LDKPublicKey revocation_key_ref;
39603         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
39604         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
39605         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);
39606         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39607         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39608         Transaction_free(ret_var);
39609         return ret_arr;
39610 }
39611
39612 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
39613         LDKPublicKey funding_pubkey_ref;
39614         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
39615         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
39616         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
39617         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39618         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39619         CVec_u8Z_free(ret_var);
39620         return ret_arr;
39621 }
39622
39623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39624         LDKChannelTransactionParameters this_obj_conv;
39625         this_obj_conv.inner = (void*)(this_obj & (~1));
39626         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39628         ChannelTransactionParameters_free(this_obj_conv);
39629 }
39630
39631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39632         LDKChannelTransactionParameters this_ptr_conv;
39633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39634         this_ptr_conv.is_owned = false;
39635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39636         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
39637         int64_t ret_ref = 0;
39638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39641         ret_ref = (uintptr_t)ret_var.inner;
39642         if (ret_var.is_owned) {
39643                 ret_ref |= 1;
39644         }
39645         return ret_ref;
39646 }
39647
39648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39649         LDKChannelTransactionParameters this_ptr_conv;
39650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39651         this_ptr_conv.is_owned = false;
39652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39653         LDKChannelPublicKeys val_conv;
39654         val_conv.inner = (void*)(val & (~1));
39655         val_conv.is_owned = (val & 1) || (val == 0);
39656         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39657         val_conv = ChannelPublicKeys_clone(&val_conv);
39658         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
39659 }
39660
39661 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39662         LDKChannelTransactionParameters this_ptr_conv;
39663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39664         this_ptr_conv.is_owned = false;
39665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39666         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
39667         return ret_conv;
39668 }
39669
39670 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) {
39671         LDKChannelTransactionParameters this_ptr_conv;
39672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39673         this_ptr_conv.is_owned = false;
39674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39675         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
39676 }
39677
39678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
39679         LDKChannelTransactionParameters this_ptr_conv;
39680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39681         this_ptr_conv.is_owned = false;
39682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39683         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
39684         return ret_conv;
39685 }
39686
39687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39688         LDKChannelTransactionParameters this_ptr_conv;
39689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39690         this_ptr_conv.is_owned = false;
39691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39692         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
39693 }
39694
39695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
39696         LDKChannelTransactionParameters this_ptr_conv;
39697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39698         this_ptr_conv.is_owned = false;
39699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39700         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
39701         int64_t ret_ref = 0;
39702         if ((uintptr_t)ret_var.inner > 4096) {
39703                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39704                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39706                 ret_ref = (uintptr_t)ret_var.inner;
39707                 if (ret_var.is_owned) {
39708                         ret_ref |= 1;
39709                 }
39710         }
39711         return ret_ref;
39712 }
39713
39714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39715         LDKChannelTransactionParameters this_ptr_conv;
39716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39717         this_ptr_conv.is_owned = false;
39718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39719         LDKCounterpartyChannelTransactionParameters val_conv;
39720         val_conv.inner = (void*)(val & (~1));
39721         val_conv.is_owned = (val & 1) || (val == 0);
39722         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39723         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
39724         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
39725 }
39726
39727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39728         LDKChannelTransactionParameters this_ptr_conv;
39729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39730         this_ptr_conv.is_owned = false;
39731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39732         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
39733         int64_t ret_ref = 0;
39734         if ((uintptr_t)ret_var.inner > 4096) {
39735                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39736                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39738                 ret_ref = (uintptr_t)ret_var.inner;
39739                 if (ret_var.is_owned) {
39740                         ret_ref |= 1;
39741                 }
39742         }
39743         return ret_ref;
39744 }
39745
39746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39747         LDKChannelTransactionParameters this_ptr_conv;
39748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39749         this_ptr_conv.is_owned = false;
39750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39751         LDKOutPoint val_conv;
39752         val_conv.inner = (void*)(val & (~1));
39753         val_conv.is_owned = (val & 1) || (val == 0);
39754         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39755         val_conv = OutPoint_clone(&val_conv);
39756         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
39757 }
39758
39759 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
39760         LDKChannelTransactionParameters this_ptr_conv;
39761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39762         this_ptr_conv.is_owned = false;
39763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39764         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
39765         return ret_conv;
39766 }
39767
39768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
39769         LDKChannelTransactionParameters this_ptr_conv;
39770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39771         this_ptr_conv.is_owned = false;
39772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39773         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
39774         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
39775 }
39776
39777 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) {
39778         LDKChannelPublicKeys holder_pubkeys_arg_conv;
39779         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
39780         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
39781         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
39782         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
39783         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
39784         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
39785         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
39786         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
39787         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
39788         LDKOutPoint funding_outpoint_arg_conv;
39789         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
39790         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
39791         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
39792         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
39793         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
39794         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);
39795         int64_t ret_ref = 0;
39796         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39797         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39799         ret_ref = (uintptr_t)ret_var.inner;
39800         if (ret_var.is_owned) {
39801                 ret_ref |= 1;
39802         }
39803         return ret_ref;
39804 }
39805
39806 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
39807         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
39808 int64_t ret_ref = 0;
39809 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39810 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39811 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39812 ret_ref = (uintptr_t)ret_var.inner;
39813 if (ret_var.is_owned) {
39814         ret_ref |= 1;
39815 }
39816         return ret_ref;
39817 }
39818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39819         LDKChannelTransactionParameters arg_conv;
39820         arg_conv.inner = (void*)(arg & (~1));
39821         arg_conv.is_owned = false;
39822         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39823         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
39824         return ret_conv;
39825 }
39826
39827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39828         LDKChannelTransactionParameters orig_conv;
39829         orig_conv.inner = (void*)(orig & (~1));
39830         orig_conv.is_owned = false;
39831         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39832         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
39833         int64_t ret_ref = 0;
39834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39837         ret_ref = (uintptr_t)ret_var.inner;
39838         if (ret_var.is_owned) {
39839                 ret_ref |= 1;
39840         }
39841         return ret_ref;
39842 }
39843
39844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39845         LDKCounterpartyChannelTransactionParameters this_obj_conv;
39846         this_obj_conv.inner = (void*)(this_obj & (~1));
39847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39849         CounterpartyChannelTransactionParameters_free(this_obj_conv);
39850 }
39851
39852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39853         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39855         this_ptr_conv.is_owned = false;
39856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39857         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
39858         int64_t ret_ref = 0;
39859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39862         ret_ref = (uintptr_t)ret_var.inner;
39863         if (ret_var.is_owned) {
39864                 ret_ref |= 1;
39865         }
39866         return ret_ref;
39867 }
39868
39869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39870         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39872         this_ptr_conv.is_owned = false;
39873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39874         LDKChannelPublicKeys val_conv;
39875         val_conv.inner = (void*)(val & (~1));
39876         val_conv.is_owned = (val & 1) || (val == 0);
39877         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39878         val_conv = ChannelPublicKeys_clone(&val_conv);
39879         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
39880 }
39881
39882 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39883         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39885         this_ptr_conv.is_owned = false;
39886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39887         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
39888         return ret_conv;
39889 }
39890
39891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39892         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39894         this_ptr_conv.is_owned = false;
39895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39896         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
39897 }
39898
39899 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) {
39900         LDKChannelPublicKeys pubkeys_arg_conv;
39901         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
39902         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
39903         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
39904         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
39905         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
39906         int64_t ret_ref = 0;
39907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39910         ret_ref = (uintptr_t)ret_var.inner;
39911         if (ret_var.is_owned) {
39912                 ret_ref |= 1;
39913         }
39914         return ret_ref;
39915 }
39916
39917 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
39918         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
39919 int64_t ret_ref = 0;
39920 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39921 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39922 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39923 ret_ref = (uintptr_t)ret_var.inner;
39924 if (ret_var.is_owned) {
39925         ret_ref |= 1;
39926 }
39927         return ret_ref;
39928 }
39929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39930         LDKCounterpartyChannelTransactionParameters arg_conv;
39931         arg_conv.inner = (void*)(arg & (~1));
39932         arg_conv.is_owned = false;
39933         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39934         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
39935         return ret_conv;
39936 }
39937
39938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39939         LDKCounterpartyChannelTransactionParameters orig_conv;
39940         orig_conv.inner = (void*)(orig & (~1));
39941         orig_conv.is_owned = false;
39942         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39943         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
39944         int64_t ret_ref = 0;
39945         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39946         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39948         ret_ref = (uintptr_t)ret_var.inner;
39949         if (ret_var.is_owned) {
39950                 ret_ref |= 1;
39951         }
39952         return ret_ref;
39953 }
39954
39955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
39956         LDKChannelTransactionParameters this_arg_conv;
39957         this_arg_conv.inner = (void*)(this_arg & (~1));
39958         this_arg_conv.is_owned = false;
39959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39960         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
39961         return ret_conv;
39962 }
39963
39964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39965         LDKChannelTransactionParameters this_arg_conv;
39966         this_arg_conv.inner = (void*)(this_arg & (~1));
39967         this_arg_conv.is_owned = false;
39968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39969         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
39970         int64_t ret_ref = 0;
39971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39974         ret_ref = (uintptr_t)ret_var.inner;
39975         if (ret_var.is_owned) {
39976                 ret_ref |= 1;
39977         }
39978         return ret_ref;
39979 }
39980
39981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39982         LDKChannelTransactionParameters this_arg_conv;
39983         this_arg_conv.inner = (void*)(this_arg & (~1));
39984         this_arg_conv.is_owned = false;
39985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39986         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
39987         int64_t ret_ref = 0;
39988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39991         ret_ref = (uintptr_t)ret_var.inner;
39992         if (ret_var.is_owned) {
39993                 ret_ref |= 1;
39994         }
39995         return ret_ref;
39996 }
39997
39998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39999         LDKCounterpartyChannelTransactionParameters obj_conv;
40000         obj_conv.inner = (void*)(obj & (~1));
40001         obj_conv.is_owned = false;
40002         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40003         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
40004         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40005         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40006         CVec_u8Z_free(ret_var);
40007         return ret_arr;
40008 }
40009
40010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40011         LDKu8slice ser_ref;
40012         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40013         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40014         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
40015         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
40016         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40017         return (int64_t)ret_conv;
40018 }
40019
40020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
40021         LDKChannelTransactionParameters obj_conv;
40022         obj_conv.inner = (void*)(obj & (~1));
40023         obj_conv.is_owned = false;
40024         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40025         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
40026         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40027         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40028         CVec_u8Z_free(ret_var);
40029         return ret_arr;
40030 }
40031
40032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40033         LDKu8slice ser_ref;
40034         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40035         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40036         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
40037         *ret_conv = ChannelTransactionParameters_read(ser_ref);
40038         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40039         return (int64_t)ret_conv;
40040 }
40041
40042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40043         LDKDirectedChannelTransactionParameters this_obj_conv;
40044         this_obj_conv.inner = (void*)(this_obj & (~1));
40045         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40047         DirectedChannelTransactionParameters_free(this_obj_conv);
40048 }
40049
40050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
40051         LDKDirectedChannelTransactionParameters this_arg_conv;
40052         this_arg_conv.inner = (void*)(this_arg & (~1));
40053         this_arg_conv.is_owned = false;
40054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40055         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
40056         int64_t ret_ref = 0;
40057         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40058         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40060         ret_ref = (uintptr_t)ret_var.inner;
40061         if (ret_var.is_owned) {
40062                 ret_ref |= 1;
40063         }
40064         return ret_ref;
40065 }
40066
40067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
40068         LDKDirectedChannelTransactionParameters this_arg_conv;
40069         this_arg_conv.inner = (void*)(this_arg & (~1));
40070         this_arg_conv.is_owned = false;
40071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40072         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
40073         int64_t ret_ref = 0;
40074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40077         ret_ref = (uintptr_t)ret_var.inner;
40078         if (ret_var.is_owned) {
40079                 ret_ref |= 1;
40080         }
40081         return ret_ref;
40082 }
40083
40084 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
40085         LDKDirectedChannelTransactionParameters this_arg_conv;
40086         this_arg_conv.inner = (void*)(this_arg & (~1));
40087         this_arg_conv.is_owned = false;
40088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40089         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
40090         return ret_conv;
40091 }
40092
40093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
40094         LDKDirectedChannelTransactionParameters this_arg_conv;
40095         this_arg_conv.inner = (void*)(this_arg & (~1));
40096         this_arg_conv.is_owned = false;
40097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40098         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
40099         return ret_conv;
40100 }
40101
40102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
40103         LDKDirectedChannelTransactionParameters this_arg_conv;
40104         this_arg_conv.inner = (void*)(this_arg & (~1));
40105         this_arg_conv.is_owned = false;
40106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40107         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
40108         int64_t ret_ref = 0;
40109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40112         ret_ref = (uintptr_t)ret_var.inner;
40113         if (ret_var.is_owned) {
40114                 ret_ref |= 1;
40115         }
40116         return ret_ref;
40117 }
40118
40119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40120         LDKDirectedChannelTransactionParameters this_arg_conv;
40121         this_arg_conv.inner = (void*)(this_arg & (~1));
40122         this_arg_conv.is_owned = false;
40123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40124         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
40125         return ret_conv;
40126 }
40127
40128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40129         LDKHolderCommitmentTransaction this_obj_conv;
40130         this_obj_conv.inner = (void*)(this_obj & (~1));
40131         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40133         HolderCommitmentTransaction_free(this_obj_conv);
40134 }
40135
40136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
40137         LDKHolderCommitmentTransaction this_ptr_conv;
40138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40139         this_ptr_conv.is_owned = false;
40140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40141         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40142         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
40143         return ret_arr;
40144 }
40145
40146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40147         LDKHolderCommitmentTransaction this_ptr_conv;
40148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40149         this_ptr_conv.is_owned = false;
40150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40151         LDKSignature val_ref;
40152         CHECK((*env)->GetArrayLength(env, val) == 64);
40153         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
40154         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
40155 }
40156
40157 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40158         LDKHolderCommitmentTransaction this_ptr_conv;
40159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40160         this_ptr_conv.is_owned = false;
40161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40162         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
40163         jobjectArray ret_arr = NULL;
40164         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
40165         ;
40166         for (size_t i = 0; i < ret_var.datalen; i++) {
40167                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
40168                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
40169                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
40170         }
40171         
40172         FREE(ret_var.data);
40173         return ret_arr;
40174 }
40175
40176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
40177         LDKHolderCommitmentTransaction this_ptr_conv;
40178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40179         this_ptr_conv.is_owned = false;
40180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40181         LDKCVec_SignatureZ val_constr;
40182         val_constr.datalen = (*env)->GetArrayLength(env, val);
40183         if (val_constr.datalen > 0)
40184                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40185         else
40186                 val_constr.data = NULL;
40187         for (size_t i = 0; i < val_constr.datalen; i++) {
40188                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
40189                 LDKSignature val_conv_8_ref;
40190                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
40191                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
40192                 val_constr.data[i] = val_conv_8_ref;
40193         }
40194         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
40195 }
40196
40197 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
40198         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
40199 int64_t ret_ref = 0;
40200 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40201 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40202 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40203 ret_ref = (uintptr_t)ret_var.inner;
40204 if (ret_var.is_owned) {
40205         ret_ref |= 1;
40206 }
40207         return ret_ref;
40208 }
40209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40210         LDKHolderCommitmentTransaction arg_conv;
40211         arg_conv.inner = (void*)(arg & (~1));
40212         arg_conv.is_owned = false;
40213         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40214         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
40215         return ret_conv;
40216 }
40217
40218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40219         LDKHolderCommitmentTransaction orig_conv;
40220         orig_conv.inner = (void*)(orig & (~1));
40221         orig_conv.is_owned = false;
40222         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40223         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
40224         int64_t ret_ref = 0;
40225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40228         ret_ref = (uintptr_t)ret_var.inner;
40229         if (ret_var.is_owned) {
40230                 ret_ref |= 1;
40231         }
40232         return ret_ref;
40233 }
40234
40235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40236         LDKHolderCommitmentTransaction obj_conv;
40237         obj_conv.inner = (void*)(obj & (~1));
40238         obj_conv.is_owned = false;
40239         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40240         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
40241         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40242         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40243         CVec_u8Z_free(ret_var);
40244         return ret_arr;
40245 }
40246
40247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40248         LDKu8slice ser_ref;
40249         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40250         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40251         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
40252         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
40253         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40254         return (int64_t)ret_conv;
40255 }
40256
40257 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) {
40258         LDKCommitmentTransaction commitment_tx_conv;
40259         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
40260         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
40261         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
40262         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
40263         LDKSignature counterparty_sig_ref;
40264         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
40265         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
40266         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
40267         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
40268         if (counterparty_htlc_sigs_constr.datalen > 0)
40269                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40270         else
40271                 counterparty_htlc_sigs_constr.data = NULL;
40272         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
40273                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
40274                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
40275                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
40276                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
40277                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
40278         }
40279         LDKPublicKey holder_funding_key_ref;
40280         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
40281         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
40282         LDKPublicKey counterparty_funding_key_ref;
40283         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
40284         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
40285         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
40286         int64_t ret_ref = 0;
40287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40290         ret_ref = (uintptr_t)ret_var.inner;
40291         if (ret_var.is_owned) {
40292                 ret_ref |= 1;
40293         }
40294         return ret_ref;
40295 }
40296
40297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40298         LDKBuiltCommitmentTransaction this_obj_conv;
40299         this_obj_conv.inner = (void*)(this_obj & (~1));
40300         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40302         BuiltCommitmentTransaction_free(this_obj_conv);
40303 }
40304
40305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
40306         LDKBuiltCommitmentTransaction this_ptr_conv;
40307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40308         this_ptr_conv.is_owned = false;
40309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40310         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
40311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40313         Transaction_free(ret_var);
40314         return ret_arr;
40315 }
40316
40317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40318         LDKBuiltCommitmentTransaction this_ptr_conv;
40319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40320         this_ptr_conv.is_owned = false;
40321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40322         LDKTransaction val_ref;
40323         val_ref.datalen = (*env)->GetArrayLength(env, val);
40324         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
40325         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
40326         val_ref.data_is_owned = true;
40327         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
40328 }
40329
40330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
40331         LDKBuiltCommitmentTransaction this_ptr_conv;
40332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40333         this_ptr_conv.is_owned = false;
40334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40335         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40336         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
40337         return ret_arr;
40338 }
40339
40340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40341         LDKBuiltCommitmentTransaction this_ptr_conv;
40342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40343         this_ptr_conv.is_owned = false;
40344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40345         LDKThirtyTwoBytes val_ref;
40346         CHECK((*env)->GetArrayLength(env, val) == 32);
40347         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40348         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
40349 }
40350
40351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
40352         LDKTransaction transaction_arg_ref;
40353         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
40354         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
40355         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
40356         transaction_arg_ref.data_is_owned = true;
40357         LDKThirtyTwoBytes txid_arg_ref;
40358         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
40359         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
40360         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
40361         int64_t ret_ref = 0;
40362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40365         ret_ref = (uintptr_t)ret_var.inner;
40366         if (ret_var.is_owned) {
40367                 ret_ref |= 1;
40368         }
40369         return ret_ref;
40370 }
40371
40372 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
40373         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
40374 int64_t ret_ref = 0;
40375 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40376 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40377 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40378 ret_ref = (uintptr_t)ret_var.inner;
40379 if (ret_var.is_owned) {
40380         ret_ref |= 1;
40381 }
40382         return ret_ref;
40383 }
40384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40385         LDKBuiltCommitmentTransaction arg_conv;
40386         arg_conv.inner = (void*)(arg & (~1));
40387         arg_conv.is_owned = false;
40388         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40389         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
40390         return ret_conv;
40391 }
40392
40393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40394         LDKBuiltCommitmentTransaction orig_conv;
40395         orig_conv.inner = (void*)(orig & (~1));
40396         orig_conv.is_owned = false;
40397         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40398         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
40399         int64_t ret_ref = 0;
40400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40403         ret_ref = (uintptr_t)ret_var.inner;
40404         if (ret_var.is_owned) {
40405                 ret_ref |= 1;
40406         }
40407         return ret_ref;
40408 }
40409
40410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40411         LDKBuiltCommitmentTransaction obj_conv;
40412         obj_conv.inner = (void*)(obj & (~1));
40413         obj_conv.is_owned = false;
40414         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40415         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
40416         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40417         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40418         CVec_u8Z_free(ret_var);
40419         return ret_arr;
40420 }
40421
40422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40423         LDKu8slice ser_ref;
40424         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40425         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40426         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
40427         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
40428         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40429         return (int64_t)ret_conv;
40430 }
40431
40432 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) {
40433         LDKBuiltCommitmentTransaction this_arg_conv;
40434         this_arg_conv.inner = (void*)(this_arg & (~1));
40435         this_arg_conv.is_owned = false;
40436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40437         LDKu8slice funding_redeemscript_ref;
40438         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40439         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40440         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40441         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
40442         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40443         return ret_arr;
40444 }
40445
40446 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) {
40447         LDKBuiltCommitmentTransaction this_arg_conv;
40448         this_arg_conv.inner = (void*)(this_arg & (~1));
40449         this_arg_conv.is_owned = false;
40450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40451         unsigned char funding_key_arr[32];
40452         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
40453         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
40454         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
40455         LDKu8slice funding_redeemscript_ref;
40456         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40457         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40458         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40459         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
40460         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40461         return ret_arr;
40462 }
40463
40464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40465         LDKClosingTransaction this_obj_conv;
40466         this_obj_conv.inner = (void*)(this_obj & (~1));
40467         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40469         ClosingTransaction_free(this_obj_conv);
40470 }
40471
40472 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
40473         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
40474 int64_t ret_ref = 0;
40475 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40476 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40477 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40478 ret_ref = (uintptr_t)ret_var.inner;
40479 if (ret_var.is_owned) {
40480         ret_ref |= 1;
40481 }
40482         return ret_ref;
40483 }
40484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40485         LDKClosingTransaction arg_conv;
40486         arg_conv.inner = (void*)(arg & (~1));
40487         arg_conv.is_owned = false;
40488         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40489         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
40490         return ret_conv;
40491 }
40492
40493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40494         LDKClosingTransaction orig_conv;
40495         orig_conv.inner = (void*)(orig & (~1));
40496         orig_conv.is_owned = false;
40497         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40498         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
40499         int64_t ret_ref = 0;
40500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40503         ret_ref = (uintptr_t)ret_var.inner;
40504         if (ret_var.is_owned) {
40505                 ret_ref |= 1;
40506         }
40507         return ret_ref;
40508 }
40509
40510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
40511         LDKClosingTransaction o_conv;
40512         o_conv.inner = (void*)(o & (~1));
40513         o_conv.is_owned = false;
40514         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40515         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
40516         return ret_conv;
40517 }
40518
40519 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) {
40520         LDKCVec_u8Z to_holder_script_ref;
40521         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
40522         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
40523         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
40524         LDKCVec_u8Z to_counterparty_script_ref;
40525         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
40526         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
40527         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
40528         LDKOutPoint funding_outpoint_conv;
40529         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
40530         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
40531         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40532         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40533         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
40534         int64_t ret_ref = 0;
40535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40538         ret_ref = (uintptr_t)ret_var.inner;
40539         if (ret_var.is_owned) {
40540                 ret_ref |= 1;
40541         }
40542         return ret_ref;
40543 }
40544
40545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
40546         LDKClosingTransaction this_arg_conv;
40547         this_arg_conv.inner = (void*)(this_arg & (~1));
40548         this_arg_conv.is_owned = false;
40549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40550         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
40551         int64_t ret_ref = 0;
40552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40555         ret_ref = (uintptr_t)ret_var.inner;
40556         if (ret_var.is_owned) {
40557                 ret_ref |= 1;
40558         }
40559         return ret_ref;
40560 }
40561
40562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
40563         LDKClosingTransaction this_arg_conv;
40564         this_arg_conv.inner = (void*)(this_arg & (~1));
40565         this_arg_conv.is_owned = false;
40566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40567         LDKOutPoint funding_outpoint_conv;
40568         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
40569         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
40570         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40571         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40572         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
40573         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
40574         return (int64_t)ret_conv;
40575 }
40576
40577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40578         LDKClosingTransaction this_arg_conv;
40579         this_arg_conv.inner = (void*)(this_arg & (~1));
40580         this_arg_conv.is_owned = false;
40581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40582         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
40583         return ret_conv;
40584 }
40585
40586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40587         LDKClosingTransaction this_arg_conv;
40588         this_arg_conv.inner = (void*)(this_arg & (~1));
40589         this_arg_conv.is_owned = false;
40590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40591         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
40592         return ret_conv;
40593 }
40594
40595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40596         LDKClosingTransaction this_arg_conv;
40597         this_arg_conv.inner = (void*)(this_arg & (~1));
40598         this_arg_conv.is_owned = false;
40599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40600         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
40601         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40602         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40603         return ret_arr;
40604 }
40605
40606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40607         LDKClosingTransaction this_arg_conv;
40608         this_arg_conv.inner = (void*)(this_arg & (~1));
40609         this_arg_conv.is_owned = false;
40610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40611         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
40612         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40613         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40614         return ret_arr;
40615 }
40616
40617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40618         LDKTrustedClosingTransaction this_obj_conv;
40619         this_obj_conv.inner = (void*)(this_obj & (~1));
40620         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40622         TrustedClosingTransaction_free(this_obj_conv);
40623 }
40624
40625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
40626         LDKTrustedClosingTransaction this_arg_conv;
40627         this_arg_conv.inner = (void*)(this_arg & (~1));
40628         this_arg_conv.is_owned = false;
40629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40630         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
40631         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40632         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40633         Transaction_free(ret_var);
40634         return ret_arr;
40635 }
40636
40637 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) {
40638         LDKTrustedClosingTransaction this_arg_conv;
40639         this_arg_conv.inner = (void*)(this_arg & (~1));
40640         this_arg_conv.is_owned = false;
40641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40642         LDKu8slice funding_redeemscript_ref;
40643         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40644         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40645         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40646         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
40647         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40648         return ret_arr;
40649 }
40650
40651 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) {
40652         LDKTrustedClosingTransaction this_arg_conv;
40653         this_arg_conv.inner = (void*)(this_arg & (~1));
40654         this_arg_conv.is_owned = false;
40655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40656         unsigned char funding_key_arr[32];
40657         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
40658         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
40659         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
40660         LDKu8slice funding_redeemscript_ref;
40661         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40662         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40663         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40664         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
40665         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40666         return ret_arr;
40667 }
40668
40669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40670         LDKCommitmentTransaction this_obj_conv;
40671         this_obj_conv.inner = (void*)(this_obj & (~1));
40672         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40674         CommitmentTransaction_free(this_obj_conv);
40675 }
40676
40677 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
40678         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
40679 int64_t ret_ref = 0;
40680 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40681 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40682 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40683 ret_ref = (uintptr_t)ret_var.inner;
40684 if (ret_var.is_owned) {
40685         ret_ref |= 1;
40686 }
40687         return ret_ref;
40688 }
40689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40690         LDKCommitmentTransaction arg_conv;
40691         arg_conv.inner = (void*)(arg & (~1));
40692         arg_conv.is_owned = false;
40693         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40694         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
40695         return ret_conv;
40696 }
40697
40698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40699         LDKCommitmentTransaction orig_conv;
40700         orig_conv.inner = (void*)(orig & (~1));
40701         orig_conv.is_owned = false;
40702         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40703         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
40704         int64_t ret_ref = 0;
40705         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40706         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40708         ret_ref = (uintptr_t)ret_var.inner;
40709         if (ret_var.is_owned) {
40710                 ret_ref |= 1;
40711         }
40712         return ret_ref;
40713 }
40714
40715 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40716         LDKCommitmentTransaction obj_conv;
40717         obj_conv.inner = (void*)(obj & (~1));
40718         obj_conv.is_owned = false;
40719         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40720         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
40721         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40722         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40723         CVec_u8Z_free(ret_var);
40724         return ret_arr;
40725 }
40726
40727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40728         LDKu8slice ser_ref;
40729         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40730         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40731         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
40732         *ret_conv = CommitmentTransaction_read(ser_ref);
40733         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40734         return (int64_t)ret_conv;
40735 }
40736
40737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
40738         LDKCommitmentTransaction this_arg_conv;
40739         this_arg_conv.inner = (void*)(this_arg & (~1));
40740         this_arg_conv.is_owned = false;
40741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40742         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
40743         return ret_conv;
40744 }
40745
40746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40747         LDKCommitmentTransaction this_arg_conv;
40748         this_arg_conv.inner = (void*)(this_arg & (~1));
40749         this_arg_conv.is_owned = false;
40750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40751         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
40752         return ret_conv;
40753 }
40754
40755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40756         LDKCommitmentTransaction this_arg_conv;
40757         this_arg_conv.inner = (void*)(this_arg & (~1));
40758         this_arg_conv.is_owned = false;
40759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40760         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
40761         return ret_conv;
40762 }
40763
40764 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
40765         LDKCommitmentTransaction this_arg_conv;
40766         this_arg_conv.inner = (void*)(this_arg & (~1));
40767         this_arg_conv.is_owned = false;
40768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40769         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
40770         return ret_conv;
40771 }
40772
40773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
40774         LDKCommitmentTransaction this_arg_conv;
40775         this_arg_conv.inner = (void*)(this_arg & (~1));
40776         this_arg_conv.is_owned = false;
40777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40778         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
40779         int64_t ret_ref = 0;
40780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40783         ret_ref = (uintptr_t)ret_var.inner;
40784         if (ret_var.is_owned) {
40785                 ret_ref |= 1;
40786         }
40787         return ret_ref;
40788 }
40789
40790 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) {
40791         LDKCommitmentTransaction this_arg_conv;
40792         this_arg_conv.inner = (void*)(this_arg & (~1));
40793         this_arg_conv.is_owned = false;
40794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40795         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40796         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40797         channel_parameters_conv.is_owned = false;
40798         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40799         LDKChannelPublicKeys broadcaster_keys_conv;
40800         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
40801         broadcaster_keys_conv.is_owned = false;
40802         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
40803         LDKChannelPublicKeys countersignatory_keys_conv;
40804         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
40805         countersignatory_keys_conv.is_owned = false;
40806         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
40807         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
40808         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
40809         return (int64_t)ret_conv;
40810 }
40811
40812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40813         LDKTrustedCommitmentTransaction 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         TrustedCommitmentTransaction_free(this_obj_conv);
40818 }
40819
40820 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
40821         LDKTrustedCommitmentTransaction this_arg_conv;
40822         this_arg_conv.inner = (void*)(this_arg & (~1));
40823         this_arg_conv.is_owned = false;
40824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40825         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40826         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
40827         return ret_arr;
40828 }
40829
40830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
40831         LDKTrustedCommitmentTransaction this_arg_conv;
40832         this_arg_conv.inner = (void*)(this_arg & (~1));
40833         this_arg_conv.is_owned = false;
40834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40835         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
40836         int64_t ret_ref = 0;
40837         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40838         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40840         ret_ref = (uintptr_t)ret_var.inner;
40841         if (ret_var.is_owned) {
40842                 ret_ref |= 1;
40843         }
40844         return ret_ref;
40845 }
40846
40847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
40848         LDKTrustedCommitmentTransaction this_arg_conv;
40849         this_arg_conv.inner = (void*)(this_arg & (~1));
40850         this_arg_conv.is_owned = false;
40851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40852         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
40853         int64_t ret_ref = 0;
40854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40857         ret_ref = (uintptr_t)ret_var.inner;
40858         if (ret_var.is_owned) {
40859                 ret_ref |= 1;
40860         }
40861         return ret_ref;
40862 }
40863
40864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40865         LDKTrustedCommitmentTransaction this_arg_conv;
40866         this_arg_conv.inner = (void*)(this_arg & (~1));
40867         this_arg_conv.is_owned = false;
40868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40869         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
40870         return ret_conv;
40871 }
40872
40873 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) {
40874         LDKTrustedCommitmentTransaction this_arg_conv;
40875         this_arg_conv.inner = (void*)(this_arg & (~1));
40876         this_arg_conv.is_owned = false;
40877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40878         unsigned char htlc_base_key_arr[32];
40879         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
40880         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
40881         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
40882         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40883         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40884         channel_parameters_conv.is_owned = false;
40885         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40886         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
40887         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
40888         return (int64_t)ret_conv;
40889 }
40890
40891 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) {
40892         LDKPublicKey broadcaster_payment_basepoint_ref;
40893         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
40894         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
40895         LDKPublicKey countersignatory_payment_basepoint_ref;
40896         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
40897         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
40898         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
40899         return ret_conv;
40900 }
40901
40902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40903         LDKInitFeatures a_conv;
40904         a_conv.inner = (void*)(a & (~1));
40905         a_conv.is_owned = false;
40906         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40907         LDKInitFeatures b_conv;
40908         b_conv.inner = (void*)(b & (~1));
40909         b_conv.is_owned = false;
40910         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40911         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
40912         return ret_conv;
40913 }
40914
40915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40916         LDKNodeFeatures a_conv;
40917         a_conv.inner = (void*)(a & (~1));
40918         a_conv.is_owned = false;
40919         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40920         LDKNodeFeatures b_conv;
40921         b_conv.inner = (void*)(b & (~1));
40922         b_conv.is_owned = false;
40923         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40924         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
40925         return ret_conv;
40926 }
40927
40928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40929         LDKChannelFeatures a_conv;
40930         a_conv.inner = (void*)(a & (~1));
40931         a_conv.is_owned = false;
40932         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40933         LDKChannelFeatures b_conv;
40934         b_conv.inner = (void*)(b & (~1));
40935         b_conv.is_owned = false;
40936         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40937         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
40938         return ret_conv;
40939 }
40940
40941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40942         LDKInvoiceFeatures a_conv;
40943         a_conv.inner = (void*)(a & (~1));
40944         a_conv.is_owned = false;
40945         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40946         LDKInvoiceFeatures b_conv;
40947         b_conv.inner = (void*)(b & (~1));
40948         b_conv.is_owned = false;
40949         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40950         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
40951         return ret_conv;
40952 }
40953
40954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40955         LDKChannelTypeFeatures a_conv;
40956         a_conv.inner = (void*)(a & (~1));
40957         a_conv.is_owned = false;
40958         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40959         LDKChannelTypeFeatures b_conv;
40960         b_conv.inner = (void*)(b & (~1));
40961         b_conv.is_owned = false;
40962         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40963         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
40964         return ret_conv;
40965 }
40966
40967 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
40968         LDKInitFeatures ret_var = InitFeatures_clone(arg);
40969 int64_t ret_ref = 0;
40970 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40971 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40972 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40973 ret_ref = (uintptr_t)ret_var.inner;
40974 if (ret_var.is_owned) {
40975         ret_ref |= 1;
40976 }
40977         return ret_ref;
40978 }
40979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40980         LDKInitFeatures arg_conv;
40981         arg_conv.inner = (void*)(arg & (~1));
40982         arg_conv.is_owned = false;
40983         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40984         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
40985         return ret_conv;
40986 }
40987
40988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40989         LDKInitFeatures orig_conv;
40990         orig_conv.inner = (void*)(orig & (~1));
40991         orig_conv.is_owned = false;
40992         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40993         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
40994         int64_t ret_ref = 0;
40995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40998         ret_ref = (uintptr_t)ret_var.inner;
40999         if (ret_var.is_owned) {
41000                 ret_ref |= 1;
41001         }
41002         return ret_ref;
41003 }
41004
41005 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
41006         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
41007 int64_t ret_ref = 0;
41008 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41009 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41010 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41011 ret_ref = (uintptr_t)ret_var.inner;
41012 if (ret_var.is_owned) {
41013         ret_ref |= 1;
41014 }
41015         return ret_ref;
41016 }
41017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41018         LDKNodeFeatures arg_conv;
41019         arg_conv.inner = (void*)(arg & (~1));
41020         arg_conv.is_owned = false;
41021         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41022         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
41023         return ret_conv;
41024 }
41025
41026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41027         LDKNodeFeatures orig_conv;
41028         orig_conv.inner = (void*)(orig & (~1));
41029         orig_conv.is_owned = false;
41030         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41031         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
41032         int64_t ret_ref = 0;
41033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41036         ret_ref = (uintptr_t)ret_var.inner;
41037         if (ret_var.is_owned) {
41038                 ret_ref |= 1;
41039         }
41040         return ret_ref;
41041 }
41042
41043 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
41044         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
41045 int64_t ret_ref = 0;
41046 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41047 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41048 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41049 ret_ref = (uintptr_t)ret_var.inner;
41050 if (ret_var.is_owned) {
41051         ret_ref |= 1;
41052 }
41053         return ret_ref;
41054 }
41055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41056         LDKChannelFeatures arg_conv;
41057         arg_conv.inner = (void*)(arg & (~1));
41058         arg_conv.is_owned = false;
41059         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41060         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
41061         return ret_conv;
41062 }
41063
41064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41065         LDKChannelFeatures orig_conv;
41066         orig_conv.inner = (void*)(orig & (~1));
41067         orig_conv.is_owned = false;
41068         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41069         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
41070         int64_t ret_ref = 0;
41071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41074         ret_ref = (uintptr_t)ret_var.inner;
41075         if (ret_var.is_owned) {
41076                 ret_ref |= 1;
41077         }
41078         return ret_ref;
41079 }
41080
41081 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
41082         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
41083 int64_t ret_ref = 0;
41084 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41085 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41086 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41087 ret_ref = (uintptr_t)ret_var.inner;
41088 if (ret_var.is_owned) {
41089         ret_ref |= 1;
41090 }
41091         return ret_ref;
41092 }
41093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41094         LDKInvoiceFeatures arg_conv;
41095         arg_conv.inner = (void*)(arg & (~1));
41096         arg_conv.is_owned = false;
41097         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41098         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
41099         return ret_conv;
41100 }
41101
41102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41103         LDKInvoiceFeatures orig_conv;
41104         orig_conv.inner = (void*)(orig & (~1));
41105         orig_conv.is_owned = false;
41106         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41107         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
41108         int64_t ret_ref = 0;
41109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41112         ret_ref = (uintptr_t)ret_var.inner;
41113         if (ret_var.is_owned) {
41114                 ret_ref |= 1;
41115         }
41116         return ret_ref;
41117 }
41118
41119 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
41120         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
41121 int64_t ret_ref = 0;
41122 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41123 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41124 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41125 ret_ref = (uintptr_t)ret_var.inner;
41126 if (ret_var.is_owned) {
41127         ret_ref |= 1;
41128 }
41129         return ret_ref;
41130 }
41131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41132         LDKChannelTypeFeatures arg_conv;
41133         arg_conv.inner = (void*)(arg & (~1));
41134         arg_conv.is_owned = false;
41135         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41136         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
41137         return ret_conv;
41138 }
41139
41140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41141         LDKChannelTypeFeatures orig_conv;
41142         orig_conv.inner = (void*)(orig & (~1));
41143         orig_conv.is_owned = false;
41144         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41145         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
41146         int64_t ret_ref = 0;
41147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41150         ret_ref = (uintptr_t)ret_var.inner;
41151         if (ret_var.is_owned) {
41152                 ret_ref |= 1;
41153         }
41154         return ret_ref;
41155 }
41156
41157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41158         LDKInitFeatures this_obj_conv;
41159         this_obj_conv.inner = (void*)(this_obj & (~1));
41160         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41162         InitFeatures_free(this_obj_conv);
41163 }
41164
41165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41166         LDKNodeFeatures this_obj_conv;
41167         this_obj_conv.inner = (void*)(this_obj & (~1));
41168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41170         NodeFeatures_free(this_obj_conv);
41171 }
41172
41173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41174         LDKChannelFeatures this_obj_conv;
41175         this_obj_conv.inner = (void*)(this_obj & (~1));
41176         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41178         ChannelFeatures_free(this_obj_conv);
41179 }
41180
41181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41182         LDKInvoiceFeatures this_obj_conv;
41183         this_obj_conv.inner = (void*)(this_obj & (~1));
41184         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41186         InvoiceFeatures_free(this_obj_conv);
41187 }
41188
41189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41190         LDKChannelTypeFeatures this_obj_conv;
41191         this_obj_conv.inner = (void*)(this_obj & (~1));
41192         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41194         ChannelTypeFeatures_free(this_obj_conv);
41195 }
41196
41197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
41198         LDKInitFeatures ret_var = InitFeatures_empty();
41199         int64_t ret_ref = 0;
41200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41203         ret_ref = (uintptr_t)ret_var.inner;
41204         if (ret_var.is_owned) {
41205                 ret_ref |= 1;
41206         }
41207         return ret_ref;
41208 }
41209
41210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
41211         LDKInitFeatures ret_var = InitFeatures_known();
41212         int64_t ret_ref = 0;
41213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41216         ret_ref = (uintptr_t)ret_var.inner;
41217         if (ret_var.is_owned) {
41218                 ret_ref |= 1;
41219         }
41220         return ret_ref;
41221 }
41222
41223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41224         LDKInitFeatures this_arg_conv;
41225         this_arg_conv.inner = (void*)(this_arg & (~1));
41226         this_arg_conv.is_owned = false;
41227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41228         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
41229         return ret_conv;
41230 }
41231
41232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
41233         LDKNodeFeatures ret_var = NodeFeatures_empty();
41234         int64_t ret_ref = 0;
41235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41238         ret_ref = (uintptr_t)ret_var.inner;
41239         if (ret_var.is_owned) {
41240                 ret_ref |= 1;
41241         }
41242         return ret_ref;
41243 }
41244
41245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
41246         LDKNodeFeatures ret_var = NodeFeatures_known();
41247         int64_t ret_ref = 0;
41248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41251         ret_ref = (uintptr_t)ret_var.inner;
41252         if (ret_var.is_owned) {
41253                 ret_ref |= 1;
41254         }
41255         return ret_ref;
41256 }
41257
41258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41259         LDKNodeFeatures this_arg_conv;
41260         this_arg_conv.inner = (void*)(this_arg & (~1));
41261         this_arg_conv.is_owned = false;
41262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41263         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
41264         return ret_conv;
41265 }
41266
41267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
41268         LDKChannelFeatures ret_var = ChannelFeatures_empty();
41269         int64_t ret_ref = 0;
41270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41273         ret_ref = (uintptr_t)ret_var.inner;
41274         if (ret_var.is_owned) {
41275                 ret_ref |= 1;
41276         }
41277         return ret_ref;
41278 }
41279
41280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
41281         LDKChannelFeatures ret_var = ChannelFeatures_known();
41282         int64_t ret_ref = 0;
41283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41286         ret_ref = (uintptr_t)ret_var.inner;
41287         if (ret_var.is_owned) {
41288                 ret_ref |= 1;
41289         }
41290         return ret_ref;
41291 }
41292
41293 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41294         LDKChannelFeatures this_arg_conv;
41295         this_arg_conv.inner = (void*)(this_arg & (~1));
41296         this_arg_conv.is_owned = false;
41297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41298         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
41299         return ret_conv;
41300 }
41301
41302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
41303         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
41304         int64_t ret_ref = 0;
41305         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41306         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41308         ret_ref = (uintptr_t)ret_var.inner;
41309         if (ret_var.is_owned) {
41310                 ret_ref |= 1;
41311         }
41312         return ret_ref;
41313 }
41314
41315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
41316         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
41317         int64_t ret_ref = 0;
41318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41321         ret_ref = (uintptr_t)ret_var.inner;
41322         if (ret_var.is_owned) {
41323                 ret_ref |= 1;
41324         }
41325         return ret_ref;
41326 }
41327
41328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41329         LDKInvoiceFeatures this_arg_conv;
41330         this_arg_conv.inner = (void*)(this_arg & (~1));
41331         this_arg_conv.is_owned = false;
41332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41333         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
41334         return ret_conv;
41335 }
41336
41337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
41338         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
41339         int64_t ret_ref = 0;
41340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41343         ret_ref = (uintptr_t)ret_var.inner;
41344         if (ret_var.is_owned) {
41345                 ret_ref |= 1;
41346         }
41347         return ret_ref;
41348 }
41349
41350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
41351         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
41352         int64_t ret_ref = 0;
41353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41356         ret_ref = (uintptr_t)ret_var.inner;
41357         if (ret_var.is_owned) {
41358                 ret_ref |= 1;
41359         }
41360         return ret_ref;
41361 }
41362
41363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41364         LDKChannelTypeFeatures this_arg_conv;
41365         this_arg_conv.inner = (void*)(this_arg & (~1));
41366         this_arg_conv.is_owned = false;
41367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41368         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
41369         return ret_conv;
41370 }
41371
41372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41373         LDKInitFeatures obj_conv;
41374         obj_conv.inner = (void*)(obj & (~1));
41375         obj_conv.is_owned = false;
41376         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41377         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
41378         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41379         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41380         CVec_u8Z_free(ret_var);
41381         return ret_arr;
41382 }
41383
41384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41385         LDKu8slice ser_ref;
41386         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41387         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41388         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
41389         *ret_conv = InitFeatures_read(ser_ref);
41390         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41391         return (int64_t)ret_conv;
41392 }
41393
41394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41395         LDKChannelFeatures obj_conv;
41396         obj_conv.inner = (void*)(obj & (~1));
41397         obj_conv.is_owned = false;
41398         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41399         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
41400         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41401         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41402         CVec_u8Z_free(ret_var);
41403         return ret_arr;
41404 }
41405
41406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41407         LDKu8slice ser_ref;
41408         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41409         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41410         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
41411         *ret_conv = ChannelFeatures_read(ser_ref);
41412         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41413         return (int64_t)ret_conv;
41414 }
41415
41416 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41417         LDKNodeFeatures obj_conv;
41418         obj_conv.inner = (void*)(obj & (~1));
41419         obj_conv.is_owned = false;
41420         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41421         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
41422         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41423         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41424         CVec_u8Z_free(ret_var);
41425         return ret_arr;
41426 }
41427
41428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41429         LDKu8slice ser_ref;
41430         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41431         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41432         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
41433         *ret_conv = NodeFeatures_read(ser_ref);
41434         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41435         return (int64_t)ret_conv;
41436 }
41437
41438 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41439         LDKInvoiceFeatures obj_conv;
41440         obj_conv.inner = (void*)(obj & (~1));
41441         obj_conv.is_owned = false;
41442         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41443         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
41444         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41445         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41446         CVec_u8Z_free(ret_var);
41447         return ret_arr;
41448 }
41449
41450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41451         LDKu8slice ser_ref;
41452         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41453         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41454         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
41455         *ret_conv = InvoiceFeatures_read(ser_ref);
41456         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41457         return (int64_t)ret_conv;
41458 }
41459
41460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41461         LDKChannelTypeFeatures obj_conv;
41462         obj_conv.inner = (void*)(obj & (~1));
41463         obj_conv.is_owned = false;
41464         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41465         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
41466         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41467         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41468         CVec_u8Z_free(ret_var);
41469         return ret_arr;
41470 }
41471
41472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41473         LDKu8slice ser_ref;
41474         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41475         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41476         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
41477         *ret_conv = ChannelTypeFeatures_read(ser_ref);
41478         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41479         return (int64_t)ret_conv;
41480 }
41481
41482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41483         LDKInitFeatures this_arg_conv;
41484         this_arg_conv.inner = (void*)(this_arg & (~1));
41485         this_arg_conv.is_owned = false;
41486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41487         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
41488 }
41489
41490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41491         LDKInitFeatures this_arg_conv;
41492         this_arg_conv.inner = (void*)(this_arg & (~1));
41493         this_arg_conv.is_owned = false;
41494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41495         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
41496 }
41497
41498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41499         LDKInitFeatures this_arg_conv;
41500         this_arg_conv.inner = (void*)(this_arg & (~1));
41501         this_arg_conv.is_owned = false;
41502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41503         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
41504         return ret_conv;
41505 }
41506
41507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41508         LDKNodeFeatures this_arg_conv;
41509         this_arg_conv.inner = (void*)(this_arg & (~1));
41510         this_arg_conv.is_owned = false;
41511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41512         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
41513 }
41514
41515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41516         LDKNodeFeatures this_arg_conv;
41517         this_arg_conv.inner = (void*)(this_arg & (~1));
41518         this_arg_conv.is_owned = false;
41519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41520         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
41521 }
41522
41523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41524         LDKNodeFeatures this_arg_conv;
41525         this_arg_conv.inner = (void*)(this_arg & (~1));
41526         this_arg_conv.is_owned = false;
41527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41528         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
41529         return ret_conv;
41530 }
41531
41532 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41533         LDKInitFeatures this_arg_conv;
41534         this_arg_conv.inner = (void*)(this_arg & (~1));
41535         this_arg_conv.is_owned = false;
41536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41537         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
41538         return ret_conv;
41539 }
41540
41541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41542         LDKNodeFeatures this_arg_conv;
41543         this_arg_conv.inner = (void*)(this_arg & (~1));
41544         this_arg_conv.is_owned = false;
41545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41546         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
41547         return ret_conv;
41548 }
41549
41550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41551         LDKInitFeatures this_arg_conv;
41552         this_arg_conv.inner = (void*)(this_arg & (~1));
41553         this_arg_conv.is_owned = false;
41554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41555         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
41556 }
41557
41558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41559         LDKInitFeatures this_arg_conv;
41560         this_arg_conv.inner = (void*)(this_arg & (~1));
41561         this_arg_conv.is_owned = false;
41562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41563         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
41564 }
41565
41566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
41567         LDKInitFeatures this_arg_conv;
41568         this_arg_conv.inner = (void*)(this_arg & (~1));
41569         this_arg_conv.is_owned = false;
41570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41571         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
41572         return ret_conv;
41573 }
41574
41575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41576         LDKInitFeatures this_arg_conv;
41577         this_arg_conv.inner = (void*)(this_arg & (~1));
41578         this_arg_conv.is_owned = false;
41579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41580         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41581 }
41582
41583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41584         LDKInitFeatures this_arg_conv;
41585         this_arg_conv.inner = (void*)(this_arg & (~1));
41586         this_arg_conv.is_owned = false;
41587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41588         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41589 }
41590
41591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41592         LDKInitFeatures this_arg_conv;
41593         this_arg_conv.inner = (void*)(this_arg & (~1));
41594         this_arg_conv.is_owned = false;
41595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41596         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41597         return ret_conv;
41598 }
41599
41600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41601         LDKNodeFeatures this_arg_conv;
41602         this_arg_conv.inner = (void*)(this_arg & (~1));
41603         this_arg_conv.is_owned = false;
41604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41605         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41606 }
41607
41608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41609         LDKNodeFeatures this_arg_conv;
41610         this_arg_conv.inner = (void*)(this_arg & (~1));
41611         this_arg_conv.is_owned = false;
41612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41613         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41614 }
41615
41616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41617         LDKNodeFeatures this_arg_conv;
41618         this_arg_conv.inner = (void*)(this_arg & (~1));
41619         this_arg_conv.is_owned = false;
41620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41621         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41622         return ret_conv;
41623 }
41624
41625 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41626         LDKInitFeatures this_arg_conv;
41627         this_arg_conv.inner = (void*)(this_arg & (~1));
41628         this_arg_conv.is_owned = false;
41629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41630         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41631         return ret_conv;
41632 }
41633
41634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41635         LDKNodeFeatures this_arg_conv;
41636         this_arg_conv.inner = (void*)(this_arg & (~1));
41637         this_arg_conv.is_owned = false;
41638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41639         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41640         return ret_conv;
41641 }
41642
41643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41644         LDKInitFeatures this_arg_conv;
41645         this_arg_conv.inner = (void*)(this_arg & (~1));
41646         this_arg_conv.is_owned = false;
41647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41648         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
41649 }
41650
41651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41652         LDKInitFeatures this_arg_conv;
41653         this_arg_conv.inner = (void*)(this_arg & (~1));
41654         this_arg_conv.is_owned = false;
41655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41656         InitFeatures_set_gossip_queries_required(&this_arg_conv);
41657 }
41658
41659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41660         LDKInitFeatures this_arg_conv;
41661         this_arg_conv.inner = (void*)(this_arg & (~1));
41662         this_arg_conv.is_owned = false;
41663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41664         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
41665         return ret_conv;
41666 }
41667
41668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41669         LDKNodeFeatures this_arg_conv;
41670         this_arg_conv.inner = (void*)(this_arg & (~1));
41671         this_arg_conv.is_owned = false;
41672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41673         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
41674 }
41675
41676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41677         LDKNodeFeatures this_arg_conv;
41678         this_arg_conv.inner = (void*)(this_arg & (~1));
41679         this_arg_conv.is_owned = false;
41680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41681         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
41682 }
41683
41684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41685         LDKNodeFeatures this_arg_conv;
41686         this_arg_conv.inner = (void*)(this_arg & (~1));
41687         this_arg_conv.is_owned = false;
41688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41689         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
41690         return ret_conv;
41691 }
41692
41693 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41694         LDKInitFeatures this_arg_conv;
41695         this_arg_conv.inner = (void*)(this_arg & (~1));
41696         this_arg_conv.is_owned = false;
41697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41698         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
41699         return ret_conv;
41700 }
41701
41702 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41703         LDKNodeFeatures this_arg_conv;
41704         this_arg_conv.inner = (void*)(this_arg & (~1));
41705         this_arg_conv.is_owned = false;
41706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41707         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
41708         return ret_conv;
41709 }
41710
41711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41712         LDKInitFeatures this_arg_conv;
41713         this_arg_conv.inner = (void*)(this_arg & (~1));
41714         this_arg_conv.is_owned = false;
41715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41716         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
41717 }
41718
41719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41720         LDKInitFeatures this_arg_conv;
41721         this_arg_conv.inner = (void*)(this_arg & (~1));
41722         this_arg_conv.is_owned = false;
41723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41724         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
41725 }
41726
41727 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41728         LDKInitFeatures this_arg_conv;
41729         this_arg_conv.inner = (void*)(this_arg & (~1));
41730         this_arg_conv.is_owned = false;
41731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41732         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
41733         return ret_conv;
41734 }
41735
41736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41737         LDKNodeFeatures this_arg_conv;
41738         this_arg_conv.inner = (void*)(this_arg & (~1));
41739         this_arg_conv.is_owned = false;
41740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41741         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
41742 }
41743
41744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41745         LDKNodeFeatures this_arg_conv;
41746         this_arg_conv.inner = (void*)(this_arg & (~1));
41747         this_arg_conv.is_owned = false;
41748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41749         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
41750 }
41751
41752 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41753         LDKNodeFeatures this_arg_conv;
41754         this_arg_conv.inner = (void*)(this_arg & (~1));
41755         this_arg_conv.is_owned = false;
41756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41757         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
41758         return ret_conv;
41759 }
41760
41761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41762         LDKInvoiceFeatures this_arg_conv;
41763         this_arg_conv.inner = (void*)(this_arg & (~1));
41764         this_arg_conv.is_owned = false;
41765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41766         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
41767 }
41768
41769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41770         LDKInvoiceFeatures this_arg_conv;
41771         this_arg_conv.inner = (void*)(this_arg & (~1));
41772         this_arg_conv.is_owned = false;
41773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41774         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
41775 }
41776
41777 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41778         LDKInvoiceFeatures this_arg_conv;
41779         this_arg_conv.inner = (void*)(this_arg & (~1));
41780         this_arg_conv.is_owned = false;
41781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41782         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
41783         return ret_conv;
41784 }
41785
41786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41787         LDKInitFeatures this_arg_conv;
41788         this_arg_conv.inner = (void*)(this_arg & (~1));
41789         this_arg_conv.is_owned = false;
41790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41791         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
41792         return ret_conv;
41793 }
41794
41795 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41796         LDKNodeFeatures this_arg_conv;
41797         this_arg_conv.inner = (void*)(this_arg & (~1));
41798         this_arg_conv.is_owned = false;
41799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41800         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
41801         return ret_conv;
41802 }
41803
41804 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41805         LDKInvoiceFeatures this_arg_conv;
41806         this_arg_conv.inner = (void*)(this_arg & (~1));
41807         this_arg_conv.is_owned = false;
41808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41809         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
41810         return ret_conv;
41811 }
41812
41813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41814         LDKInitFeatures this_arg_conv;
41815         this_arg_conv.inner = (void*)(this_arg & (~1));
41816         this_arg_conv.is_owned = false;
41817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41818         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
41819 }
41820
41821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41822         LDKInitFeatures this_arg_conv;
41823         this_arg_conv.inner = (void*)(this_arg & (~1));
41824         this_arg_conv.is_owned = false;
41825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41826         InitFeatures_set_static_remote_key_required(&this_arg_conv);
41827 }
41828
41829 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41830         LDKInitFeatures this_arg_conv;
41831         this_arg_conv.inner = (void*)(this_arg & (~1));
41832         this_arg_conv.is_owned = false;
41833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41834         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
41835         return ret_conv;
41836 }
41837
41838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41839         LDKNodeFeatures this_arg_conv;
41840         this_arg_conv.inner = (void*)(this_arg & (~1));
41841         this_arg_conv.is_owned = false;
41842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41843         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
41844 }
41845
41846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41847         LDKNodeFeatures this_arg_conv;
41848         this_arg_conv.inner = (void*)(this_arg & (~1));
41849         this_arg_conv.is_owned = false;
41850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41851         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
41852 }
41853
41854 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41855         LDKNodeFeatures this_arg_conv;
41856         this_arg_conv.inner = (void*)(this_arg & (~1));
41857         this_arg_conv.is_owned = false;
41858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41859         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
41860         return ret_conv;
41861 }
41862
41863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41864         LDKChannelTypeFeatures this_arg_conv;
41865         this_arg_conv.inner = (void*)(this_arg & (~1));
41866         this_arg_conv.is_owned = false;
41867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41868         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
41869 }
41870
41871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41872         LDKChannelTypeFeatures this_arg_conv;
41873         this_arg_conv.inner = (void*)(this_arg & (~1));
41874         this_arg_conv.is_owned = false;
41875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41876         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
41877 }
41878
41879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41880         LDKChannelTypeFeatures this_arg_conv;
41881         this_arg_conv.inner = (void*)(this_arg & (~1));
41882         this_arg_conv.is_owned = false;
41883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41884         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
41885         return ret_conv;
41886 }
41887
41888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41889         LDKInitFeatures this_arg_conv;
41890         this_arg_conv.inner = (void*)(this_arg & (~1));
41891         this_arg_conv.is_owned = false;
41892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41893         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
41894         return ret_conv;
41895 }
41896
41897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41898         LDKNodeFeatures this_arg_conv;
41899         this_arg_conv.inner = (void*)(this_arg & (~1));
41900         this_arg_conv.is_owned = false;
41901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41902         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
41903         return ret_conv;
41904 }
41905
41906 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41907         LDKChannelTypeFeatures this_arg_conv;
41908         this_arg_conv.inner = (void*)(this_arg & (~1));
41909         this_arg_conv.is_owned = false;
41910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41911         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
41912         return ret_conv;
41913 }
41914
41915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41916         LDKInitFeatures this_arg_conv;
41917         this_arg_conv.inner = (void*)(this_arg & (~1));
41918         this_arg_conv.is_owned = false;
41919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41920         InitFeatures_set_payment_secret_optional(&this_arg_conv);
41921 }
41922
41923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41924         LDKInitFeatures this_arg_conv;
41925         this_arg_conv.inner = (void*)(this_arg & (~1));
41926         this_arg_conv.is_owned = false;
41927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41928         InitFeatures_set_payment_secret_required(&this_arg_conv);
41929 }
41930
41931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41932         LDKInitFeatures this_arg_conv;
41933         this_arg_conv.inner = (void*)(this_arg & (~1));
41934         this_arg_conv.is_owned = false;
41935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41936         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
41937         return ret_conv;
41938 }
41939
41940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41941         LDKNodeFeatures this_arg_conv;
41942         this_arg_conv.inner = (void*)(this_arg & (~1));
41943         this_arg_conv.is_owned = false;
41944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41945         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
41946 }
41947
41948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41949         LDKNodeFeatures this_arg_conv;
41950         this_arg_conv.inner = (void*)(this_arg & (~1));
41951         this_arg_conv.is_owned = false;
41952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41953         NodeFeatures_set_payment_secret_required(&this_arg_conv);
41954 }
41955
41956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41957         LDKNodeFeatures this_arg_conv;
41958         this_arg_conv.inner = (void*)(this_arg & (~1));
41959         this_arg_conv.is_owned = false;
41960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41961         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
41962         return ret_conv;
41963 }
41964
41965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41966         LDKInvoiceFeatures this_arg_conv;
41967         this_arg_conv.inner = (void*)(this_arg & (~1));
41968         this_arg_conv.is_owned = false;
41969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41970         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
41971 }
41972
41973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41974         LDKInvoiceFeatures this_arg_conv;
41975         this_arg_conv.inner = (void*)(this_arg & (~1));
41976         this_arg_conv.is_owned = false;
41977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41978         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
41979 }
41980
41981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41982         LDKInvoiceFeatures this_arg_conv;
41983         this_arg_conv.inner = (void*)(this_arg & (~1));
41984         this_arg_conv.is_owned = false;
41985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41986         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
41987         return ret_conv;
41988 }
41989
41990 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41991         LDKInitFeatures this_arg_conv;
41992         this_arg_conv.inner = (void*)(this_arg & (~1));
41993         this_arg_conv.is_owned = false;
41994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41995         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
41996         return ret_conv;
41997 }
41998
41999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42000         LDKNodeFeatures this_arg_conv;
42001         this_arg_conv.inner = (void*)(this_arg & (~1));
42002         this_arg_conv.is_owned = false;
42003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42004         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
42005         return ret_conv;
42006 }
42007
42008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42009         LDKInvoiceFeatures this_arg_conv;
42010         this_arg_conv.inner = (void*)(this_arg & (~1));
42011         this_arg_conv.is_owned = false;
42012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42013         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
42014         return ret_conv;
42015 }
42016
42017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42018         LDKInitFeatures this_arg_conv;
42019         this_arg_conv.inner = (void*)(this_arg & (~1));
42020         this_arg_conv.is_owned = false;
42021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42022         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
42023 }
42024
42025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42026         LDKInitFeatures this_arg_conv;
42027         this_arg_conv.inner = (void*)(this_arg & (~1));
42028         this_arg_conv.is_owned = false;
42029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42030         InitFeatures_set_basic_mpp_required(&this_arg_conv);
42031 }
42032
42033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42034         LDKInitFeatures this_arg_conv;
42035         this_arg_conv.inner = (void*)(this_arg & (~1));
42036         this_arg_conv.is_owned = false;
42037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42038         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
42039         return ret_conv;
42040 }
42041
42042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42043         LDKNodeFeatures this_arg_conv;
42044         this_arg_conv.inner = (void*)(this_arg & (~1));
42045         this_arg_conv.is_owned = false;
42046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42047         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
42048 }
42049
42050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42051         LDKNodeFeatures this_arg_conv;
42052         this_arg_conv.inner = (void*)(this_arg & (~1));
42053         this_arg_conv.is_owned = false;
42054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42055         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
42056 }
42057
42058 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42059         LDKNodeFeatures this_arg_conv;
42060         this_arg_conv.inner = (void*)(this_arg & (~1));
42061         this_arg_conv.is_owned = false;
42062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42063         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
42064         return ret_conv;
42065 }
42066
42067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42068         LDKInvoiceFeatures this_arg_conv;
42069         this_arg_conv.inner = (void*)(this_arg & (~1));
42070         this_arg_conv.is_owned = false;
42071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42072         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
42073 }
42074
42075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42076         LDKInvoiceFeatures this_arg_conv;
42077         this_arg_conv.inner = (void*)(this_arg & (~1));
42078         this_arg_conv.is_owned = false;
42079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42080         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
42081 }
42082
42083 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42084         LDKInvoiceFeatures this_arg_conv;
42085         this_arg_conv.inner = (void*)(this_arg & (~1));
42086         this_arg_conv.is_owned = false;
42087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42088         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
42089         return ret_conv;
42090 }
42091
42092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42093         LDKInitFeatures this_arg_conv;
42094         this_arg_conv.inner = (void*)(this_arg & (~1));
42095         this_arg_conv.is_owned = false;
42096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42097         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
42098         return ret_conv;
42099 }
42100
42101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42102         LDKNodeFeatures this_arg_conv;
42103         this_arg_conv.inner = (void*)(this_arg & (~1));
42104         this_arg_conv.is_owned = false;
42105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42106         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
42107         return ret_conv;
42108 }
42109
42110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42111         LDKInvoiceFeatures this_arg_conv;
42112         this_arg_conv.inner = (void*)(this_arg & (~1));
42113         this_arg_conv.is_owned = false;
42114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42115         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
42116         return ret_conv;
42117 }
42118
42119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42120         LDKInitFeatures this_arg_conv;
42121         this_arg_conv.inner = (void*)(this_arg & (~1));
42122         this_arg_conv.is_owned = false;
42123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42124         InitFeatures_set_wumbo_optional(&this_arg_conv);
42125 }
42126
42127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42128         LDKInitFeatures this_arg_conv;
42129         this_arg_conv.inner = (void*)(this_arg & (~1));
42130         this_arg_conv.is_owned = false;
42131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42132         InitFeatures_set_wumbo_required(&this_arg_conv);
42133 }
42134
42135 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42136         LDKInitFeatures this_arg_conv;
42137         this_arg_conv.inner = (void*)(this_arg & (~1));
42138         this_arg_conv.is_owned = false;
42139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42140         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
42141         return ret_conv;
42142 }
42143
42144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42145         LDKNodeFeatures this_arg_conv;
42146         this_arg_conv.inner = (void*)(this_arg & (~1));
42147         this_arg_conv.is_owned = false;
42148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42149         NodeFeatures_set_wumbo_optional(&this_arg_conv);
42150 }
42151
42152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42153         LDKNodeFeatures this_arg_conv;
42154         this_arg_conv.inner = (void*)(this_arg & (~1));
42155         this_arg_conv.is_owned = false;
42156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42157         NodeFeatures_set_wumbo_required(&this_arg_conv);
42158 }
42159
42160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42161         LDKNodeFeatures this_arg_conv;
42162         this_arg_conv.inner = (void*)(this_arg & (~1));
42163         this_arg_conv.is_owned = false;
42164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42165         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
42166         return ret_conv;
42167 }
42168
42169 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42170         LDKInitFeatures this_arg_conv;
42171         this_arg_conv.inner = (void*)(this_arg & (~1));
42172         this_arg_conv.is_owned = false;
42173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42174         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
42175         return ret_conv;
42176 }
42177
42178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42179         LDKNodeFeatures this_arg_conv;
42180         this_arg_conv.inner = (void*)(this_arg & (~1));
42181         this_arg_conv.is_owned = false;
42182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42183         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
42184         return ret_conv;
42185 }
42186
42187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42188         LDKInitFeatures this_arg_conv;
42189         this_arg_conv.inner = (void*)(this_arg & (~1));
42190         this_arg_conv.is_owned = false;
42191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42192         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42193 }
42194
42195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42196         LDKInitFeatures this_arg_conv;
42197         this_arg_conv.inner = (void*)(this_arg & (~1));
42198         this_arg_conv.is_owned = false;
42199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42200         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42201 }
42202
42203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42204         LDKInitFeatures this_arg_conv;
42205         this_arg_conv.inner = (void*)(this_arg & (~1));
42206         this_arg_conv.is_owned = false;
42207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42208         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42209         return ret_conv;
42210 }
42211
42212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42213         LDKNodeFeatures this_arg_conv;
42214         this_arg_conv.inner = (void*)(this_arg & (~1));
42215         this_arg_conv.is_owned = false;
42216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42217         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42218 }
42219
42220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42221         LDKNodeFeatures this_arg_conv;
42222         this_arg_conv.inner = (void*)(this_arg & (~1));
42223         this_arg_conv.is_owned = false;
42224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42225         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42226 }
42227
42228 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42229         LDKNodeFeatures this_arg_conv;
42230         this_arg_conv.inner = (void*)(this_arg & (~1));
42231         this_arg_conv.is_owned = false;
42232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42233         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42234         return ret_conv;
42235 }
42236
42237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42238         LDKInitFeatures this_arg_conv;
42239         this_arg_conv.inner = (void*)(this_arg & (~1));
42240         this_arg_conv.is_owned = false;
42241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42242         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42243         return ret_conv;
42244 }
42245
42246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42247         LDKNodeFeatures this_arg_conv;
42248         this_arg_conv.inner = (void*)(this_arg & (~1));
42249         this_arg_conv.is_owned = false;
42250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42251         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42252         return ret_conv;
42253 }
42254
42255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42256         LDKInitFeatures this_arg_conv;
42257         this_arg_conv.inner = (void*)(this_arg & (~1));
42258         this_arg_conv.is_owned = false;
42259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42260         InitFeatures_set_channel_type_optional(&this_arg_conv);
42261 }
42262
42263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42264         LDKInitFeatures this_arg_conv;
42265         this_arg_conv.inner = (void*)(this_arg & (~1));
42266         this_arg_conv.is_owned = false;
42267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42268         InitFeatures_set_channel_type_required(&this_arg_conv);
42269 }
42270
42271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42272         LDKInitFeatures this_arg_conv;
42273         this_arg_conv.inner = (void*)(this_arg & (~1));
42274         this_arg_conv.is_owned = false;
42275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42276         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
42277         return ret_conv;
42278 }
42279
42280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42281         LDKNodeFeatures this_arg_conv;
42282         this_arg_conv.inner = (void*)(this_arg & (~1));
42283         this_arg_conv.is_owned = false;
42284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42285         NodeFeatures_set_channel_type_optional(&this_arg_conv);
42286 }
42287
42288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42289         LDKNodeFeatures this_arg_conv;
42290         this_arg_conv.inner = (void*)(this_arg & (~1));
42291         this_arg_conv.is_owned = false;
42292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42293         NodeFeatures_set_channel_type_required(&this_arg_conv);
42294 }
42295
42296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42297         LDKNodeFeatures this_arg_conv;
42298         this_arg_conv.inner = (void*)(this_arg & (~1));
42299         this_arg_conv.is_owned = false;
42300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42301         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
42302         return ret_conv;
42303 }
42304
42305 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42306         LDKInitFeatures this_arg_conv;
42307         this_arg_conv.inner = (void*)(this_arg & (~1));
42308         this_arg_conv.is_owned = false;
42309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42310         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
42311         return ret_conv;
42312 }
42313
42314 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42315         LDKNodeFeatures this_arg_conv;
42316         this_arg_conv.inner = (void*)(this_arg & (~1));
42317         this_arg_conv.is_owned = false;
42318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42319         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
42320         return ret_conv;
42321 }
42322
42323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42324         LDKInitFeatures this_arg_conv;
42325         this_arg_conv.inner = (void*)(this_arg & (~1));
42326         this_arg_conv.is_owned = false;
42327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42328         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
42329 }
42330
42331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42332         LDKInitFeatures this_arg_conv;
42333         this_arg_conv.inner = (void*)(this_arg & (~1));
42334         this_arg_conv.is_owned = false;
42335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42336         InitFeatures_set_scid_privacy_required(&this_arg_conv);
42337 }
42338
42339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42340         LDKInitFeatures this_arg_conv;
42341         this_arg_conv.inner = (void*)(this_arg & (~1));
42342         this_arg_conv.is_owned = false;
42343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42344         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
42345         return ret_conv;
42346 }
42347
42348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42349         LDKNodeFeatures this_arg_conv;
42350         this_arg_conv.inner = (void*)(this_arg & (~1));
42351         this_arg_conv.is_owned = false;
42352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42353         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
42354 }
42355
42356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42357         LDKNodeFeatures this_arg_conv;
42358         this_arg_conv.inner = (void*)(this_arg & (~1));
42359         this_arg_conv.is_owned = false;
42360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42361         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
42362 }
42363
42364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42365         LDKNodeFeatures this_arg_conv;
42366         this_arg_conv.inner = (void*)(this_arg & (~1));
42367         this_arg_conv.is_owned = false;
42368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42369         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
42370         return ret_conv;
42371 }
42372
42373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42374         LDKChannelTypeFeatures this_arg_conv;
42375         this_arg_conv.inner = (void*)(this_arg & (~1));
42376         this_arg_conv.is_owned = false;
42377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42378         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
42379 }
42380
42381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42382         LDKChannelTypeFeatures this_arg_conv;
42383         this_arg_conv.inner = (void*)(this_arg & (~1));
42384         this_arg_conv.is_owned = false;
42385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42386         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
42387 }
42388
42389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42390         LDKChannelTypeFeatures this_arg_conv;
42391         this_arg_conv.inner = (void*)(this_arg & (~1));
42392         this_arg_conv.is_owned = false;
42393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42394         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
42395         return ret_conv;
42396 }
42397
42398 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42399         LDKInitFeatures this_arg_conv;
42400         this_arg_conv.inner = (void*)(this_arg & (~1));
42401         this_arg_conv.is_owned = false;
42402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42403         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
42404         return ret_conv;
42405 }
42406
42407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42408         LDKNodeFeatures this_arg_conv;
42409         this_arg_conv.inner = (void*)(this_arg & (~1));
42410         this_arg_conv.is_owned = false;
42411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42412         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
42413         return ret_conv;
42414 }
42415
42416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42417         LDKChannelTypeFeatures this_arg_conv;
42418         this_arg_conv.inner = (void*)(this_arg & (~1));
42419         this_arg_conv.is_owned = false;
42420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42421         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
42422         return ret_conv;
42423 }
42424
42425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42426         LDKInitFeatures this_arg_conv;
42427         this_arg_conv.inner = (void*)(this_arg & (~1));
42428         this_arg_conv.is_owned = false;
42429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42430         InitFeatures_set_zero_conf_optional(&this_arg_conv);
42431 }
42432
42433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42434         LDKInitFeatures this_arg_conv;
42435         this_arg_conv.inner = (void*)(this_arg & (~1));
42436         this_arg_conv.is_owned = false;
42437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42438         InitFeatures_set_zero_conf_required(&this_arg_conv);
42439 }
42440
42441 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42442         LDKInitFeatures this_arg_conv;
42443         this_arg_conv.inner = (void*)(this_arg & (~1));
42444         this_arg_conv.is_owned = false;
42445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42446         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
42447         return ret_conv;
42448 }
42449
42450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42451         LDKNodeFeatures this_arg_conv;
42452         this_arg_conv.inner = (void*)(this_arg & (~1));
42453         this_arg_conv.is_owned = false;
42454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42455         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
42456 }
42457
42458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42459         LDKNodeFeatures this_arg_conv;
42460         this_arg_conv.inner = (void*)(this_arg & (~1));
42461         this_arg_conv.is_owned = false;
42462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42463         NodeFeatures_set_zero_conf_required(&this_arg_conv);
42464 }
42465
42466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42467         LDKNodeFeatures this_arg_conv;
42468         this_arg_conv.inner = (void*)(this_arg & (~1));
42469         this_arg_conv.is_owned = false;
42470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42471         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
42472         return ret_conv;
42473 }
42474
42475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42476         LDKChannelTypeFeatures this_arg_conv;
42477         this_arg_conv.inner = (void*)(this_arg & (~1));
42478         this_arg_conv.is_owned = false;
42479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42480         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
42481 }
42482
42483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42484         LDKChannelTypeFeatures this_arg_conv;
42485         this_arg_conv.inner = (void*)(this_arg & (~1));
42486         this_arg_conv.is_owned = false;
42487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42488         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
42489 }
42490
42491 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42492         LDKChannelTypeFeatures this_arg_conv;
42493         this_arg_conv.inner = (void*)(this_arg & (~1));
42494         this_arg_conv.is_owned = false;
42495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42496         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
42497         return ret_conv;
42498 }
42499
42500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42501         LDKInitFeatures this_arg_conv;
42502         this_arg_conv.inner = (void*)(this_arg & (~1));
42503         this_arg_conv.is_owned = false;
42504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42505         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
42506         return ret_conv;
42507 }
42508
42509 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42510         LDKNodeFeatures this_arg_conv;
42511         this_arg_conv.inner = (void*)(this_arg & (~1));
42512         this_arg_conv.is_owned = false;
42513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42514         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
42515         return ret_conv;
42516 }
42517
42518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42519         LDKChannelTypeFeatures this_arg_conv;
42520         this_arg_conv.inner = (void*)(this_arg & (~1));
42521         this_arg_conv.is_owned = false;
42522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42523         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
42524         return ret_conv;
42525 }
42526
42527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42528         LDKNodeFeatures this_arg_conv;
42529         this_arg_conv.inner = (void*)(this_arg & (~1));
42530         this_arg_conv.is_owned = false;
42531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42532         NodeFeatures_set_keysend_optional(&this_arg_conv);
42533 }
42534
42535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42536         LDKNodeFeatures this_arg_conv;
42537         this_arg_conv.inner = (void*)(this_arg & (~1));
42538         this_arg_conv.is_owned = false;
42539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42540         NodeFeatures_set_keysend_required(&this_arg_conv);
42541 }
42542
42543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
42544         LDKNodeFeatures this_arg_conv;
42545         this_arg_conv.inner = (void*)(this_arg & (~1));
42546         this_arg_conv.is_owned = false;
42547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42548         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
42549         return ret_conv;
42550 }
42551
42552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
42553         LDKNodeFeatures this_arg_conv;
42554         this_arg_conv.inner = (void*)(this_arg & (~1));
42555         this_arg_conv.is_owned = false;
42556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42557         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
42558         return ret_conv;
42559 }
42560
42561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42562         LDKShutdownScript this_obj_conv;
42563         this_obj_conv.inner = (void*)(this_obj & (~1));
42564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42566         ShutdownScript_free(this_obj_conv);
42567 }
42568
42569 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
42570         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
42571 int64_t ret_ref = 0;
42572 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42573 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42574 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42575 ret_ref = (uintptr_t)ret_var.inner;
42576 if (ret_var.is_owned) {
42577         ret_ref |= 1;
42578 }
42579         return ret_ref;
42580 }
42581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42582         LDKShutdownScript arg_conv;
42583         arg_conv.inner = (void*)(arg & (~1));
42584         arg_conv.is_owned = false;
42585         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42586         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
42587         return ret_conv;
42588 }
42589
42590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42591         LDKShutdownScript orig_conv;
42592         orig_conv.inner = (void*)(orig & (~1));
42593         orig_conv.is_owned = false;
42594         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42595         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
42596         int64_t ret_ref = 0;
42597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42600         ret_ref = (uintptr_t)ret_var.inner;
42601         if (ret_var.is_owned) {
42602                 ret_ref |= 1;
42603         }
42604         return ret_ref;
42605 }
42606
42607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42608         LDKInvalidShutdownScript this_obj_conv;
42609         this_obj_conv.inner = (void*)(this_obj & (~1));
42610         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42612         InvalidShutdownScript_free(this_obj_conv);
42613 }
42614
42615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
42616         LDKInvalidShutdownScript this_ptr_conv;
42617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42618         this_ptr_conv.is_owned = false;
42619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42620         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
42621         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42622         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42623         return ret_arr;
42624 }
42625
42626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42627         LDKInvalidShutdownScript this_ptr_conv;
42628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42629         this_ptr_conv.is_owned = false;
42630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42631         LDKCVec_u8Z val_ref;
42632         val_ref.datalen = (*env)->GetArrayLength(env, val);
42633         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
42634         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
42635         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
42636 }
42637
42638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
42639         LDKCVec_u8Z script_arg_ref;
42640         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
42641         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
42642         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
42643         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
42644         int64_t ret_ref = 0;
42645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42648         ret_ref = (uintptr_t)ret_var.inner;
42649         if (ret_var.is_owned) {
42650                 ret_ref |= 1;
42651         }
42652         return ret_ref;
42653 }
42654
42655 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
42656         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
42657 int64_t ret_ref = 0;
42658 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42659 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42660 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42661 ret_ref = (uintptr_t)ret_var.inner;
42662 if (ret_var.is_owned) {
42663         ret_ref |= 1;
42664 }
42665         return ret_ref;
42666 }
42667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42668         LDKInvalidShutdownScript arg_conv;
42669         arg_conv.inner = (void*)(arg & (~1));
42670         arg_conv.is_owned = false;
42671         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42672         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
42673         return ret_conv;
42674 }
42675
42676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42677         LDKInvalidShutdownScript orig_conv;
42678         orig_conv.inner = (void*)(orig & (~1));
42679         orig_conv.is_owned = false;
42680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42681         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
42682         int64_t ret_ref = 0;
42683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42686         ret_ref = (uintptr_t)ret_var.inner;
42687         if (ret_var.is_owned) {
42688                 ret_ref |= 1;
42689         }
42690         return ret_ref;
42691 }
42692
42693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
42694         LDKShutdownScript obj_conv;
42695         obj_conv.inner = (void*)(obj & (~1));
42696         obj_conv.is_owned = false;
42697         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42698         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
42699         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42700         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42701         CVec_u8Z_free(ret_var);
42702         return ret_arr;
42703 }
42704
42705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42706         LDKu8slice ser_ref;
42707         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42708         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42709         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
42710         *ret_conv = ShutdownScript_read(ser_ref);
42711         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42712         return (int64_t)ret_conv;
42713 }
42714
42715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
42716         unsigned char pubkey_hash_arr[20];
42717         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
42718         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
42719         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
42720         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
42721         int64_t ret_ref = 0;
42722         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42723         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42725         ret_ref = (uintptr_t)ret_var.inner;
42726         if (ret_var.is_owned) {
42727                 ret_ref |= 1;
42728         }
42729         return ret_ref;
42730 }
42731
42732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
42733         unsigned char script_hash_arr[32];
42734         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
42735         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
42736         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
42737         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
42738         int64_t ret_ref = 0;
42739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42742         ret_ref = (uintptr_t)ret_var.inner;
42743         if (ret_var.is_owned) {
42744                 ret_ref |= 1;
42745         }
42746         return ret_ref;
42747 }
42748
42749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
42750         
42751         LDKu8slice program_ref;
42752         program_ref.datalen = (*env)->GetArrayLength(env, program);
42753         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
42754         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
42755         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
42756         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
42757         return (int64_t)ret_conv;
42758 }
42759
42760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
42761         LDKShutdownScript this_arg_conv;
42762         this_arg_conv.inner = (void*)(this_arg & (~1));
42763         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
42764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42765         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
42766         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
42767         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42768         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42769         CVec_u8Z_free(ret_var);
42770         return ret_arr;
42771 }
42772
42773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
42774         LDKShutdownScript this_arg_conv;
42775         this_arg_conv.inner = (void*)(this_arg & (~1));
42776         this_arg_conv.is_owned = false;
42777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42778         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
42780         return ret_arr;
42781 }
42782
42783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
42784         LDKShutdownScript this_arg_conv;
42785         this_arg_conv.inner = (void*)(this_arg & (~1));
42786         this_arg_conv.is_owned = false;
42787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42788         LDKInitFeatures features_conv;
42789         features_conv.inner = (void*)(features & (~1));
42790         features_conv.is_owned = false;
42791         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
42792         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
42793         return ret_conv;
42794 }
42795
42796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42797         if ((this_ptr & 1) != 0) return;
42798         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42799         CHECK_ACCESS(this_ptr_ptr);
42800         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
42801         FREE((void*)this_ptr);
42802         CustomMessageReader_free(this_ptr_conv);
42803 }
42804
42805 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
42806         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
42807         *ret_ret = Type_clone(arg);
42808         return (int64_t)ret_ret;
42809 }
42810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42811         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
42812         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
42813         LDKType* arg_conv = (LDKType*)arg_ptr;
42814         int64_t ret_conv = Type_clone_ptr(arg_conv);
42815         return ret_conv;
42816 }
42817
42818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42819         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
42820         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
42821         LDKType* orig_conv = (LDKType*)orig_ptr;
42822         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
42823         *ret_ret = Type_clone(orig_conv);
42824         return (int64_t)ret_ret;
42825 }
42826
42827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42828         if ((this_ptr & 1) != 0) return;
42829         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42830         CHECK_ACCESS(this_ptr_ptr);
42831         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
42832         FREE((void*)this_ptr);
42833         Type_free(this_ptr_conv);
42834 }
42835
42836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42837         LDKNodeId this_obj_conv;
42838         this_obj_conv.inner = (void*)(this_obj & (~1));
42839         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42841         NodeId_free(this_obj_conv);
42842 }
42843
42844 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
42845         LDKNodeId ret_var = NodeId_clone(arg);
42846 int64_t ret_ref = 0;
42847 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42848 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42849 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42850 ret_ref = (uintptr_t)ret_var.inner;
42851 if (ret_var.is_owned) {
42852         ret_ref |= 1;
42853 }
42854         return ret_ref;
42855 }
42856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42857         LDKNodeId arg_conv;
42858         arg_conv.inner = (void*)(arg & (~1));
42859         arg_conv.is_owned = false;
42860         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42861         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
42862         return ret_conv;
42863 }
42864
42865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42866         LDKNodeId orig_conv;
42867         orig_conv.inner = (void*)(orig & (~1));
42868         orig_conv.is_owned = false;
42869         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42870         LDKNodeId ret_var = NodeId_clone(&orig_conv);
42871         int64_t ret_ref = 0;
42872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42875         ret_ref = (uintptr_t)ret_var.inner;
42876         if (ret_var.is_owned) {
42877                 ret_ref |= 1;
42878         }
42879         return ret_ref;
42880 }
42881
42882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
42883         LDKPublicKey pubkey_ref;
42884         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
42885         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
42886         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
42887         int64_t ret_ref = 0;
42888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42891         ret_ref = (uintptr_t)ret_var.inner;
42892         if (ret_var.is_owned) {
42893                 ret_ref |= 1;
42894         }
42895         return ret_ref;
42896 }
42897
42898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
42899         LDKNodeId this_arg_conv;
42900         this_arg_conv.inner = (void*)(this_arg & (~1));
42901         this_arg_conv.is_owned = false;
42902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42903         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
42904         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42905         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42906         return ret_arr;
42907 }
42908
42909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
42910         LDKNodeId o_conv;
42911         o_conv.inner = (void*)(o & (~1));
42912         o_conv.is_owned = false;
42913         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42914         int64_t ret_conv = NodeId_hash(&o_conv);
42915         return ret_conv;
42916 }
42917
42918 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
42919         LDKNodeId obj_conv;
42920         obj_conv.inner = (void*)(obj & (~1));
42921         obj_conv.is_owned = false;
42922         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42923         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
42924         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42925         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42926         CVec_u8Z_free(ret_var);
42927         return ret_arr;
42928 }
42929
42930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42931         LDKu8slice ser_ref;
42932         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42933         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42934         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
42935         *ret_conv = NodeId_read(ser_ref);
42936         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42937         return (int64_t)ret_conv;
42938 }
42939
42940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42941         LDKNetworkGraph this_obj_conv;
42942         this_obj_conv.inner = (void*)(this_obj & (~1));
42943         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42945         NetworkGraph_free(this_obj_conv);
42946 }
42947
42948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42949         LDKReadOnlyNetworkGraph this_obj_conv;
42950         this_obj_conv.inner = (void*)(this_obj & (~1));
42951         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42953         ReadOnlyNetworkGraph_free(this_obj_conv);
42954 }
42955
42956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42957         if ((this_ptr & 1) != 0) return;
42958         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42959         CHECK_ACCESS(this_ptr_ptr);
42960         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
42961         FREE((void*)this_ptr);
42962         NetworkUpdate_free(this_ptr_conv);
42963 }
42964
42965 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
42966         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42967         *ret_copy = NetworkUpdate_clone(arg);
42968 int64_t ret_ref = (uintptr_t)ret_copy;
42969         return ret_ref;
42970 }
42971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42972         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
42973         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
42974         return ret_conv;
42975 }
42976
42977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42978         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
42979         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42980         *ret_copy = NetworkUpdate_clone(orig_conv);
42981         int64_t ret_ref = (uintptr_t)ret_copy;
42982         return ret_ref;
42983 }
42984
42985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
42986         LDKChannelUpdate msg_conv;
42987         msg_conv.inner = (void*)(msg & (~1));
42988         msg_conv.is_owned = (msg & 1) || (msg == 0);
42989         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42990         msg_conv = ChannelUpdate_clone(&msg_conv);
42991         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42992         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
42993         int64_t ret_ref = (uintptr_t)ret_copy;
42994         return ret_ref;
42995 }
42996
42997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
42998         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42999         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
43000         int64_t ret_ref = (uintptr_t)ret_copy;
43001         return ret_ref;
43002 }
43003
43004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
43005         LDKPublicKey node_id_ref;
43006         CHECK((*env)->GetArrayLength(env, node_id) == 33);
43007         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
43008         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
43009         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
43010         int64_t ret_ref = (uintptr_t)ret_copy;
43011         return ret_ref;
43012 }
43013
43014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
43015         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
43016         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
43017         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43018         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43019         CVec_u8Z_free(ret_var);
43020         return ret_arr;
43021 }
43022
43023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43024         LDKu8slice ser_ref;
43025         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43026         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43027         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
43028         *ret_conv = NetworkUpdate_read(ser_ref);
43029         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43030         return (int64_t)ret_conv;
43031 }
43032
43033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43034         LDKP2PGossipSync this_obj_conv;
43035         this_obj_conv.inner = (void*)(this_obj & (~1));
43036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43038         P2PGossipSync_free(this_obj_conv);
43039 }
43040
43041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
43042         LDKNetworkGraph network_graph_conv;
43043         network_graph_conv.inner = (void*)(network_graph & (~1));
43044         network_graph_conv.is_owned = false;
43045         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43046         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43047         CHECK_ACCESS(chain_access_ptr);
43048         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43049         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43050         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43051                 // Manually implement clone for Java trait instances
43052                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43053                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43054                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43055                 }
43056         }
43057         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43058         CHECK_ACCESS(logger_ptr);
43059         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43060         if (logger_conv.free == LDKLogger_JCalls_free) {
43061                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43062                 LDKLogger_JCalls_cloned(&logger_conv);
43063         }
43064         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
43065         int64_t ret_ref = 0;
43066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43069         ret_ref = (uintptr_t)ret_var.inner;
43070         if (ret_var.is_owned) {
43071                 ret_ref |= 1;
43072         }
43073         return ret_ref;
43074 }
43075
43076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
43077         LDKP2PGossipSync this_arg_conv;
43078         this_arg_conv.inner = (void*)(this_arg & (~1));
43079         this_arg_conv.is_owned = false;
43080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43081         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43082         CHECK_ACCESS(chain_access_ptr);
43083         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43084         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43085         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43086                 // Manually implement clone for Java trait instances
43087                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43088                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43089                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43090                 }
43091         }
43092         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
43093 }
43094
43095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
43096         LDKNetworkGraph this_arg_conv;
43097         this_arg_conv.inner = (void*)(this_arg & (~1));
43098         this_arg_conv.is_owned = false;
43099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43100         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
43101         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
43102         return (int64_t)ret_ret;
43103 }
43104
43105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
43106         LDKP2PGossipSync this_arg_conv;
43107         this_arg_conv.inner = (void*)(this_arg & (~1));
43108         this_arg_conv.is_owned = false;
43109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43110         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
43111         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
43112         return (int64_t)ret_ret;
43113 }
43114
43115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
43116         LDKP2PGossipSync this_arg_conv;
43117         this_arg_conv.inner = (void*)(this_arg & (~1));
43118         this_arg_conv.is_owned = false;
43119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43120         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
43121         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
43122         return (int64_t)ret_ret;
43123 }
43124
43125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43126         LDKChannelUpdateInfo this_obj_conv;
43127         this_obj_conv.inner = (void*)(this_obj & (~1));
43128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43130         ChannelUpdateInfo_free(this_obj_conv);
43131 }
43132
43133 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
43134         LDKChannelUpdateInfo this_ptr_conv;
43135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43136         this_ptr_conv.is_owned = false;
43137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43138         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
43139         return ret_conv;
43140 }
43141
43142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43143         LDKChannelUpdateInfo this_ptr_conv;
43144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43145         this_ptr_conv.is_owned = false;
43146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43147         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
43148 }
43149
43150 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
43151         LDKChannelUpdateInfo this_ptr_conv;
43152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43153         this_ptr_conv.is_owned = false;
43154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43155         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
43156         return ret_conv;
43157 }
43158
43159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43160         LDKChannelUpdateInfo this_ptr_conv;
43161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43162         this_ptr_conv.is_owned = false;
43163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43164         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
43165 }
43166
43167 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
43168         LDKChannelUpdateInfo this_ptr_conv;
43169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43170         this_ptr_conv.is_owned = false;
43171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43172         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
43173         return ret_conv;
43174 }
43175
43176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43177         LDKChannelUpdateInfo this_ptr_conv;
43178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43179         this_ptr_conv.is_owned = false;
43180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43181         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
43182 }
43183
43184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43185         LDKChannelUpdateInfo this_ptr_conv;
43186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43187         this_ptr_conv.is_owned = false;
43188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43189         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
43190         return ret_conv;
43191 }
43192
43193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43194         LDKChannelUpdateInfo this_ptr_conv;
43195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43196         this_ptr_conv.is_owned = false;
43197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43198         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
43199 }
43200
43201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43202         LDKChannelUpdateInfo this_ptr_conv;
43203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43204         this_ptr_conv.is_owned = false;
43205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43206         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
43207         return ret_conv;
43208 }
43209
43210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43211         LDKChannelUpdateInfo this_ptr_conv;
43212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43213         this_ptr_conv.is_owned = false;
43214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43215         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
43216 }
43217
43218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
43219         LDKChannelUpdateInfo this_ptr_conv;
43220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43221         this_ptr_conv.is_owned = false;
43222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43223         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
43224         int64_t ret_ref = 0;
43225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43228         ret_ref = (uintptr_t)ret_var.inner;
43229         if (ret_var.is_owned) {
43230                 ret_ref |= 1;
43231         }
43232         return ret_ref;
43233 }
43234
43235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43236         LDKChannelUpdateInfo this_ptr_conv;
43237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43238         this_ptr_conv.is_owned = false;
43239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43240         LDKRoutingFees val_conv;
43241         val_conv.inner = (void*)(val & (~1));
43242         val_conv.is_owned = (val & 1) || (val == 0);
43243         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43244         val_conv = RoutingFees_clone(&val_conv);
43245         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
43246 }
43247
43248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43249         LDKChannelUpdateInfo this_ptr_conv;
43250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43251         this_ptr_conv.is_owned = false;
43252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43253         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
43254         int64_t ret_ref = 0;
43255         if ((uintptr_t)ret_var.inner > 4096) {
43256                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43257                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43259                 ret_ref = (uintptr_t)ret_var.inner;
43260                 if (ret_var.is_owned) {
43261                         ret_ref |= 1;
43262                 }
43263         }
43264         return ret_ref;
43265 }
43266
43267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43268         LDKChannelUpdateInfo this_ptr_conv;
43269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43270         this_ptr_conv.is_owned = false;
43271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43272         LDKChannelUpdate val_conv;
43273         val_conv.inner = (void*)(val & (~1));
43274         val_conv.is_owned = (val & 1) || (val == 0);
43275         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43276         val_conv = ChannelUpdate_clone(&val_conv);
43277         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
43278 }
43279
43280 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) {
43281         LDKRoutingFees fees_arg_conv;
43282         fees_arg_conv.inner = (void*)(fees_arg & (~1));
43283         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
43284         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
43285         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
43286         LDKChannelUpdate last_update_message_arg_conv;
43287         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
43288         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
43289         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
43290         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
43291         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg_conv, last_update_message_arg_conv);
43292         int64_t ret_ref = 0;
43293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43296         ret_ref = (uintptr_t)ret_var.inner;
43297         if (ret_var.is_owned) {
43298                 ret_ref |= 1;
43299         }
43300         return ret_ref;
43301 }
43302
43303 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
43304         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
43305 int64_t ret_ref = 0;
43306 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43307 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43308 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43309 ret_ref = (uintptr_t)ret_var.inner;
43310 if (ret_var.is_owned) {
43311         ret_ref |= 1;
43312 }
43313         return ret_ref;
43314 }
43315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43316         LDKChannelUpdateInfo arg_conv;
43317         arg_conv.inner = (void*)(arg & (~1));
43318         arg_conv.is_owned = false;
43319         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43320         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
43321         return ret_conv;
43322 }
43323
43324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43325         LDKChannelUpdateInfo orig_conv;
43326         orig_conv.inner = (void*)(orig & (~1));
43327         orig_conv.is_owned = false;
43328         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43329         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
43330         int64_t ret_ref = 0;
43331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43334         ret_ref = (uintptr_t)ret_var.inner;
43335         if (ret_var.is_owned) {
43336                 ret_ref |= 1;
43337         }
43338         return ret_ref;
43339 }
43340
43341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43342         LDKChannelUpdateInfo obj_conv;
43343         obj_conv.inner = (void*)(obj & (~1));
43344         obj_conv.is_owned = false;
43345         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43346         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
43347         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43348         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43349         CVec_u8Z_free(ret_var);
43350         return ret_arr;
43351 }
43352
43353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43354         LDKu8slice ser_ref;
43355         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43356         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43357         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
43358         *ret_conv = ChannelUpdateInfo_read(ser_ref);
43359         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43360         return (int64_t)ret_conv;
43361 }
43362
43363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43364         LDKChannelInfo this_obj_conv;
43365         this_obj_conv.inner = (void*)(this_obj & (~1));
43366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43368         ChannelInfo_free(this_obj_conv);
43369 }
43370
43371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43372         LDKChannelInfo this_ptr_conv;
43373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43374         this_ptr_conv.is_owned = false;
43375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43376         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
43377         int64_t ret_ref = 0;
43378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43381         ret_ref = (uintptr_t)ret_var.inner;
43382         if (ret_var.is_owned) {
43383                 ret_ref |= 1;
43384         }
43385         return ret_ref;
43386 }
43387
43388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43389         LDKChannelInfo this_ptr_conv;
43390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43391         this_ptr_conv.is_owned = false;
43392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43393         LDKChannelFeatures val_conv;
43394         val_conv.inner = (void*)(val & (~1));
43395         val_conv.is_owned = (val & 1) || (val == 0);
43396         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43397         val_conv = ChannelFeatures_clone(&val_conv);
43398         ChannelInfo_set_features(&this_ptr_conv, val_conv);
43399 }
43400
43401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43402         LDKChannelInfo this_ptr_conv;
43403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43404         this_ptr_conv.is_owned = false;
43405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43406         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
43407         int64_t ret_ref = 0;
43408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43411         ret_ref = (uintptr_t)ret_var.inner;
43412         if (ret_var.is_owned) {
43413                 ret_ref |= 1;
43414         }
43415         return ret_ref;
43416 }
43417
43418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43419         LDKChannelInfo this_ptr_conv;
43420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43421         this_ptr_conv.is_owned = false;
43422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43423         LDKNodeId val_conv;
43424         val_conv.inner = (void*)(val & (~1));
43425         val_conv.is_owned = (val & 1) || (val == 0);
43426         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43427         val_conv = NodeId_clone(&val_conv);
43428         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
43429 }
43430
43431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43432         LDKChannelInfo this_ptr_conv;
43433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43434         this_ptr_conv.is_owned = false;
43435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43436         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
43437         int64_t ret_ref = 0;
43438         if ((uintptr_t)ret_var.inner > 4096) {
43439                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43440                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43442                 ret_ref = (uintptr_t)ret_var.inner;
43443                 if (ret_var.is_owned) {
43444                         ret_ref |= 1;
43445                 }
43446         }
43447         return ret_ref;
43448 }
43449
43450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43451         LDKChannelInfo this_ptr_conv;
43452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43453         this_ptr_conv.is_owned = false;
43454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43455         LDKChannelUpdateInfo val_conv;
43456         val_conv.inner = (void*)(val & (~1));
43457         val_conv.is_owned = (val & 1) || (val == 0);
43458         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43459         val_conv = ChannelUpdateInfo_clone(&val_conv);
43460         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
43461 }
43462
43463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43464         LDKChannelInfo this_ptr_conv;
43465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43466         this_ptr_conv.is_owned = false;
43467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43468         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
43469         int64_t ret_ref = 0;
43470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43473         ret_ref = (uintptr_t)ret_var.inner;
43474         if (ret_var.is_owned) {
43475                 ret_ref |= 1;
43476         }
43477         return ret_ref;
43478 }
43479
43480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43481         LDKChannelInfo this_ptr_conv;
43482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43483         this_ptr_conv.is_owned = false;
43484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43485         LDKNodeId val_conv;
43486         val_conv.inner = (void*)(val & (~1));
43487         val_conv.is_owned = (val & 1) || (val == 0);
43488         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43489         val_conv = NodeId_clone(&val_conv);
43490         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
43491 }
43492
43493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43494         LDKChannelInfo this_ptr_conv;
43495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43496         this_ptr_conv.is_owned = false;
43497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43498         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
43499         int64_t ret_ref = 0;
43500         if ((uintptr_t)ret_var.inner > 4096) {
43501                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43502                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43504                 ret_ref = (uintptr_t)ret_var.inner;
43505                 if (ret_var.is_owned) {
43506                         ret_ref |= 1;
43507                 }
43508         }
43509         return ret_ref;
43510 }
43511
43512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43513         LDKChannelInfo this_ptr_conv;
43514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43515         this_ptr_conv.is_owned = false;
43516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43517         LDKChannelUpdateInfo val_conv;
43518         val_conv.inner = (void*)(val & (~1));
43519         val_conv.is_owned = (val & 1) || (val == 0);
43520         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43521         val_conv = ChannelUpdateInfo_clone(&val_conv);
43522         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
43523 }
43524
43525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
43526         LDKChannelInfo this_ptr_conv;
43527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43528         this_ptr_conv.is_owned = false;
43529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43530         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43531         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
43532         int64_t ret_ref = (uintptr_t)ret_copy;
43533         return ret_ref;
43534 }
43535
43536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43537         LDKChannelInfo this_ptr_conv;
43538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43539         this_ptr_conv.is_owned = false;
43540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43541         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
43542         CHECK_ACCESS(val_ptr);
43543         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
43544         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
43545         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
43546 }
43547
43548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43549         LDKChannelInfo this_ptr_conv;
43550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43551         this_ptr_conv.is_owned = false;
43552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43553         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
43554         int64_t ret_ref = 0;
43555         if ((uintptr_t)ret_var.inner > 4096) {
43556                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43557                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43559                 ret_ref = (uintptr_t)ret_var.inner;
43560                 if (ret_var.is_owned) {
43561                         ret_ref |= 1;
43562                 }
43563         }
43564         return ret_ref;
43565 }
43566
43567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43568         LDKChannelInfo this_ptr_conv;
43569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43570         this_ptr_conv.is_owned = false;
43571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43572         LDKChannelAnnouncement val_conv;
43573         val_conv.inner = (void*)(val & (~1));
43574         val_conv.is_owned = (val & 1) || (val == 0);
43575         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43576         val_conv = ChannelAnnouncement_clone(&val_conv);
43577         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
43578 }
43579
43580 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
43581         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
43582 int64_t ret_ref = 0;
43583 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43584 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43585 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43586 ret_ref = (uintptr_t)ret_var.inner;
43587 if (ret_var.is_owned) {
43588         ret_ref |= 1;
43589 }
43590         return ret_ref;
43591 }
43592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43593         LDKChannelInfo arg_conv;
43594         arg_conv.inner = (void*)(arg & (~1));
43595         arg_conv.is_owned = false;
43596         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43597         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
43598         return ret_conv;
43599 }
43600
43601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43602         LDKChannelInfo orig_conv;
43603         orig_conv.inner = (void*)(orig & (~1));
43604         orig_conv.is_owned = false;
43605         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43606         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
43607         int64_t ret_ref = 0;
43608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43611         ret_ref = (uintptr_t)ret_var.inner;
43612         if (ret_var.is_owned) {
43613                 ret_ref |= 1;
43614         }
43615         return ret_ref;
43616 }
43617
43618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1directional_1info(JNIEnv *env, jclass clz, int64_t this_arg, int8_t channel_flags) {
43619         LDKChannelInfo this_arg_conv;
43620         this_arg_conv.inner = (void*)(this_arg & (~1));
43621         this_arg_conv.is_owned = false;
43622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43623         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
43624         int64_t ret_ref = 0;
43625         if ((uintptr_t)ret_var.inner > 4096) {
43626                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43627                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43629                 ret_ref = (uintptr_t)ret_var.inner;
43630                 if (ret_var.is_owned) {
43631                         ret_ref |= 1;
43632                 }
43633         }
43634         return ret_ref;
43635 }
43636
43637 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43638         LDKChannelInfo obj_conv;
43639         obj_conv.inner = (void*)(obj & (~1));
43640         obj_conv.is_owned = false;
43641         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43642         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
43643         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43644         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43645         CVec_u8Z_free(ret_var);
43646         return ret_arr;
43647 }
43648
43649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43650         LDKu8slice ser_ref;
43651         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43652         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43653         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
43654         *ret_conv = ChannelInfo_read(ser_ref);
43655         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43656         return (int64_t)ret_conv;
43657 }
43658
43659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43660         LDKDirectedChannelInfo this_obj_conv;
43661         this_obj_conv.inner = (void*)(this_obj & (~1));
43662         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43664         DirectedChannelInfo_free(this_obj_conv);
43665 }
43666
43667 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
43668         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
43669 int64_t ret_ref = 0;
43670 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43671 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43672 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43673 ret_ref = (uintptr_t)ret_var.inner;
43674 if (ret_var.is_owned) {
43675         ret_ref |= 1;
43676 }
43677         return ret_ref;
43678 }
43679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43680         LDKDirectedChannelInfo arg_conv;
43681         arg_conv.inner = (void*)(arg & (~1));
43682         arg_conv.is_owned = false;
43683         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43684         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
43685         return ret_conv;
43686 }
43687
43688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43689         LDKDirectedChannelInfo orig_conv;
43690         orig_conv.inner = (void*)(orig & (~1));
43691         orig_conv.is_owned = false;
43692         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43693         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
43694         int64_t ret_ref = 0;
43695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43698         ret_ref = (uintptr_t)ret_var.inner;
43699         if (ret_var.is_owned) {
43700                 ret_ref |= 1;
43701         }
43702         return ret_ref;
43703 }
43704
43705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
43706         LDKDirectedChannelInfo this_arg_conv;
43707         this_arg_conv.inner = (void*)(this_arg & (~1));
43708         this_arg_conv.is_owned = false;
43709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43710         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
43711         int64_t ret_ref = 0;
43712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43715         ret_ref = (uintptr_t)ret_var.inner;
43716         if (ret_var.is_owned) {
43717                 ret_ref |= 1;
43718         }
43719         return ret_ref;
43720 }
43721
43722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
43723         LDKDirectedChannelInfo this_arg_conv;
43724         this_arg_conv.inner = (void*)(this_arg & (~1));
43725         this_arg_conv.is_owned = false;
43726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43727         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
43728         int64_t ret_ref = 0;
43729         if ((uintptr_t)ret_var.inner > 4096) {
43730                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43731                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43733                 ret_ref = (uintptr_t)ret_var.inner;
43734                 if (ret_var.is_owned) {
43735                         ret_ref |= 1;
43736                 }
43737         }
43738         return ret_ref;
43739 }
43740
43741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
43742         LDKDirectedChannelInfo this_arg_conv;
43743         this_arg_conv.inner = (void*)(this_arg & (~1));
43744         this_arg_conv.is_owned = false;
43745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43746         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
43747         return ret_conv;
43748 }
43749
43750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
43751         LDKDirectedChannelInfo this_arg_conv;
43752         this_arg_conv.inner = (void*)(this_arg & (~1));
43753         this_arg_conv.is_owned = false;
43754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43755         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43756         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
43757         int64_t ret_ref = (uintptr_t)ret_copy;
43758         return ret_ref;
43759 }
43760
43761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43762         if ((this_ptr & 1) != 0) return;
43763         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43764         CHECK_ACCESS(this_ptr_ptr);
43765         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
43766         FREE((void*)this_ptr);
43767         EffectiveCapacity_free(this_ptr_conv);
43768 }
43769
43770 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
43771         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43772         *ret_copy = EffectiveCapacity_clone(arg);
43773 int64_t ret_ref = (uintptr_t)ret_copy;
43774         return ret_ref;
43775 }
43776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43777         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
43778         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
43779         return ret_conv;
43780 }
43781
43782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43783         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
43784         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43785         *ret_copy = EffectiveCapacity_clone(orig_conv);
43786         int64_t ret_ref = (uintptr_t)ret_copy;
43787         return ret_ref;
43788 }
43789
43790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
43791         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43792         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
43793         int64_t ret_ref = (uintptr_t)ret_copy;
43794         return ret_ref;
43795 }
43796
43797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
43798         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43799         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
43800         int64_t ret_ref = (uintptr_t)ret_copy;
43801         return ret_ref;
43802 }
43803
43804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
43805         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
43806         CHECK_ACCESS(htlc_maximum_msat_ptr);
43807         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
43808         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
43809         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43810         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
43811         int64_t ret_ref = (uintptr_t)ret_copy;
43812         return ret_ref;
43813 }
43814
43815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
43816         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43817         *ret_copy = EffectiveCapacity_infinite();
43818         int64_t ret_ref = (uintptr_t)ret_copy;
43819         return ret_ref;
43820 }
43821
43822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
43823         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43824         *ret_copy = EffectiveCapacity_unknown();
43825         int64_t ret_ref = (uintptr_t)ret_copy;
43826         return ret_ref;
43827 }
43828
43829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
43830         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
43831         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
43832         return ret_conv;
43833 }
43834
43835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43836         LDKRoutingFees this_obj_conv;
43837         this_obj_conv.inner = (void*)(this_obj & (~1));
43838         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43840         RoutingFees_free(this_obj_conv);
43841 }
43842
43843 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43844         LDKRoutingFees this_ptr_conv;
43845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43846         this_ptr_conv.is_owned = false;
43847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43848         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
43849         return ret_conv;
43850 }
43851
43852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43853         LDKRoutingFees this_ptr_conv;
43854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43855         this_ptr_conv.is_owned = false;
43856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43857         RoutingFees_set_base_msat(&this_ptr_conv, val);
43858 }
43859
43860 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
43861         LDKRoutingFees this_ptr_conv;
43862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43863         this_ptr_conv.is_owned = false;
43864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43865         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
43866         return ret_conv;
43867 }
43868
43869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43870         LDKRoutingFees this_ptr_conv;
43871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43872         this_ptr_conv.is_owned = false;
43873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43874         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
43875 }
43876
43877 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) {
43878         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
43879         int64_t ret_ref = 0;
43880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43883         ret_ref = (uintptr_t)ret_var.inner;
43884         if (ret_var.is_owned) {
43885                 ret_ref |= 1;
43886         }
43887         return ret_ref;
43888 }
43889
43890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43891         LDKRoutingFees a_conv;
43892         a_conv.inner = (void*)(a & (~1));
43893         a_conv.is_owned = false;
43894         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43895         LDKRoutingFees b_conv;
43896         b_conv.inner = (void*)(b & (~1));
43897         b_conv.is_owned = false;
43898         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43899         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
43900         return ret_conv;
43901 }
43902
43903 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
43904         LDKRoutingFees ret_var = RoutingFees_clone(arg);
43905 int64_t ret_ref = 0;
43906 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43907 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43908 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43909 ret_ref = (uintptr_t)ret_var.inner;
43910 if (ret_var.is_owned) {
43911         ret_ref |= 1;
43912 }
43913         return ret_ref;
43914 }
43915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43916         LDKRoutingFees arg_conv;
43917         arg_conv.inner = (void*)(arg & (~1));
43918         arg_conv.is_owned = false;
43919         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43920         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
43921         return ret_conv;
43922 }
43923
43924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43925         LDKRoutingFees orig_conv;
43926         orig_conv.inner = (void*)(orig & (~1));
43927         orig_conv.is_owned = false;
43928         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43929         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
43930         int64_t ret_ref = 0;
43931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43934         ret_ref = (uintptr_t)ret_var.inner;
43935         if (ret_var.is_owned) {
43936                 ret_ref |= 1;
43937         }
43938         return ret_ref;
43939 }
43940
43941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
43942         LDKRoutingFees o_conv;
43943         o_conv.inner = (void*)(o & (~1));
43944         o_conv.is_owned = false;
43945         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43946         int64_t ret_conv = RoutingFees_hash(&o_conv);
43947         return ret_conv;
43948 }
43949
43950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
43951         LDKRoutingFees obj_conv;
43952         obj_conv.inner = (void*)(obj & (~1));
43953         obj_conv.is_owned = false;
43954         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43955         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
43956         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43957         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43958         CVec_u8Z_free(ret_var);
43959         return ret_arr;
43960 }
43961
43962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43963         LDKu8slice ser_ref;
43964         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43965         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43966         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
43967         *ret_conv = RoutingFees_read(ser_ref);
43968         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43969         return (int64_t)ret_conv;
43970 }
43971
43972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43973         LDKNodeAnnouncementInfo this_obj_conv;
43974         this_obj_conv.inner = (void*)(this_obj & (~1));
43975         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43977         NodeAnnouncementInfo_free(this_obj_conv);
43978 }
43979
43980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43981         LDKNodeAnnouncementInfo this_ptr_conv;
43982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43983         this_ptr_conv.is_owned = false;
43984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43985         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
43986         int64_t ret_ref = 0;
43987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43990         ret_ref = (uintptr_t)ret_var.inner;
43991         if (ret_var.is_owned) {
43992                 ret_ref |= 1;
43993         }
43994         return ret_ref;
43995 }
43996
43997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43998         LDKNodeAnnouncementInfo this_ptr_conv;
43999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44000         this_ptr_conv.is_owned = false;
44001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44002         LDKNodeFeatures val_conv;
44003         val_conv.inner = (void*)(val & (~1));
44004         val_conv.is_owned = (val & 1) || (val == 0);
44005         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44006         val_conv = NodeFeatures_clone(&val_conv);
44007         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
44008 }
44009
44010 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
44011         LDKNodeAnnouncementInfo this_ptr_conv;
44012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44013         this_ptr_conv.is_owned = false;
44014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44015         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
44016         return ret_conv;
44017 }
44018
44019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44020         LDKNodeAnnouncementInfo this_ptr_conv;
44021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44022         this_ptr_conv.is_owned = false;
44023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44024         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
44025 }
44026
44027 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
44028         LDKNodeAnnouncementInfo this_ptr_conv;
44029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44030         this_ptr_conv.is_owned = false;
44031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44032         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
44033         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
44034         return ret_arr;
44035 }
44036
44037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44038         LDKNodeAnnouncementInfo this_ptr_conv;
44039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44040         this_ptr_conv.is_owned = false;
44041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44042         LDKThreeBytes val_ref;
44043         CHECK((*env)->GetArrayLength(env, val) == 3);
44044         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
44045         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
44046 }
44047
44048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
44049         LDKNodeAnnouncementInfo this_ptr_conv;
44050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44051         this_ptr_conv.is_owned = false;
44052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44053         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
44054         int64_t ret_ref = 0;
44055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44058         ret_ref = (uintptr_t)ret_var.inner;
44059         if (ret_var.is_owned) {
44060                 ret_ref |= 1;
44061         }
44062         return ret_ref;
44063 }
44064
44065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44066         LDKNodeAnnouncementInfo this_ptr_conv;
44067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44068         this_ptr_conv.is_owned = false;
44069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44070         LDKNodeAlias val_conv;
44071         val_conv.inner = (void*)(val & (~1));
44072         val_conv.is_owned = (val & 1) || (val == 0);
44073         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44074         val_conv = NodeAlias_clone(&val_conv);
44075         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
44076 }
44077
44078 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
44079         LDKNodeAnnouncementInfo this_ptr_conv;
44080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44081         this_ptr_conv.is_owned = false;
44082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44083         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
44084         int64_tArray ret_arr = NULL;
44085         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44086         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44087         for (size_t m = 0; m < ret_var.datalen; m++) {
44088                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
44089                 *ret_conv_12_copy = ret_var.data[m];
44090                 int64_t ret_conv_12_ref = (uintptr_t)ret_conv_12_copy;
44091                 ret_arr_ptr[m] = ret_conv_12_ref;
44092         }
44093         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44094         FREE(ret_var.data);
44095         return ret_arr;
44096 }
44097
44098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44099         LDKNodeAnnouncementInfo this_ptr_conv;
44100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44101         this_ptr_conv.is_owned = false;
44102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44103         LDKCVec_NetAddressZ val_constr;
44104         val_constr.datalen = (*env)->GetArrayLength(env, val);
44105         if (val_constr.datalen > 0)
44106                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
44107         else
44108                 val_constr.data = NULL;
44109         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44110         for (size_t m = 0; m < val_constr.datalen; m++) {
44111                 int64_t val_conv_12 = val_vals[m];
44112                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
44113                 CHECK_ACCESS(val_conv_12_ptr);
44114                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
44115                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
44116                 val_constr.data[m] = val_conv_12_conv;
44117         }
44118         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44119         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
44120 }
44121
44122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
44123         LDKNodeAnnouncementInfo this_ptr_conv;
44124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44125         this_ptr_conv.is_owned = false;
44126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44127         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
44128         int64_t ret_ref = 0;
44129         if ((uintptr_t)ret_var.inner > 4096) {
44130                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44131                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44133                 ret_ref = (uintptr_t)ret_var.inner;
44134                 if (ret_var.is_owned) {
44135                         ret_ref |= 1;
44136                 }
44137         }
44138         return ret_ref;
44139 }
44140
44141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44142         LDKNodeAnnouncementInfo this_ptr_conv;
44143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44144         this_ptr_conv.is_owned = false;
44145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44146         LDKNodeAnnouncement val_conv;
44147         val_conv.inner = (void*)(val & (~1));
44148         val_conv.is_owned = (val & 1) || (val == 0);
44149         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44150         val_conv = NodeAnnouncement_clone(&val_conv);
44151         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
44152 }
44153
44154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int64_t alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
44155         LDKNodeFeatures features_arg_conv;
44156         features_arg_conv.inner = (void*)(features_arg & (~1));
44157         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
44158         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
44159         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
44160         LDKThreeBytes rgb_arg_ref;
44161         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
44162         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
44163         LDKNodeAlias alias_arg_conv;
44164         alias_arg_conv.inner = (void*)(alias_arg & (~1));
44165         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
44166         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
44167         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
44168         LDKCVec_NetAddressZ addresses_arg_constr;
44169         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
44170         if (addresses_arg_constr.datalen > 0)
44171                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
44172         else
44173                 addresses_arg_constr.data = NULL;
44174         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
44175         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
44176                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
44177                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
44178                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
44179                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
44180                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
44181         }
44182         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
44183         LDKNodeAnnouncement announcement_message_arg_conv;
44184         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
44185         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
44186         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
44187         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
44188         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
44189         int64_t ret_ref = 0;
44190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44193         ret_ref = (uintptr_t)ret_var.inner;
44194         if (ret_var.is_owned) {
44195                 ret_ref |= 1;
44196         }
44197         return ret_ref;
44198 }
44199
44200 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
44201         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
44202 int64_t ret_ref = 0;
44203 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44204 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44205 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44206 ret_ref = (uintptr_t)ret_var.inner;
44207 if (ret_var.is_owned) {
44208         ret_ref |= 1;
44209 }
44210         return ret_ref;
44211 }
44212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44213         LDKNodeAnnouncementInfo arg_conv;
44214         arg_conv.inner = (void*)(arg & (~1));
44215         arg_conv.is_owned = false;
44216         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44217         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
44218         return ret_conv;
44219 }
44220
44221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44222         LDKNodeAnnouncementInfo orig_conv;
44223         orig_conv.inner = (void*)(orig & (~1));
44224         orig_conv.is_owned = false;
44225         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44226         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
44227         int64_t ret_ref = 0;
44228         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44229         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44231         ret_ref = (uintptr_t)ret_var.inner;
44232         if (ret_var.is_owned) {
44233                 ret_ref |= 1;
44234         }
44235         return ret_ref;
44236 }
44237
44238 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44239         LDKNodeAnnouncementInfo obj_conv;
44240         obj_conv.inner = (void*)(obj & (~1));
44241         obj_conv.is_owned = false;
44242         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44243         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
44244         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44245         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44246         CVec_u8Z_free(ret_var);
44247         return ret_arr;
44248 }
44249
44250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44251         LDKu8slice ser_ref;
44252         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44253         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44254         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
44255         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
44256         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44257         return (int64_t)ret_conv;
44258 }
44259
44260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44261         LDKNodeAlias this_obj_conv;
44262         this_obj_conv.inner = (void*)(this_obj & (~1));
44263         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44265         NodeAlias_free(this_obj_conv);
44266 }
44267
44268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44269         LDKNodeAlias this_ptr_conv;
44270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44271         this_ptr_conv.is_owned = false;
44272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44273         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44274         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
44275         return ret_arr;
44276 }
44277
44278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44279         LDKNodeAlias this_ptr_conv;
44280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44281         this_ptr_conv.is_owned = false;
44282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44283         LDKThirtyTwoBytes val_ref;
44284         CHECK((*env)->GetArrayLength(env, val) == 32);
44285         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
44286         NodeAlias_set_a(&this_ptr_conv, val_ref);
44287 }
44288
44289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
44290         LDKThirtyTwoBytes a_arg_ref;
44291         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
44292         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
44293         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
44294         int64_t ret_ref = 0;
44295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44298         ret_ref = (uintptr_t)ret_var.inner;
44299         if (ret_var.is_owned) {
44300                 ret_ref |= 1;
44301         }
44302         return ret_ref;
44303 }
44304
44305 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
44306         LDKNodeAlias ret_var = NodeAlias_clone(arg);
44307 int64_t ret_ref = 0;
44308 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44309 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44310 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44311 ret_ref = (uintptr_t)ret_var.inner;
44312 if (ret_var.is_owned) {
44313         ret_ref |= 1;
44314 }
44315         return ret_ref;
44316 }
44317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44318         LDKNodeAlias arg_conv;
44319         arg_conv.inner = (void*)(arg & (~1));
44320         arg_conv.is_owned = false;
44321         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44322         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
44323         return ret_conv;
44324 }
44325
44326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44327         LDKNodeAlias orig_conv;
44328         orig_conv.inner = (void*)(orig & (~1));
44329         orig_conv.is_owned = false;
44330         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44331         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
44332         int64_t ret_ref = 0;
44333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44336         ret_ref = (uintptr_t)ret_var.inner;
44337         if (ret_var.is_owned) {
44338                 ret_ref |= 1;
44339         }
44340         return ret_ref;
44341 }
44342
44343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
44344         LDKNodeAlias obj_conv;
44345         obj_conv.inner = (void*)(obj & (~1));
44346         obj_conv.is_owned = false;
44347         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44348         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
44349         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44350         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44351         CVec_u8Z_free(ret_var);
44352         return ret_arr;
44353 }
44354
44355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44356         LDKu8slice ser_ref;
44357         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44358         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44359         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
44360         *ret_conv = NodeAlias_read(ser_ref);
44361         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44362         return (int64_t)ret_conv;
44363 }
44364
44365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44366         LDKNodeInfo this_obj_conv;
44367         this_obj_conv.inner = (void*)(this_obj & (~1));
44368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44370         NodeInfo_free(this_obj_conv);
44371 }
44372
44373 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
44374         LDKNodeInfo this_ptr_conv;
44375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44376         this_ptr_conv.is_owned = false;
44377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44378         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
44379         int64_tArray ret_arr = NULL;
44380         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44381         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44382         for (size_t g = 0; g < ret_var.datalen; g++) {
44383                 int64_t ret_conv_6_conv = ret_var.data[g];
44384                 ret_arr_ptr[g] = ret_conv_6_conv;
44385         }
44386         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44387         FREE(ret_var.data);
44388         return ret_arr;
44389 }
44390
44391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44392         LDKNodeInfo this_ptr_conv;
44393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44394         this_ptr_conv.is_owned = false;
44395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44396         LDKCVec_u64Z val_constr;
44397         val_constr.datalen = (*env)->GetArrayLength(env, val);
44398         if (val_constr.datalen > 0)
44399                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44400         else
44401                 val_constr.data = NULL;
44402         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44403         for (size_t g = 0; g < val_constr.datalen; g++) {
44404                 int64_t val_conv_6 = val_vals[g];
44405                 val_constr.data[g] = val_conv_6;
44406         }
44407         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44408         NodeInfo_set_channels(&this_ptr_conv, val_constr);
44409 }
44410
44411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
44412         LDKNodeInfo this_ptr_conv;
44413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44414         this_ptr_conv.is_owned = false;
44415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44416         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
44417         int64_t ret_ref = 0;
44418         if ((uintptr_t)ret_var.inner > 4096) {
44419                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44420                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44422                 ret_ref = (uintptr_t)ret_var.inner;
44423                 if (ret_var.is_owned) {
44424                         ret_ref |= 1;
44425                 }
44426         }
44427         return ret_ref;
44428 }
44429
44430 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) {
44431         LDKNodeInfo this_ptr_conv;
44432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44433         this_ptr_conv.is_owned = false;
44434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44435         LDKRoutingFees val_conv;
44436         val_conv.inner = (void*)(val & (~1));
44437         val_conv.is_owned = (val & 1) || (val == 0);
44438         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44439         val_conv = RoutingFees_clone(&val_conv);
44440         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
44441 }
44442
44443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
44444         LDKNodeInfo this_ptr_conv;
44445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44446         this_ptr_conv.is_owned = false;
44447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44448         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
44449         int64_t ret_ref = 0;
44450         if ((uintptr_t)ret_var.inner > 4096) {
44451                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44452                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44454                 ret_ref = (uintptr_t)ret_var.inner;
44455                 if (ret_var.is_owned) {
44456                         ret_ref |= 1;
44457                 }
44458         }
44459         return ret_ref;
44460 }
44461
44462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44463         LDKNodeInfo 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         LDKNodeAnnouncementInfo val_conv;
44468         val_conv.inner = (void*)(val & (~1));
44469         val_conv.is_owned = (val & 1) || (val == 0);
44470         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44471         val_conv = NodeAnnouncementInfo_clone(&val_conv);
44472         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
44473 }
44474
44475 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) {
44476         LDKCVec_u64Z channels_arg_constr;
44477         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
44478         if (channels_arg_constr.datalen > 0)
44479                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44480         else
44481                 channels_arg_constr.data = NULL;
44482         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
44483         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
44484                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
44485                 channels_arg_constr.data[g] = channels_arg_conv_6;
44486         }
44487         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
44488         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
44489         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
44490         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
44491         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
44492         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
44493         LDKNodeAnnouncementInfo announcement_info_arg_conv;
44494         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
44495         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
44496         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
44497         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
44498         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
44499         int64_t ret_ref = 0;
44500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44503         ret_ref = (uintptr_t)ret_var.inner;
44504         if (ret_var.is_owned) {
44505                 ret_ref |= 1;
44506         }
44507         return ret_ref;
44508 }
44509
44510 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
44511         LDKNodeInfo ret_var = NodeInfo_clone(arg);
44512 int64_t ret_ref = 0;
44513 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44514 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44515 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44516 ret_ref = (uintptr_t)ret_var.inner;
44517 if (ret_var.is_owned) {
44518         ret_ref |= 1;
44519 }
44520         return ret_ref;
44521 }
44522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44523         LDKNodeInfo arg_conv;
44524         arg_conv.inner = (void*)(arg & (~1));
44525         arg_conv.is_owned = false;
44526         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44527         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
44528         return ret_conv;
44529 }
44530
44531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44532         LDKNodeInfo orig_conv;
44533         orig_conv.inner = (void*)(orig & (~1));
44534         orig_conv.is_owned = false;
44535         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44536         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
44537         int64_t ret_ref = 0;
44538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44541         ret_ref = (uintptr_t)ret_var.inner;
44542         if (ret_var.is_owned) {
44543                 ret_ref |= 1;
44544         }
44545         return ret_ref;
44546 }
44547
44548 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44549         LDKNodeInfo obj_conv;
44550         obj_conv.inner = (void*)(obj & (~1));
44551         obj_conv.is_owned = false;
44552         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44553         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
44554         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44555         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44556         CVec_u8Z_free(ret_var);
44557         return ret_arr;
44558 }
44559
44560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44561         LDKu8slice ser_ref;
44562         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44563         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44564         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
44565         *ret_conv = NodeInfo_read(ser_ref);
44566         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44567         return (int64_t)ret_conv;
44568 }
44569
44570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
44571         LDKNetworkGraph obj_conv;
44572         obj_conv.inner = (void*)(obj & (~1));
44573         obj_conv.is_owned = false;
44574         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44575         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
44576         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44577         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44578         CVec_u8Z_free(ret_var);
44579         return ret_arr;
44580 }
44581
44582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
44583         LDKu8slice ser_ref;
44584         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44585         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44586         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
44587         CHECK_ACCESS(arg_ptr);
44588         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
44589         if (arg_conv.free == LDKLogger_JCalls_free) {
44590                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44591                 LDKLogger_JCalls_cloned(&arg_conv);
44592         }
44593         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
44594         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
44595         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44596         return (int64_t)ret_conv;
44597 }
44598
44599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
44600         LDKThirtyTwoBytes genesis_hash_ref;
44601         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
44602         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
44603         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44604         CHECK_ACCESS(logger_ptr);
44605         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44606         if (logger_conv.free == LDKLogger_JCalls_free) {
44607                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44608                 LDKLogger_JCalls_cloned(&logger_conv);
44609         }
44610         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
44611         int64_t ret_ref = 0;
44612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44613         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44615         ret_ref = (uintptr_t)ret_var.inner;
44616         if (ret_var.is_owned) {
44617                 ret_ref |= 1;
44618         }
44619         return ret_ref;
44620 }
44621
44622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
44623         LDKNetworkGraph this_arg_conv;
44624         this_arg_conv.inner = (void*)(this_arg & (~1));
44625         this_arg_conv.is_owned = false;
44626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44627         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
44628         int64_t ret_ref = 0;
44629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44632         ret_ref = (uintptr_t)ret_var.inner;
44633         if (ret_var.is_owned) {
44634                 ret_ref |= 1;
44635         }
44636         return ret_ref;
44637 }
44638
44639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
44640         LDKNetworkGraph this_arg_conv;
44641         this_arg_conv.inner = (void*)(this_arg & (~1));
44642         this_arg_conv.is_owned = false;
44643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44644         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
44645         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
44646         int64_t ret_ref = (uintptr_t)ret_copy;
44647         return ret_ref;
44648 }
44649
44650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1set_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
44651         LDKNetworkGraph this_arg_conv;
44652         this_arg_conv.inner = (void*)(this_arg & (~1));
44653         this_arg_conv.is_owned = false;
44654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44655         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
44656 }
44657
44658 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) {
44659         LDKNetworkGraph this_arg_conv;
44660         this_arg_conv.inner = (void*)(this_arg & (~1));
44661         this_arg_conv.is_owned = false;
44662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44663         LDKNodeAnnouncement msg_conv;
44664         msg_conv.inner = (void*)(msg & (~1));
44665         msg_conv.is_owned = false;
44666         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44667         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44668         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
44669         return (int64_t)ret_conv;
44670 }
44671
44672 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) {
44673         LDKNetworkGraph this_arg_conv;
44674         this_arg_conv.inner = (void*)(this_arg & (~1));
44675         this_arg_conv.is_owned = false;
44676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44677         LDKUnsignedNodeAnnouncement msg_conv;
44678         msg_conv.inner = (void*)(msg & (~1));
44679         msg_conv.is_owned = false;
44680         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44681         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44682         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
44683         return (int64_t)ret_conv;
44684 }
44685
44686 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) {
44687         LDKNetworkGraph this_arg_conv;
44688         this_arg_conv.inner = (void*)(this_arg & (~1));
44689         this_arg_conv.is_owned = false;
44690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44691         LDKChannelAnnouncement msg_conv;
44692         msg_conv.inner = (void*)(msg & (~1));
44693         msg_conv.is_owned = false;
44694         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44695         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
44696         CHECK_ACCESS(chain_access_ptr);
44697         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44698         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44699         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44700                 // Manually implement clone for Java trait instances
44701                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44702                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44703                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44704                 }
44705         }
44706         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44707         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
44708         return (int64_t)ret_conv;
44709 }
44710
44711 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) {
44712         LDKNetworkGraph this_arg_conv;
44713         this_arg_conv.inner = (void*)(this_arg & (~1));
44714         this_arg_conv.is_owned = false;
44715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44716         LDKUnsignedChannelAnnouncement msg_conv;
44717         msg_conv.inner = (void*)(msg & (~1));
44718         msg_conv.is_owned = false;
44719         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44720         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
44721         CHECK_ACCESS(chain_access_ptr);
44722         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44723         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44724         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44725                 // Manually implement clone for Java trait instances
44726                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44727                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44728                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44729                 }
44730         }
44731         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44732         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
44733         return (int64_t)ret_conv;
44734 }
44735
44736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1add_1channel_1from_1partial_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t timestamp, int64_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
44737         LDKNetworkGraph this_arg_conv;
44738         this_arg_conv.inner = (void*)(this_arg & (~1));
44739         this_arg_conv.is_owned = false;
44740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44741         LDKChannelFeatures features_conv;
44742         features_conv.inner = (void*)(features & (~1));
44743         features_conv.is_owned = (features & 1) || (features == 0);
44744         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
44745         features_conv = ChannelFeatures_clone(&features_conv);
44746         LDKPublicKey node_id_1_ref;
44747         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
44748         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
44749         LDKPublicKey node_id_2_ref;
44750         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
44751         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
44752         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44753         *ret_conv = NetworkGraph_add_channel_from_partial_announcement(&this_arg_conv, short_channel_id, timestamp, features_conv, node_id_1_ref, node_id_2_ref);
44754         return (int64_t)ret_conv;
44755 }
44756
44757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1channel_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
44758         LDKNetworkGraph this_arg_conv;
44759         this_arg_conv.inner = (void*)(this_arg & (~1));
44760         this_arg_conv.is_owned = false;
44761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44762         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
44763 }
44764
44765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
44766         LDKNetworkGraph this_arg_conv;
44767         this_arg_conv.inner = (void*)(this_arg & (~1));
44768         this_arg_conv.is_owned = false;
44769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44770         LDKPublicKey _node_id_ref;
44771         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
44772         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
44773         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
44774 }
44775
44776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
44777         LDKNetworkGraph this_arg_conv;
44778         this_arg_conv.inner = (void*)(this_arg & (~1));
44779         this_arg_conv.is_owned = false;
44780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44781         NetworkGraph_remove_stale_channels(&this_arg_conv);
44782 }
44783
44784 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) {
44785         LDKNetworkGraph this_arg_conv;
44786         this_arg_conv.inner = (void*)(this_arg & (~1));
44787         this_arg_conv.is_owned = false;
44788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44789         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
44790 }
44791
44792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
44793         LDKNetworkGraph this_arg_conv;
44794         this_arg_conv.inner = (void*)(this_arg & (~1));
44795         this_arg_conv.is_owned = false;
44796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44797         LDKChannelUpdate msg_conv;
44798         msg_conv.inner = (void*)(msg & (~1));
44799         msg_conv.is_owned = false;
44800         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44801         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44802         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
44803         return (int64_t)ret_conv;
44804 }
44805
44806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
44807         LDKNetworkGraph this_arg_conv;
44808         this_arg_conv.inner = (void*)(this_arg & (~1));
44809         this_arg_conv.is_owned = false;
44810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44811         LDKUnsignedChannelUpdate msg_conv;
44812         msg_conv.inner = (void*)(msg & (~1));
44813         msg_conv.is_owned = false;
44814         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44815         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44816         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
44817         return (int64_t)ret_conv;
44818 }
44819
44820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
44821         LDKReadOnlyNetworkGraph this_arg_conv;
44822         this_arg_conv.inner = (void*)(this_arg & (~1));
44823         this_arg_conv.is_owned = false;
44824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44825         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
44826         int64_t ret_ref = 0;
44827         if ((uintptr_t)ret_var.inner > 4096) {
44828                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44829                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44831                 ret_ref = (uintptr_t)ret_var.inner;
44832                 if (ret_var.is_owned) {
44833                         ret_ref |= 1;
44834                 }
44835         }
44836         return ret_ref;
44837 }
44838
44839 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
44840         LDKReadOnlyNetworkGraph this_arg_conv;
44841         this_arg_conv.inner = (void*)(this_arg & (~1));
44842         this_arg_conv.is_owned = false;
44843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44844         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
44845         int64_tArray ret_arr = NULL;
44846         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44847         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44848         for (size_t g = 0; g < ret_var.datalen; g++) {
44849                 int64_t ret_conv_6_conv = ret_var.data[g];
44850                 ret_arr_ptr[g] = ret_conv_6_conv;
44851         }
44852         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44853         FREE(ret_var.data);
44854         return ret_arr;
44855 }
44856
44857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
44858         LDKReadOnlyNetworkGraph this_arg_conv;
44859         this_arg_conv.inner = (void*)(this_arg & (~1));
44860         this_arg_conv.is_owned = false;
44861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44862         LDKNodeId node_id_conv;
44863         node_id_conv.inner = (void*)(node_id & (~1));
44864         node_id_conv.is_owned = false;
44865         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
44866         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
44867         int64_t ret_ref = 0;
44868         if ((uintptr_t)ret_var.inner > 4096) {
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         }
44877         return ret_ref;
44878 }
44879
44880 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
44881         LDKReadOnlyNetworkGraph this_arg_conv;
44882         this_arg_conv.inner = (void*)(this_arg & (~1));
44883         this_arg_conv.is_owned = false;
44884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44885         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
44886         int64_tArray ret_arr = NULL;
44887         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44888         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44889         for (size_t i = 0; i < ret_var.datalen; i++) {
44890                 LDKNodeId ret_conv_8_var = ret_var.data[i];
44891                 int64_t ret_conv_8_ref = 0;
44892                 CHECK((((uintptr_t)ret_conv_8_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44893                 CHECK((((uintptr_t)&ret_conv_8_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44894                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
44895                 ret_conv_8_ref = (uintptr_t)ret_conv_8_var.inner;
44896                 if (ret_conv_8_var.is_owned) {
44897                         ret_conv_8_ref |= 1;
44898                 }
44899                 ret_arr_ptr[i] = ret_conv_8_ref;
44900         }
44901         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44902         FREE(ret_var.data);
44903         return ret_arr;
44904 }
44905
44906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
44907         LDKReadOnlyNetworkGraph this_arg_conv;
44908         this_arg_conv.inner = (void*)(this_arg & (~1));
44909         this_arg_conv.is_owned = false;
44910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44911         LDKPublicKey pubkey_ref;
44912         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
44913         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
44914         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
44915         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
44916         int64_t ret_ref = (uintptr_t)ret_copy;
44917         return ret_ref;
44918 }
44919
44920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44921         LDKRouteHop this_obj_conv;
44922         this_obj_conv.inner = (void*)(this_obj & (~1));
44923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44925         RouteHop_free(this_obj_conv);
44926 }
44927
44928 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
44929         LDKRouteHop this_ptr_conv;
44930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44931         this_ptr_conv.is_owned = false;
44932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44933         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44934         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
44935         return ret_arr;
44936 }
44937
44938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44939         LDKRouteHop this_ptr_conv;
44940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44941         this_ptr_conv.is_owned = false;
44942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44943         LDKPublicKey val_ref;
44944         CHECK((*env)->GetArrayLength(env, val) == 33);
44945         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44946         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
44947 }
44948
44949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44950         LDKRouteHop this_ptr_conv;
44951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44952         this_ptr_conv.is_owned = false;
44953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44954         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
44955         int64_t ret_ref = 0;
44956         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44957         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44959         ret_ref = (uintptr_t)ret_var.inner;
44960         if (ret_var.is_owned) {
44961                 ret_ref |= 1;
44962         }
44963         return ret_ref;
44964 }
44965
44966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44967         LDKRouteHop this_ptr_conv;
44968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44969         this_ptr_conv.is_owned = false;
44970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44971         LDKNodeFeatures val_conv;
44972         val_conv.inner = (void*)(val & (~1));
44973         val_conv.is_owned = (val & 1) || (val == 0);
44974         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44975         val_conv = NodeFeatures_clone(&val_conv);
44976         RouteHop_set_node_features(&this_ptr_conv, val_conv);
44977 }
44978
44979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
44980         LDKRouteHop this_ptr_conv;
44981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44982         this_ptr_conv.is_owned = false;
44983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44984         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
44985         return ret_conv;
44986 }
44987
44988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44989         LDKRouteHop this_ptr_conv;
44990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44991         this_ptr_conv.is_owned = false;
44992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44993         RouteHop_set_short_channel_id(&this_ptr_conv, val);
44994 }
44995
44996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44997         LDKRouteHop this_ptr_conv;
44998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44999         this_ptr_conv.is_owned = false;
45000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45001         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
45002         int64_t ret_ref = 0;
45003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45006         ret_ref = (uintptr_t)ret_var.inner;
45007         if (ret_var.is_owned) {
45008                 ret_ref |= 1;
45009         }
45010         return ret_ref;
45011 }
45012
45013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45014         LDKRouteHop this_ptr_conv;
45015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45016         this_ptr_conv.is_owned = false;
45017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45018         LDKChannelFeatures val_conv;
45019         val_conv.inner = (void*)(val & (~1));
45020         val_conv.is_owned = (val & 1) || (val == 0);
45021         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45022         val_conv = ChannelFeatures_clone(&val_conv);
45023         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
45024 }
45025
45026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45027         LDKRouteHop this_ptr_conv;
45028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45029         this_ptr_conv.is_owned = false;
45030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45031         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
45032         return ret_conv;
45033 }
45034
45035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45036         LDKRouteHop this_ptr_conv;
45037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45038         this_ptr_conv.is_owned = false;
45039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45040         RouteHop_set_fee_msat(&this_ptr_conv, val);
45041 }
45042
45043 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45044         LDKRouteHop this_ptr_conv;
45045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45046         this_ptr_conv.is_owned = false;
45047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45048         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
45049         return ret_conv;
45050 }
45051
45052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
45053         LDKRouteHop this_ptr_conv;
45054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45055         this_ptr_conv.is_owned = false;
45056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45057         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
45058 }
45059
45060 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) {
45061         LDKPublicKey pubkey_arg_ref;
45062         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
45063         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
45064         LDKNodeFeatures node_features_arg_conv;
45065         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
45066         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
45067         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
45068         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
45069         LDKChannelFeatures channel_features_arg_conv;
45070         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
45071         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
45072         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
45073         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
45074         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);
45075         int64_t ret_ref = 0;
45076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45079         ret_ref = (uintptr_t)ret_var.inner;
45080         if (ret_var.is_owned) {
45081                 ret_ref |= 1;
45082         }
45083         return ret_ref;
45084 }
45085
45086 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
45087         LDKRouteHop ret_var = RouteHop_clone(arg);
45088 int64_t ret_ref = 0;
45089 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45090 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45091 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45092 ret_ref = (uintptr_t)ret_var.inner;
45093 if (ret_var.is_owned) {
45094         ret_ref |= 1;
45095 }
45096         return ret_ref;
45097 }
45098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45099         LDKRouteHop arg_conv;
45100         arg_conv.inner = (void*)(arg & (~1));
45101         arg_conv.is_owned = false;
45102         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45103         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
45104         return ret_conv;
45105 }
45106
45107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45108         LDKRouteHop orig_conv;
45109         orig_conv.inner = (void*)(orig & (~1));
45110         orig_conv.is_owned = false;
45111         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45112         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
45113         int64_t ret_ref = 0;
45114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45117         ret_ref = (uintptr_t)ret_var.inner;
45118         if (ret_var.is_owned) {
45119                 ret_ref |= 1;
45120         }
45121         return ret_ref;
45122 }
45123
45124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
45125         LDKRouteHop o_conv;
45126         o_conv.inner = (void*)(o & (~1));
45127         o_conv.is_owned = false;
45128         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45129         int64_t ret_conv = RouteHop_hash(&o_conv);
45130         return ret_conv;
45131 }
45132
45133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45134         LDKRouteHop a_conv;
45135         a_conv.inner = (void*)(a & (~1));
45136         a_conv.is_owned = false;
45137         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45138         LDKRouteHop b_conv;
45139         b_conv.inner = (void*)(b & (~1));
45140         b_conv.is_owned = false;
45141         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45142         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
45143         return ret_conv;
45144 }
45145
45146 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
45147         LDKRouteHop obj_conv;
45148         obj_conv.inner = (void*)(obj & (~1));
45149         obj_conv.is_owned = false;
45150         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45151         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
45152         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45153         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45154         CVec_u8Z_free(ret_var);
45155         return ret_arr;
45156 }
45157
45158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45159         LDKu8slice ser_ref;
45160         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45161         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45162         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
45163         *ret_conv = RouteHop_read(ser_ref);
45164         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45165         return (int64_t)ret_conv;
45166 }
45167
45168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45169         LDKRoute this_obj_conv;
45170         this_obj_conv.inner = (void*)(this_obj & (~1));
45171         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45173         Route_free(this_obj_conv);
45174 }
45175
45176 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
45177         LDKRoute this_ptr_conv;
45178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45179         this_ptr_conv.is_owned = false;
45180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45181         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
45182         jobjectArray ret_arr = NULL;
45183         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
45184         ;
45185         for (size_t m = 0; m < ret_var.datalen; m++) {
45186                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
45187                 int64_tArray ret_conv_12_arr = NULL;
45188                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
45189                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
45190                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
45191                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
45192                         int64_t ret_conv_12_conv_10_ref = 0;
45193                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45194                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45195                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
45196                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
45197                         if (ret_conv_12_conv_10_var.is_owned) {
45198                                 ret_conv_12_conv_10_ref |= 1;
45199                         }
45200                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
45201                 }
45202                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
45203                 FREE(ret_conv_12_var.data);
45204                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
45205         }
45206         
45207         FREE(ret_var.data);
45208         return ret_arr;
45209 }
45210
45211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
45212         LDKRoute this_ptr_conv;
45213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45214         this_ptr_conv.is_owned = false;
45215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45216         LDKCVec_CVec_RouteHopZZ val_constr;
45217         val_constr.datalen = (*env)->GetArrayLength(env, val);
45218         if (val_constr.datalen > 0)
45219                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45220         else
45221                 val_constr.data = NULL;
45222         for (size_t m = 0; m < val_constr.datalen; m++) {
45223                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
45224                 LDKCVec_RouteHopZ val_conv_12_constr;
45225                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
45226                 if (val_conv_12_constr.datalen > 0)
45227                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45228                 else
45229                         val_conv_12_constr.data = NULL;
45230                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
45231                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
45232                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
45233                         LDKRouteHop val_conv_12_conv_10_conv;
45234                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
45235                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
45236                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
45237                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
45238                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
45239                 }
45240                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
45241                 val_constr.data[m] = val_conv_12_constr;
45242         }
45243         Route_set_paths(&this_ptr_conv, val_constr);
45244 }
45245
45246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45247         LDKRoute this_ptr_conv;
45248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45249         this_ptr_conv.is_owned = false;
45250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45251         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
45252         int64_t ret_ref = 0;
45253         if ((uintptr_t)ret_var.inner > 4096) {
45254                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45255                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45257                 ret_ref = (uintptr_t)ret_var.inner;
45258                 if (ret_var.is_owned) {
45259                         ret_ref |= 1;
45260                 }
45261         }
45262         return ret_ref;
45263 }
45264
45265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45266         LDKRoute this_ptr_conv;
45267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45268         this_ptr_conv.is_owned = false;
45269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45270         LDKPaymentParameters val_conv;
45271         val_conv.inner = (void*)(val & (~1));
45272         val_conv.is_owned = (val & 1) || (val == 0);
45273         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45274         val_conv = PaymentParameters_clone(&val_conv);
45275         Route_set_payment_params(&this_ptr_conv, val_conv);
45276 }
45277
45278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
45279         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
45280         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
45281         if (paths_arg_constr.datalen > 0)
45282                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45283         else
45284                 paths_arg_constr.data = NULL;
45285         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
45286                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
45287                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
45288                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
45289                 if (paths_arg_conv_12_constr.datalen > 0)
45290                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45291                 else
45292                         paths_arg_conv_12_constr.data = NULL;
45293                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
45294                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
45295                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
45296                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
45297                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
45298                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
45299                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
45300                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
45301                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
45302                 }
45303                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
45304                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
45305         }
45306         LDKPaymentParameters payment_params_arg_conv;
45307         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
45308         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
45309         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45310         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45311         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
45312         int64_t ret_ref = 0;
45313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45316         ret_ref = (uintptr_t)ret_var.inner;
45317         if (ret_var.is_owned) {
45318                 ret_ref |= 1;
45319         }
45320         return ret_ref;
45321 }
45322
45323 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
45324         LDKRoute ret_var = Route_clone(arg);
45325 int64_t ret_ref = 0;
45326 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45327 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45328 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45329 ret_ref = (uintptr_t)ret_var.inner;
45330 if (ret_var.is_owned) {
45331         ret_ref |= 1;
45332 }
45333         return ret_ref;
45334 }
45335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45336         LDKRoute arg_conv;
45337         arg_conv.inner = (void*)(arg & (~1));
45338         arg_conv.is_owned = false;
45339         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45340         int64_t ret_conv = Route_clone_ptr(&arg_conv);
45341         return ret_conv;
45342 }
45343
45344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45345         LDKRoute orig_conv;
45346         orig_conv.inner = (void*)(orig & (~1));
45347         orig_conv.is_owned = false;
45348         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45349         LDKRoute ret_var = Route_clone(&orig_conv);
45350         int64_t ret_ref = 0;
45351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45354         ret_ref = (uintptr_t)ret_var.inner;
45355         if (ret_var.is_owned) {
45356                 ret_ref |= 1;
45357         }
45358         return ret_ref;
45359 }
45360
45361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
45362         LDKRoute o_conv;
45363         o_conv.inner = (void*)(o & (~1));
45364         o_conv.is_owned = false;
45365         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45366         int64_t ret_conv = Route_hash(&o_conv);
45367         return ret_conv;
45368 }
45369
45370 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45371         LDKRoute a_conv;
45372         a_conv.inner = (void*)(a & (~1));
45373         a_conv.is_owned = false;
45374         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45375         LDKRoute b_conv;
45376         b_conv.inner = (void*)(b & (~1));
45377         b_conv.is_owned = false;
45378         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45379         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
45380         return ret_conv;
45381 }
45382
45383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
45384         LDKRoute this_arg_conv;
45385         this_arg_conv.inner = (void*)(this_arg & (~1));
45386         this_arg_conv.is_owned = false;
45387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45388         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
45389         return ret_conv;
45390 }
45391
45392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
45393         LDKRoute this_arg_conv;
45394         this_arg_conv.inner = (void*)(this_arg & (~1));
45395         this_arg_conv.is_owned = false;
45396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45397         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
45398         return ret_conv;
45399 }
45400
45401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
45402         LDKRoute obj_conv;
45403         obj_conv.inner = (void*)(obj & (~1));
45404         obj_conv.is_owned = false;
45405         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45406         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
45407         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45408         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45409         CVec_u8Z_free(ret_var);
45410         return ret_arr;
45411 }
45412
45413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45414         LDKu8slice ser_ref;
45415         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45416         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45417         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
45418         *ret_conv = Route_read(ser_ref);
45419         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45420         return (int64_t)ret_conv;
45421 }
45422
45423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45424         LDKRouteParameters this_obj_conv;
45425         this_obj_conv.inner = (void*)(this_obj & (~1));
45426         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45428         RouteParameters_free(this_obj_conv);
45429 }
45430
45431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45432         LDKRouteParameters this_ptr_conv;
45433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45434         this_ptr_conv.is_owned = false;
45435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45436         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
45437         int64_t ret_ref = 0;
45438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45441         ret_ref = (uintptr_t)ret_var.inner;
45442         if (ret_var.is_owned) {
45443                 ret_ref |= 1;
45444         }
45445         return ret_ref;
45446 }
45447
45448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45449         LDKRouteParameters this_ptr_conv;
45450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45451         this_ptr_conv.is_owned = false;
45452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45453         LDKPaymentParameters val_conv;
45454         val_conv.inner = (void*)(val & (~1));
45455         val_conv.is_owned = (val & 1) || (val == 0);
45456         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45457         val_conv = PaymentParameters_clone(&val_conv);
45458         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
45459 }
45460
45461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45462         LDKRouteParameters this_ptr_conv;
45463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45464         this_ptr_conv.is_owned = false;
45465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45466         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
45467         return ret_conv;
45468 }
45469
45470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45471         LDKRouteParameters this_ptr_conv;
45472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45473         this_ptr_conv.is_owned = false;
45474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45475         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
45476 }
45477
45478 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45479         LDKRouteParameters this_ptr_conv;
45480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45481         this_ptr_conv.is_owned = false;
45482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45483         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
45484         return ret_conv;
45485 }
45486
45487 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) {
45488         LDKRouteParameters this_ptr_conv;
45489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45490         this_ptr_conv.is_owned = false;
45491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45492         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
45493 }
45494
45495 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) {
45496         LDKPaymentParameters payment_params_arg_conv;
45497         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
45498         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
45499         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45500         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45501         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
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 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
45514         LDKRouteParameters ret_var = RouteParameters_clone(arg);
45515 int64_t ret_ref = 0;
45516 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45517 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45518 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45519 ret_ref = (uintptr_t)ret_var.inner;
45520 if (ret_var.is_owned) {
45521         ret_ref |= 1;
45522 }
45523         return ret_ref;
45524 }
45525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45526         LDKRouteParameters arg_conv;
45527         arg_conv.inner = (void*)(arg & (~1));
45528         arg_conv.is_owned = false;
45529         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45530         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
45531         return ret_conv;
45532 }
45533
45534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45535         LDKRouteParameters orig_conv;
45536         orig_conv.inner = (void*)(orig & (~1));
45537         orig_conv.is_owned = false;
45538         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45539         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
45540         int64_t ret_ref = 0;
45541         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45542         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45544         ret_ref = (uintptr_t)ret_var.inner;
45545         if (ret_var.is_owned) {
45546                 ret_ref |= 1;
45547         }
45548         return ret_ref;
45549 }
45550
45551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
45552         LDKRouteParameters obj_conv;
45553         obj_conv.inner = (void*)(obj & (~1));
45554         obj_conv.is_owned = false;
45555         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45556         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
45557         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45558         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45559         CVec_u8Z_free(ret_var);
45560         return ret_arr;
45561 }
45562
45563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45564         LDKu8slice ser_ref;
45565         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45566         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45567         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
45568         *ret_conv = RouteParameters_read(ser_ref);
45569         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45570         return (int64_t)ret_conv;
45571 }
45572
45573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45574         LDKPaymentParameters this_obj_conv;
45575         this_obj_conv.inner = (void*)(this_obj & (~1));
45576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45578         PaymentParameters_free(this_obj_conv);
45579 }
45580
45581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
45582         LDKPaymentParameters this_ptr_conv;
45583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45584         this_ptr_conv.is_owned = false;
45585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45586         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
45588         return ret_arr;
45589 }
45590
45591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45592         LDKPaymentParameters this_ptr_conv;
45593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45594         this_ptr_conv.is_owned = false;
45595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45596         LDKPublicKey val_ref;
45597         CHECK((*env)->GetArrayLength(env, val) == 33);
45598         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45599         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
45600 }
45601
45602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
45603         LDKPaymentParameters this_ptr_conv;
45604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45605         this_ptr_conv.is_owned = false;
45606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45607         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
45608         int64_t ret_ref = 0;
45609         if ((uintptr_t)ret_var.inner > 4096) {
45610                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45611                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45613                 ret_ref = (uintptr_t)ret_var.inner;
45614                 if (ret_var.is_owned) {
45615                         ret_ref |= 1;
45616                 }
45617         }
45618         return ret_ref;
45619 }
45620
45621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45622         LDKPaymentParameters this_ptr_conv;
45623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45624         this_ptr_conv.is_owned = false;
45625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45626         LDKInvoiceFeatures val_conv;
45627         val_conv.inner = (void*)(val & (~1));
45628         val_conv.is_owned = (val & 1) || (val == 0);
45629         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45630         val_conv = InvoiceFeatures_clone(&val_conv);
45631         PaymentParameters_set_features(&this_ptr_conv, val_conv);
45632 }
45633
45634 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
45635         LDKPaymentParameters this_ptr_conv;
45636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45637         this_ptr_conv.is_owned = false;
45638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45639         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
45640         int64_tArray ret_arr = NULL;
45641         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45642         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45643         for (size_t l = 0; l < ret_var.datalen; l++) {
45644                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45645                 int64_t ret_conv_11_ref = 0;
45646                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45647                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45648                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45649                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
45650                 if (ret_conv_11_var.is_owned) {
45651                         ret_conv_11_ref |= 1;
45652                 }
45653                 ret_arr_ptr[l] = ret_conv_11_ref;
45654         }
45655         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45656         FREE(ret_var.data);
45657         return ret_arr;
45658 }
45659
45660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45661         LDKPaymentParameters this_ptr_conv;
45662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45663         this_ptr_conv.is_owned = false;
45664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45665         LDKCVec_RouteHintZ val_constr;
45666         val_constr.datalen = (*env)->GetArrayLength(env, val);
45667         if (val_constr.datalen > 0)
45668                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
45669         else
45670                 val_constr.data = NULL;
45671         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45672         for (size_t l = 0; l < val_constr.datalen; l++) {
45673                 int64_t val_conv_11 = val_vals[l];
45674                 LDKRouteHint val_conv_11_conv;
45675                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
45676                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
45677                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
45678                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
45679                 val_constr.data[l] = val_conv_11_conv;
45680         }
45681         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45682         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
45683 }
45684
45685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
45686         LDKPaymentParameters this_ptr_conv;
45687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45688         this_ptr_conv.is_owned = false;
45689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45690         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45691         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
45692         int64_t ret_ref = (uintptr_t)ret_copy;
45693         return ret_ref;
45694 }
45695
45696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45697         LDKPaymentParameters this_ptr_conv;
45698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45699         this_ptr_conv.is_owned = false;
45700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45701         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45702         CHECK_ACCESS(val_ptr);
45703         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45704         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
45705         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
45706 }
45707
45708 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45709         LDKPaymentParameters this_ptr_conv;
45710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45711         this_ptr_conv.is_owned = false;
45712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45713         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
45714         return ret_conv;
45715 }
45716
45717 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) {
45718         LDKPaymentParameters this_ptr_conv;
45719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45720         this_ptr_conv.is_owned = false;
45721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45722         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
45723 }
45724
45725 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
45726         LDKPaymentParameters this_ptr_conv;
45727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45728         this_ptr_conv.is_owned = false;
45729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45730         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
45731         return ret_conv;
45732 }
45733
45734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
45735         LDKPaymentParameters this_ptr_conv;
45736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45737         this_ptr_conv.is_owned = false;
45738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45739         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
45740 }
45741
45742 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr) {
45743         LDKPaymentParameters this_ptr_conv;
45744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45745         this_ptr_conv.is_owned = false;
45746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45747         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
45748         return ret_conv;
45749 }
45750
45751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
45752         LDKPaymentParameters this_ptr_conv;
45753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45754         this_ptr_conv.is_owned = false;
45755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45756         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
45757 }
45758
45759 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
45760         LDKPaymentParameters this_ptr_conv;
45761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45762         this_ptr_conv.is_owned = false;
45763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45764         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
45765         int64_tArray ret_arr = NULL;
45766         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45767         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45768         for (size_t g = 0; g < ret_var.datalen; g++) {
45769                 int64_t ret_conv_6_conv = ret_var.data[g];
45770                 ret_arr_ptr[g] = ret_conv_6_conv;
45771         }
45772         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45773         FREE(ret_var.data);
45774         return ret_arr;
45775 }
45776
45777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45778         LDKPaymentParameters this_ptr_conv;
45779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45780         this_ptr_conv.is_owned = false;
45781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45782         LDKCVec_u64Z val_constr;
45783         val_constr.datalen = (*env)->GetArrayLength(env, val);
45784         if (val_constr.datalen > 0)
45785                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45786         else
45787                 val_constr.data = NULL;
45788         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45789         for (size_t g = 0; g < val_constr.datalen; g++) {
45790                 int64_t val_conv_6 = val_vals[g];
45791                 val_constr.data[g] = val_conv_6;
45792         }
45793         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45794         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
45795 }
45796
45797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1new(JNIEnv *env, jclass clz, int8_tArray payee_pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg) {
45798         LDKPublicKey payee_pubkey_arg_ref;
45799         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
45800         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
45801         LDKInvoiceFeatures features_arg_conv;
45802         features_arg_conv.inner = (void*)(features_arg & (~1));
45803         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
45804         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
45805         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
45806         LDKCVec_RouteHintZ route_hints_arg_constr;
45807         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
45808         if (route_hints_arg_constr.datalen > 0)
45809                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
45810         else
45811                 route_hints_arg_constr.data = NULL;
45812         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
45813         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
45814                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
45815                 LDKRouteHint route_hints_arg_conv_11_conv;
45816                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
45817                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
45818                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
45819                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
45820                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
45821         }
45822         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
45823         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
45824         CHECK_ACCESS(expiry_time_arg_ptr);
45825         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
45826         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
45827         LDKCVec_u64Z previously_failed_channels_arg_constr;
45828         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
45829         if (previously_failed_channels_arg_constr.datalen > 0)
45830                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45831         else
45832                 previously_failed_channels_arg_constr.data = NULL;
45833         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
45834         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
45835                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
45836                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
45837         }
45838         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
45839         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr);
45840         int64_t ret_ref = 0;
45841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45844         ret_ref = (uintptr_t)ret_var.inner;
45845         if (ret_var.is_owned) {
45846                 ret_ref |= 1;
45847         }
45848         return ret_ref;
45849 }
45850
45851 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
45852         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
45853 int64_t ret_ref = 0;
45854 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45855 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45856 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45857 ret_ref = (uintptr_t)ret_var.inner;
45858 if (ret_var.is_owned) {
45859         ret_ref |= 1;
45860 }
45861         return ret_ref;
45862 }
45863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45864         LDKPaymentParameters arg_conv;
45865         arg_conv.inner = (void*)(arg & (~1));
45866         arg_conv.is_owned = false;
45867         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45868         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
45869         return ret_conv;
45870 }
45871
45872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45873         LDKPaymentParameters orig_conv;
45874         orig_conv.inner = (void*)(orig & (~1));
45875         orig_conv.is_owned = false;
45876         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45877         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
45878         int64_t ret_ref = 0;
45879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45882         ret_ref = (uintptr_t)ret_var.inner;
45883         if (ret_var.is_owned) {
45884                 ret_ref |= 1;
45885         }
45886         return ret_ref;
45887 }
45888
45889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
45890         LDKPaymentParameters o_conv;
45891         o_conv.inner = (void*)(o & (~1));
45892         o_conv.is_owned = false;
45893         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45894         int64_t ret_conv = PaymentParameters_hash(&o_conv);
45895         return ret_conv;
45896 }
45897
45898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45899         LDKPaymentParameters a_conv;
45900         a_conv.inner = (void*)(a & (~1));
45901         a_conv.is_owned = false;
45902         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45903         LDKPaymentParameters b_conv;
45904         b_conv.inner = (void*)(b & (~1));
45905         b_conv.is_owned = false;
45906         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45907         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
45908         return ret_conv;
45909 }
45910
45911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
45912         LDKPaymentParameters obj_conv;
45913         obj_conv.inner = (void*)(obj & (~1));
45914         obj_conv.is_owned = false;
45915         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45916         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
45917         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45918         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45919         CVec_u8Z_free(ret_var);
45920         return ret_arr;
45921 }
45922
45923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45924         LDKu8slice ser_ref;
45925         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45926         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45927         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
45928         *ret_conv = PaymentParameters_read(ser_ref);
45929         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45930         return (int64_t)ret_conv;
45931 }
45932
45933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
45934         LDKPublicKey payee_pubkey_ref;
45935         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
45936         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
45937         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
45938         int64_t ret_ref = 0;
45939         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45940         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45942         ret_ref = (uintptr_t)ret_var.inner;
45943         if (ret_var.is_owned) {
45944                 ret_ref |= 1;
45945         }
45946         return ret_ref;
45947 }
45948
45949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
45950         LDKPublicKey payee_pubkey_ref;
45951         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
45952         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
45953         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
45954         int64_t ret_ref = 0;
45955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45958         ret_ref = (uintptr_t)ret_var.inner;
45959         if (ret_var.is_owned) {
45960                 ret_ref |= 1;
45961         }
45962         return ret_ref;
45963 }
45964
45965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45966         LDKRouteHint this_obj_conv;
45967         this_obj_conv.inner = (void*)(this_obj & (~1));
45968         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45970         RouteHint_free(this_obj_conv);
45971 }
45972
45973 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
45974         LDKRouteHint this_ptr_conv;
45975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45976         this_ptr_conv.is_owned = false;
45977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45978         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
45979         int64_tArray ret_arr = NULL;
45980         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45981         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45982         for (size_t o = 0; o < ret_var.datalen; o++) {
45983                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
45984                 int64_t ret_conv_14_ref = 0;
45985                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45986                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45987                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45988                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45989                 if (ret_conv_14_var.is_owned) {
45990                         ret_conv_14_ref |= 1;
45991                 }
45992                 ret_arr_ptr[o] = ret_conv_14_ref;
45993         }
45994         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45995         FREE(ret_var.data);
45996         return ret_arr;
45997 }
45998
45999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
46000         LDKRouteHint this_ptr_conv;
46001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46002         this_ptr_conv.is_owned = false;
46003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46004         LDKCVec_RouteHintHopZ val_constr;
46005         val_constr.datalen = (*env)->GetArrayLength(env, val);
46006         if (val_constr.datalen > 0)
46007                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
46008         else
46009                 val_constr.data = NULL;
46010         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
46011         for (size_t o = 0; o < val_constr.datalen; o++) {
46012                 int64_t val_conv_14 = val_vals[o];
46013                 LDKRouteHintHop val_conv_14_conv;
46014                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
46015                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
46016                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
46017                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
46018                 val_constr.data[o] = val_conv_14_conv;
46019         }
46020         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
46021         RouteHint_set_a(&this_ptr_conv, val_constr);
46022 }
46023
46024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
46025         LDKCVec_RouteHintHopZ a_arg_constr;
46026         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
46027         if (a_arg_constr.datalen > 0)
46028                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
46029         else
46030                 a_arg_constr.data = NULL;
46031         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
46032         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
46033                 int64_t a_arg_conv_14 = a_arg_vals[o];
46034                 LDKRouteHintHop a_arg_conv_14_conv;
46035                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
46036                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
46037                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
46038                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
46039                 a_arg_constr.data[o] = a_arg_conv_14_conv;
46040         }
46041         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
46042         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
46043         int64_t ret_ref = 0;
46044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46047         ret_ref = (uintptr_t)ret_var.inner;
46048         if (ret_var.is_owned) {
46049                 ret_ref |= 1;
46050         }
46051         return ret_ref;
46052 }
46053
46054 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
46055         LDKRouteHint ret_var = RouteHint_clone(arg);
46056 int64_t ret_ref = 0;
46057 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46058 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46059 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46060 ret_ref = (uintptr_t)ret_var.inner;
46061 if (ret_var.is_owned) {
46062         ret_ref |= 1;
46063 }
46064         return ret_ref;
46065 }
46066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46067         LDKRouteHint arg_conv;
46068         arg_conv.inner = (void*)(arg & (~1));
46069         arg_conv.is_owned = false;
46070         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46071         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
46072         return ret_conv;
46073 }
46074
46075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46076         LDKRouteHint orig_conv;
46077         orig_conv.inner = (void*)(orig & (~1));
46078         orig_conv.is_owned = false;
46079         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46080         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
46081         int64_t ret_ref = 0;
46082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46085         ret_ref = (uintptr_t)ret_var.inner;
46086         if (ret_var.is_owned) {
46087                 ret_ref |= 1;
46088         }
46089         return ret_ref;
46090 }
46091
46092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
46093         LDKRouteHint o_conv;
46094         o_conv.inner = (void*)(o & (~1));
46095         o_conv.is_owned = false;
46096         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46097         int64_t ret_conv = RouteHint_hash(&o_conv);
46098         return ret_conv;
46099 }
46100
46101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46102         LDKRouteHint a_conv;
46103         a_conv.inner = (void*)(a & (~1));
46104         a_conv.is_owned = false;
46105         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46106         LDKRouteHint b_conv;
46107         b_conv.inner = (void*)(b & (~1));
46108         b_conv.is_owned = false;
46109         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46110         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
46111         return ret_conv;
46112 }
46113
46114 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
46115         LDKRouteHint obj_conv;
46116         obj_conv.inner = (void*)(obj & (~1));
46117         obj_conv.is_owned = false;
46118         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46119         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
46120         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46121         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46122         CVec_u8Z_free(ret_var);
46123         return ret_arr;
46124 }
46125
46126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46127         LDKu8slice ser_ref;
46128         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46129         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46130         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
46131         *ret_conv = RouteHint_read(ser_ref);
46132         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46133         return (int64_t)ret_conv;
46134 }
46135
46136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46137         LDKRouteHintHop this_obj_conv;
46138         this_obj_conv.inner = (void*)(this_obj & (~1));
46139         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46141         RouteHintHop_free(this_obj_conv);
46142 }
46143
46144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
46145         LDKRouteHintHop this_ptr_conv;
46146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46147         this_ptr_conv.is_owned = false;
46148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46149         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
46151         return ret_arr;
46152 }
46153
46154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46155         LDKRouteHintHop this_ptr_conv;
46156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46157         this_ptr_conv.is_owned = false;
46158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46159         LDKPublicKey val_ref;
46160         CHECK((*env)->GetArrayLength(env, val) == 33);
46161         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
46162         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
46163 }
46164
46165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
46166         LDKRouteHintHop this_ptr_conv;
46167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46168         this_ptr_conv.is_owned = false;
46169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46170         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
46171         return ret_conv;
46172 }
46173
46174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46175         LDKRouteHintHop this_ptr_conv;
46176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46177         this_ptr_conv.is_owned = false;
46178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46179         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
46180 }
46181
46182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
46183         LDKRouteHintHop this_ptr_conv;
46184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46185         this_ptr_conv.is_owned = false;
46186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46187         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
46188         int64_t ret_ref = 0;
46189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46192         ret_ref = (uintptr_t)ret_var.inner;
46193         if (ret_var.is_owned) {
46194                 ret_ref |= 1;
46195         }
46196         return ret_ref;
46197 }
46198
46199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46200         LDKRouteHintHop this_ptr_conv;
46201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46202         this_ptr_conv.is_owned = false;
46203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46204         LDKRoutingFees val_conv;
46205         val_conv.inner = (void*)(val & (~1));
46206         val_conv.is_owned = (val & 1) || (val == 0);
46207         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46208         val_conv = RoutingFees_clone(&val_conv);
46209         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
46210 }
46211
46212 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
46213         LDKRouteHintHop this_ptr_conv;
46214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46215         this_ptr_conv.is_owned = false;
46216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46217         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
46218         return ret_conv;
46219 }
46220
46221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
46222         LDKRouteHintHop this_ptr_conv;
46223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46224         this_ptr_conv.is_owned = false;
46225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46226         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
46227 }
46228
46229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46230         LDKRouteHintHop this_ptr_conv;
46231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46232         this_ptr_conv.is_owned = false;
46233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46234         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46235         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
46236         int64_t ret_ref = (uintptr_t)ret_copy;
46237         return ret_ref;
46238 }
46239
46240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46241         LDKRouteHintHop this_ptr_conv;
46242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46243         this_ptr_conv.is_owned = false;
46244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46245         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46246         CHECK_ACCESS(val_ptr);
46247         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46248         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
46249         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
46250 }
46251
46252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46253         LDKRouteHintHop this_ptr_conv;
46254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46255         this_ptr_conv.is_owned = false;
46256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46257         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46258         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
46259         int64_t ret_ref = (uintptr_t)ret_copy;
46260         return ret_ref;
46261 }
46262
46263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46264         LDKRouteHintHop this_ptr_conv;
46265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46266         this_ptr_conv.is_owned = false;
46267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46268         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46269         CHECK_ACCESS(val_ptr);
46270         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46271         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
46272         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
46273 }
46274
46275 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) {
46276         LDKPublicKey src_node_id_arg_ref;
46277         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
46278         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
46279         LDKRoutingFees fees_arg_conv;
46280         fees_arg_conv.inner = (void*)(fees_arg & (~1));
46281         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
46282         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
46283         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
46284         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
46285         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
46286         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
46287         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
46288         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
46289         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
46290         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
46291         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
46292         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);
46293         int64_t ret_ref = 0;
46294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46297         ret_ref = (uintptr_t)ret_var.inner;
46298         if (ret_var.is_owned) {
46299                 ret_ref |= 1;
46300         }
46301         return ret_ref;
46302 }
46303
46304 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
46305         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
46306 int64_t ret_ref = 0;
46307 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46308 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46309 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46310 ret_ref = (uintptr_t)ret_var.inner;
46311 if (ret_var.is_owned) {
46312         ret_ref |= 1;
46313 }
46314         return ret_ref;
46315 }
46316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46317         LDKRouteHintHop arg_conv;
46318         arg_conv.inner = (void*)(arg & (~1));
46319         arg_conv.is_owned = false;
46320         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46321         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
46322         return ret_conv;
46323 }
46324
46325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46326         LDKRouteHintHop orig_conv;
46327         orig_conv.inner = (void*)(orig & (~1));
46328         orig_conv.is_owned = false;
46329         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46330         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
46331         int64_t ret_ref = 0;
46332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46335         ret_ref = (uintptr_t)ret_var.inner;
46336         if (ret_var.is_owned) {
46337                 ret_ref |= 1;
46338         }
46339         return ret_ref;
46340 }
46341
46342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
46343         LDKRouteHintHop o_conv;
46344         o_conv.inner = (void*)(o & (~1));
46345         o_conv.is_owned = false;
46346         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46347         int64_t ret_conv = RouteHintHop_hash(&o_conv);
46348         return ret_conv;
46349 }
46350
46351 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46352         LDKRouteHintHop a_conv;
46353         a_conv.inner = (void*)(a & (~1));
46354         a_conv.is_owned = false;
46355         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46356         LDKRouteHintHop b_conv;
46357         b_conv.inner = (void*)(b & (~1));
46358         b_conv.is_owned = false;
46359         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46360         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
46361         return ret_conv;
46362 }
46363
46364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
46365         LDKRouteHintHop obj_conv;
46366         obj_conv.inner = (void*)(obj & (~1));
46367         obj_conv.is_owned = false;
46368         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46369         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
46370         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46371         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46372         CVec_u8Z_free(ret_var);
46373         return ret_arr;
46374 }
46375
46376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46377         LDKu8slice ser_ref;
46378         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46379         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46380         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
46381         *ret_conv = RouteHintHop_read(ser_ref);
46382         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46383         return (int64_t)ret_conv;
46384 }
46385
46386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network_graph, int64_tArray first_hops, int64_t logger, int64_t scorer, int8_tArray random_seed_bytes) {
46387         LDKPublicKey our_node_pubkey_ref;
46388         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46389         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46390         LDKRouteParameters route_params_conv;
46391         route_params_conv.inner = (void*)(route_params & (~1));
46392         route_params_conv.is_owned = false;
46393         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46394         LDKNetworkGraph network_graph_conv;
46395         network_graph_conv.inner = (void*)(network_graph & (~1));
46396         network_graph_conv.is_owned = false;
46397         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46398         LDKCVec_ChannelDetailsZ first_hops_constr;
46399         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
46400         if (first_hops != NULL) {
46401                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
46402                 if (first_hops_constr.datalen > 0)
46403                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
46404                 else
46405                         first_hops_constr.data = NULL;
46406                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
46407                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
46408                         int64_t first_hops_conv_16 = first_hops_vals[q];
46409                         LDKChannelDetails first_hops_conv_16_conv;
46410                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
46411                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
46412                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
46413                         first_hops_constr.data[q] = first_hops_conv_16_conv;
46414                 }
46415                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
46416                 first_hops_ptr = &first_hops_constr;
46417         }
46418         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46419         CHECK_ACCESS(logger_ptr);
46420         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46421         if (logger_conv.free == LDKLogger_JCalls_free) {
46422                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46423                 LDKLogger_JCalls_cloned(&logger_conv);
46424         }
46425         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
46426         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
46427         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
46428         unsigned char random_seed_bytes_arr[32];
46429         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46430         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46431         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46432         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46433         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_graph_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
46434         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
46435         return (int64_t)ret_conv;
46436 }
46437
46438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_build_1route_1from_1hops(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, jobjectArray hops, int64_t route_params, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes) {
46439         LDKPublicKey our_node_pubkey_ref;
46440         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46441         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46442         LDKCVec_PublicKeyZ hops_constr;
46443         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
46444         if (hops_constr.datalen > 0)
46445                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
46446         else
46447                 hops_constr.data = NULL;
46448         for (size_t i = 0; i < hops_constr.datalen; i++) {
46449                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
46450                 LDKPublicKey hops_conv_8_ref;
46451                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
46452                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
46453                 hops_constr.data[i] = hops_conv_8_ref;
46454         }
46455         LDKRouteParameters route_params_conv;
46456         route_params_conv.inner = (void*)(route_params & (~1));
46457         route_params_conv.is_owned = false;
46458         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46459         LDKNetworkGraph network_graph_conv;
46460         network_graph_conv.inner = (void*)(network_graph & (~1));
46461         network_graph_conv.is_owned = false;
46462         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46463         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46464         CHECK_ACCESS(logger_ptr);
46465         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46466         if (logger_conv.free == LDKLogger_JCalls_free) {
46467                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46468                 LDKLogger_JCalls_cloned(&logger_conv);
46469         }
46470         unsigned char random_seed_bytes_arr[32];
46471         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46472         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46473         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46474         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46475         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
46476         return (int64_t)ret_conv;
46477 }
46478
46479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46480         if ((this_ptr & 1) != 0) return;
46481         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46482         CHECK_ACCESS(this_ptr_ptr);
46483         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
46484         FREE((void*)this_ptr);
46485         Score_free(this_ptr_conv);
46486 }
46487
46488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46489         if ((this_ptr & 1) != 0) return;
46490         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46491         CHECK_ACCESS(this_ptr_ptr);
46492         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
46493         FREE((void*)this_ptr);
46494         LockableScore_free(this_ptr_conv);
46495 }
46496
46497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46498         LDKMultiThreadedLockableScore this_obj_conv;
46499         this_obj_conv.inner = (void*)(this_obj & (~1));
46500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46502         MultiThreadedLockableScore_free(this_obj_conv);
46503 }
46504
46505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
46506         LDKMultiThreadedLockableScore obj_conv;
46507         obj_conv.inner = (void*)(obj & (~1));
46508         obj_conv.is_owned = false;
46509         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46510         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
46511         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46512         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46513         CVec_u8Z_free(ret_var);
46514         return ret_arr;
46515 }
46516
46517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
46518         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
46519         CHECK_ACCESS(score_ptr);
46520         LDKScore score_conv = *(LDKScore*)(score_ptr);
46521         if (score_conv.free == LDKScore_JCalls_free) {
46522                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46523                 LDKScore_JCalls_cloned(&score_conv);
46524         }
46525         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
46526         int64_t ret_ref = 0;
46527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46530         ret_ref = (uintptr_t)ret_var.inner;
46531         if (ret_var.is_owned) {
46532                 ret_ref |= 1;
46533         }
46534         return ret_ref;
46535 }
46536
46537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46538         LDKChannelUsage this_obj_conv;
46539         this_obj_conv.inner = (void*)(this_obj & (~1));
46540         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46542         ChannelUsage_free(this_obj_conv);
46543 }
46544
46545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46546         LDKChannelUsage this_ptr_conv;
46547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46548         this_ptr_conv.is_owned = false;
46549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46550         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
46551         return ret_conv;
46552 }
46553
46554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46555         LDKChannelUsage this_ptr_conv;
46556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46557         this_ptr_conv.is_owned = false;
46558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46559         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
46560 }
46561
46562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46563         LDKChannelUsage this_ptr_conv;
46564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46565         this_ptr_conv.is_owned = false;
46566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46567         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
46568         return ret_conv;
46569 }
46570
46571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46572         LDKChannelUsage this_ptr_conv;
46573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46574         this_ptr_conv.is_owned = false;
46575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46576         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
46577 }
46578
46579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
46580         LDKChannelUsage this_ptr_conv;
46581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46582         this_ptr_conv.is_owned = false;
46583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46584         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46585         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
46586         int64_t ret_ref = (uintptr_t)ret_copy;
46587         return ret_ref;
46588 }
46589
46590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46591         LDKChannelUsage this_ptr_conv;
46592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46593         this_ptr_conv.is_owned = false;
46594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46595         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46596         CHECK_ACCESS(val_ptr);
46597         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
46598         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
46599         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
46600 }
46601
46602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1new(JNIEnv *env, jclass clz, int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, int64_t effective_capacity_arg) {
46603         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
46604         CHECK_ACCESS(effective_capacity_arg_ptr);
46605         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
46606         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
46607         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
46608         int64_t ret_ref = 0;
46609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46612         ret_ref = (uintptr_t)ret_var.inner;
46613         if (ret_var.is_owned) {
46614                 ret_ref |= 1;
46615         }
46616         return ret_ref;
46617 }
46618
46619 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
46620         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
46621 int64_t ret_ref = 0;
46622 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46623 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46624 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46625 ret_ref = (uintptr_t)ret_var.inner;
46626 if (ret_var.is_owned) {
46627         ret_ref |= 1;
46628 }
46629         return ret_ref;
46630 }
46631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46632         LDKChannelUsage arg_conv;
46633         arg_conv.inner = (void*)(arg & (~1));
46634         arg_conv.is_owned = false;
46635         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46636         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
46637         return ret_conv;
46638 }
46639
46640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46641         LDKChannelUsage orig_conv;
46642         orig_conv.inner = (void*)(orig & (~1));
46643         orig_conv.is_owned = false;
46644         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46645         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
46646         int64_t ret_ref = 0;
46647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46650         ret_ref = (uintptr_t)ret_var.inner;
46651         if (ret_var.is_owned) {
46652                 ret_ref |= 1;
46653         }
46654         return ret_ref;
46655 }
46656
46657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46658         LDKFixedPenaltyScorer this_obj_conv;
46659         this_obj_conv.inner = (void*)(this_obj & (~1));
46660         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46662         FixedPenaltyScorer_free(this_obj_conv);
46663 }
46664
46665 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
46666         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
46667 int64_t ret_ref = 0;
46668 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46669 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46670 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46671 ret_ref = (uintptr_t)ret_var.inner;
46672 if (ret_var.is_owned) {
46673         ret_ref |= 1;
46674 }
46675         return ret_ref;
46676 }
46677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46678         LDKFixedPenaltyScorer arg_conv;
46679         arg_conv.inner = (void*)(arg & (~1));
46680         arg_conv.is_owned = false;
46681         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46682         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
46683         return ret_conv;
46684 }
46685
46686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46687         LDKFixedPenaltyScorer orig_conv;
46688         orig_conv.inner = (void*)(orig & (~1));
46689         orig_conv.is_owned = false;
46690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46691         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
46692         int64_t ret_ref = 0;
46693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46696         ret_ref = (uintptr_t)ret_var.inner;
46697         if (ret_var.is_owned) {
46698                 ret_ref |= 1;
46699         }
46700         return ret_ref;
46701 }
46702
46703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
46704         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
46705         int64_t ret_ref = 0;
46706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46709         ret_ref = (uintptr_t)ret_var.inner;
46710         if (ret_var.is_owned) {
46711                 ret_ref |= 1;
46712         }
46713         return ret_ref;
46714 }
46715
46716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
46717         LDKFixedPenaltyScorer this_arg_conv;
46718         this_arg_conv.inner = (void*)(this_arg & (~1));
46719         this_arg_conv.is_owned = false;
46720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46721         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
46722         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
46723         return (int64_t)ret_ret;
46724 }
46725
46726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
46727         LDKFixedPenaltyScorer obj_conv;
46728         obj_conv.inner = (void*)(obj & (~1));
46729         obj_conv.is_owned = false;
46730         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46731         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
46732         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46733         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46734         CVec_u8Z_free(ret_var);
46735         return ret_arr;
46736 }
46737
46738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
46739         LDKu8slice ser_ref;
46740         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46741         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46742         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
46743         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
46744         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46745         return (int64_t)ret_conv;
46746 }
46747
46748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46749         LDKProbabilisticScorer this_obj_conv;
46750         this_obj_conv.inner = (void*)(this_obj & (~1));
46751         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46753         ProbabilisticScorer_free(this_obj_conv);
46754 }
46755
46756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46757         LDKProbabilisticScoringParameters this_obj_conv;
46758         this_obj_conv.inner = (void*)(this_obj & (~1));
46759         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46761         ProbabilisticScoringParameters_free(this_obj_conv);
46762 }
46763
46764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46765         LDKProbabilisticScoringParameters this_ptr_conv;
46766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46767         this_ptr_conv.is_owned = false;
46768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46769         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
46770         return ret_conv;
46771 }
46772
46773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46774         LDKProbabilisticScoringParameters this_ptr_conv;
46775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46776         this_ptr_conv.is_owned = false;
46777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46778         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
46779 }
46780
46781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46782         LDKProbabilisticScoringParameters this_ptr_conv;
46783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46784         this_ptr_conv.is_owned = false;
46785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46786         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
46787         return ret_conv;
46788 }
46789
46790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46791         LDKProbabilisticScoringParameters this_ptr_conv;
46792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46793         this_ptr_conv.is_owned = false;
46794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46795         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
46796 }
46797
46798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46799         LDKProbabilisticScoringParameters this_ptr_conv;
46800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46801         this_ptr_conv.is_owned = false;
46802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46803         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
46804         return ret_conv;
46805 }
46806
46807 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) {
46808         LDKProbabilisticScoringParameters this_ptr_conv;
46809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46810         this_ptr_conv.is_owned = false;
46811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46812         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
46813 }
46814
46815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
46816         LDKProbabilisticScoringParameters this_ptr_conv;
46817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46818         this_ptr_conv.is_owned = false;
46819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46820         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
46821         return ret_conv;
46822 }
46823
46824 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) {
46825         LDKProbabilisticScoringParameters this_ptr_conv;
46826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46827         this_ptr_conv.is_owned = false;
46828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46829         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
46830 }
46831
46832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46833         LDKProbabilisticScoringParameters this_ptr_conv;
46834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46835         this_ptr_conv.is_owned = false;
46836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46837         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
46838         return ret_conv;
46839 }
46840
46841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46842         LDKProbabilisticScoringParameters this_ptr_conv;
46843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46844         this_ptr_conv.is_owned = false;
46845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46846         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
46847 }
46848
46849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46850         LDKProbabilisticScoringParameters this_ptr_conv;
46851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46852         this_ptr_conv.is_owned = false;
46853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46854         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
46855         return ret_conv;
46856 }
46857
46858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46859         LDKProbabilisticScoringParameters this_ptr_conv;
46860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46861         this_ptr_conv.is_owned = false;
46862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46863         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
46864 }
46865
46866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46867         LDKProbabilisticScoringParameters this_ptr_conv;
46868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46869         this_ptr_conv.is_owned = false;
46870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46871         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
46872         return ret_conv;
46873 }
46874
46875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46876         LDKProbabilisticScoringParameters this_ptr_conv;
46877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46878         this_ptr_conv.is_owned = false;
46879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46880         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
46881 }
46882
46883 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
46884         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
46885 int64_t ret_ref = 0;
46886 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46887 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46888 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46889 ret_ref = (uintptr_t)ret_var.inner;
46890 if (ret_var.is_owned) {
46891         ret_ref |= 1;
46892 }
46893         return ret_ref;
46894 }
46895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46896         LDKProbabilisticScoringParameters arg_conv;
46897         arg_conv.inner = (void*)(arg & (~1));
46898         arg_conv.is_owned = false;
46899         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46900         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
46901         return ret_conv;
46902 }
46903
46904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46905         LDKProbabilisticScoringParameters orig_conv;
46906         orig_conv.inner = (void*)(orig & (~1));
46907         orig_conv.is_owned = false;
46908         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46909         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
46910         int64_t ret_ref = 0;
46911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46914         ret_ref = (uintptr_t)ret_var.inner;
46915         if (ret_var.is_owned) {
46916                 ret_ref |= 1;
46917         }
46918         return ret_ref;
46919 }
46920
46921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph, int64_t logger) {
46922         LDKProbabilisticScoringParameters params_conv;
46923         params_conv.inner = (void*)(params & (~1));
46924         params_conv.is_owned = (params & 1) || (params == 0);
46925         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
46926         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
46927         LDKNetworkGraph network_graph_conv;
46928         network_graph_conv.inner = (void*)(network_graph & (~1));
46929         network_graph_conv.is_owned = false;
46930         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46931         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46932         CHECK_ACCESS(logger_ptr);
46933         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46934         if (logger_conv.free == LDKLogger_JCalls_free) {
46935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46936                 LDKLogger_JCalls_cloned(&logger_conv);
46937         }
46938         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
46939         int64_t ret_ref = 0;
46940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46943         ret_ref = (uintptr_t)ret_var.inner;
46944         if (ret_var.is_owned) {
46945                 ret_ref |= 1;
46946         }
46947         return ret_ref;
46948 }
46949
46950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
46951         LDKProbabilisticScorer this_arg_conv;
46952         this_arg_conv.inner = (void*)(this_arg & (~1));
46953         this_arg_conv.is_owned = false;
46954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46955         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
46956 }
46957
46958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1estimated_1channel_1liquidity_1range(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scid, int64_t target) {
46959         LDKProbabilisticScorer this_arg_conv;
46960         this_arg_conv.inner = (void*)(this_arg & (~1));
46961         this_arg_conv.is_owned = false;
46962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46963         LDKNodeId target_conv;
46964         target_conv.inner = (void*)(target & (~1));
46965         target_conv.is_owned = false;
46966         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
46967         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
46968         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
46969         int64_t ret_ref = (uintptr_t)ret_copy;
46970         return ret_ref;
46971 }
46972
46973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46974         LDKProbabilisticScorer this_arg_conv;
46975         this_arg_conv.inner = (void*)(this_arg & (~1));
46976         this_arg_conv.is_owned = false;
46977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46978         LDKNodeId node_id_conv;
46979         node_id_conv.inner = (void*)(node_id & (~1));
46980         node_id_conv.is_owned = false;
46981         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46982         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
46983 }
46984
46985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46986         LDKProbabilisticScorer this_arg_conv;
46987         this_arg_conv.inner = (void*)(this_arg & (~1));
46988         this_arg_conv.is_owned = false;
46989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46990         LDKNodeId node_id_conv;
46991         node_id_conv.inner = (void*)(node_id & (~1));
46992         node_id_conv.is_owned = false;
46993         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46994         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
46995 }
46996
46997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1set_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id, int64_t penalty) {
46998         LDKProbabilisticScorer this_arg_conv;
46999         this_arg_conv.inner = (void*)(this_arg & (~1));
47000         this_arg_conv.is_owned = false;
47001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47002         LDKNodeId node_id_conv;
47003         node_id_conv.inner = (void*)(node_id & (~1));
47004         node_id_conv.is_owned = false;
47005         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47006         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
47007 }
47008
47009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
47010         LDKProbabilisticScorer this_arg_conv;
47011         this_arg_conv.inner = (void*)(this_arg & (~1));
47012         this_arg_conv.is_owned = false;
47013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47014         LDKNodeId node_id_conv;
47015         node_id_conv.inner = (void*)(node_id & (~1));
47016         node_id_conv.is_owned = false;
47017         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47018         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
47019 }
47020
47021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
47022         LDKProbabilisticScorer this_arg_conv;
47023         this_arg_conv.inner = (void*)(this_arg & (~1));
47024         this_arg_conv.is_owned = false;
47025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47026         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
47027 }
47028
47029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1add_1banned_1from_1list(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray node_ids) {
47030         LDKProbabilisticScoringParameters this_arg_conv;
47031         this_arg_conv.inner = (void*)(this_arg & (~1));
47032         this_arg_conv.is_owned = false;
47033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47034         LDKCVec_NodeIdZ node_ids_constr;
47035         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
47036         if (node_ids_constr.datalen > 0)
47037                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
47038         else
47039                 node_ids_constr.data = NULL;
47040         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
47041         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
47042                 int64_t node_ids_conv_8 = node_ids_vals[i];
47043                 LDKNodeId node_ids_conv_8_conv;
47044                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
47045                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
47046                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
47047                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
47048                 node_ids_constr.data[i] = node_ids_conv_8_conv;
47049         }
47050         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
47051         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
47052 }
47053
47054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
47055         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
47056         int64_t ret_ref = 0;
47057         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47058         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47060         ret_ref = (uintptr_t)ret_var.inner;
47061         if (ret_var.is_owned) {
47062                 ret_ref |= 1;
47063         }
47064         return ret_ref;
47065 }
47066
47067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
47068         LDKProbabilisticScorer this_arg_conv;
47069         this_arg_conv.inner = (void*)(this_arg & (~1));
47070         this_arg_conv.is_owned = false;
47071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47072         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
47073         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
47074         return (int64_t)ret_ret;
47075 }
47076
47077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
47078         LDKProbabilisticScorer obj_conv;
47079         obj_conv.inner = (void*)(obj & (~1));
47080         obj_conv.is_owned = false;
47081         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47082         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
47083         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47084         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47085         CVec_u8Z_free(ret_var);
47086         return ret_arr;
47087 }
47088
47089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg_a, int64_t arg_b, int64_t arg_c) {
47090         LDKu8slice ser_ref;
47091         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47092         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47093         LDKProbabilisticScoringParameters arg_a_conv;
47094         arg_a_conv.inner = (void*)(arg_a & (~1));
47095         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
47096         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
47097         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
47098         LDKNetworkGraph arg_b_conv;
47099         arg_b_conv.inner = (void*)(arg_b & (~1));
47100         arg_b_conv.is_owned = false;
47101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
47102         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
47103         CHECK_ACCESS(arg_c_ptr);
47104         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
47105         if (arg_c_conv.free == LDKLogger_JCalls_free) {
47106                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47107                 LDKLogger_JCalls_cloned(&arg_c_conv);
47108         }
47109         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
47110         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
47111         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47112         return (int64_t)ret_conv;
47113 }
47114
47115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47116         LDKFilesystemPersister this_obj_conv;
47117         this_obj_conv.inner = (void*)(this_obj & (~1));
47118         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47120         FilesystemPersister_free(this_obj_conv);
47121 }
47122
47123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
47124         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
47125         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
47126         int64_t ret_ref = 0;
47127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47130         ret_ref = (uintptr_t)ret_var.inner;
47131         if (ret_var.is_owned) {
47132                 ret_ref |= 1;
47133         }
47134         return ret_ref;
47135 }
47136
47137 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
47138         LDKFilesystemPersister this_arg_conv;
47139         this_arg_conv.inner = (void*)(this_arg & (~1));
47140         this_arg_conv.is_owned = false;
47141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47142         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
47143         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47144         Str_free(ret_str);
47145         return ret_conv;
47146 }
47147
47148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
47149         LDKFilesystemPersister this_arg_conv;
47150         this_arg_conv.inner = (void*)(this_arg & (~1));
47151         this_arg_conv.is_owned = false;
47152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47153         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
47154         CHECK_ACCESS(keys_manager_ptr);
47155         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47156         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47157                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47158                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47159         }
47160         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
47161         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
47162         return (int64_t)ret_conv;
47163 }
47164
47165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47166         LDKBackgroundProcessor this_obj_conv;
47167         this_obj_conv.inner = (void*)(this_obj & (~1));
47168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47170         BackgroundProcessor_free(this_obj_conv);
47171 }
47172
47173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47174         if ((this_ptr & 1) != 0) return;
47175         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47176         CHECK_ACCESS(this_ptr_ptr);
47177         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
47178         FREE((void*)this_ptr);
47179         GossipSync_free(this_ptr_conv);
47180 }
47181
47182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
47183         LDKP2PGossipSync a_conv;
47184         a_conv.inner = (void*)(a & (~1));
47185         a_conv.is_owned = false;
47186         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47187         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
47188         *ret_copy = GossipSync_p2_p(&a_conv);
47189         int64_t ret_ref = (uintptr_t)ret_copy;
47190         return ret_ref;
47191 }
47192
47193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
47194         LDKRapidGossipSync a_conv;
47195         a_conv.inner = (void*)(a & (~1));
47196         a_conv.is_owned = false;
47197         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47198         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
47199         *ret_copy = GossipSync_rapid(&a_conv);
47200         int64_t ret_ref = (uintptr_t)ret_copy;
47201         return ret_ref;
47202 }
47203
47204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
47205         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
47206         *ret_copy = GossipSync_none();
47207         int64_t ret_ref = (uintptr_t)ret_copy;
47208         return ret_ref;
47209 }
47210
47211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t gossip_sync, int64_t peer_manager, int64_t logger, int64_t scorer) {
47212         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
47213         CHECK_ACCESS(persister_ptr);
47214         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
47215         if (persister_conv.free == LDKPersister_JCalls_free) {
47216                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47217                 LDKPersister_JCalls_cloned(&persister_conv);
47218         }
47219         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
47220         CHECK_ACCESS(event_handler_ptr);
47221         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
47222         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
47223                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47224                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
47225         }
47226         LDKChainMonitor chain_monitor_conv;
47227         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
47228         chain_monitor_conv.is_owned = false;
47229         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
47230         LDKChannelManager channel_manager_conv;
47231         channel_manager_conv.inner = (void*)(channel_manager & (~1));
47232         channel_manager_conv.is_owned = false;
47233         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
47234         void* gossip_sync_ptr = (void*)(((uintptr_t)gossip_sync) & ~1);
47235         CHECK_ACCESS(gossip_sync_ptr);
47236         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
47237         // WARNING: we may need a move here but no clone is available for LDKGossipSync
47238         LDKPeerManager peer_manager_conv;
47239         peer_manager_conv.inner = (void*)(peer_manager & (~1));
47240         peer_manager_conv.is_owned = false;
47241         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
47242         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
47243         CHECK_ACCESS(logger_ptr);
47244         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47245         if (logger_conv.free == LDKLogger_JCalls_free) {
47246                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47247                 LDKLogger_JCalls_cloned(&logger_conv);
47248         }
47249         LDKMultiThreadedLockableScore scorer_conv;
47250         scorer_conv.inner = (void*)(scorer & (~1));
47251         scorer_conv.is_owned = (scorer & 1) || (scorer == 0);
47252         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
47253         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, gossip_sync_conv, &peer_manager_conv, logger_conv, scorer_conv);
47254         int64_t ret_ref = 0;
47255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47258         ret_ref = (uintptr_t)ret_var.inner;
47259         if (ret_var.is_owned) {
47260                 ret_ref |= 1;
47261         }
47262         return ret_ref;
47263 }
47264
47265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
47266         LDKBackgroundProcessor this_arg_conv;
47267         this_arg_conv.inner = (void*)(this_arg & (~1));
47268         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47270         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47271         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47272         *ret_conv = BackgroundProcessor_join(this_arg_conv);
47273         return (int64_t)ret_conv;
47274 }
47275
47276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
47277         LDKBackgroundProcessor this_arg_conv;
47278         this_arg_conv.inner = (void*)(this_arg & (~1));
47279         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47281         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47282         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47283         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
47284         return (int64_t)ret_conv;
47285 }
47286
47287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47288         if ((this_ptr & 1) != 0) return;
47289         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47290         CHECK_ACCESS(this_ptr_ptr);
47291         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
47292         FREE((void*)this_ptr);
47293         ParseError_free(this_ptr_conv);
47294 }
47295
47296 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
47297         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47298         *ret_copy = ParseError_clone(arg);
47299 int64_t ret_ref = (uintptr_t)ret_copy;
47300         return ret_ref;
47301 }
47302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47303         LDKParseError* arg_conv = (LDKParseError*)arg;
47304         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
47305         return ret_conv;
47306 }
47307
47308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47309         LDKParseError* orig_conv = (LDKParseError*)orig;
47310         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47311         *ret_copy = ParseError_clone(orig_conv);
47312         int64_t ret_ref = (uintptr_t)ret_copy;
47313         return ret_ref;
47314 }
47315
47316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
47317         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
47318         CHECK_ACCESS(a_ptr);
47319         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
47320         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
47321         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47322         *ret_copy = ParseError_bech32_error(a_conv);
47323         int64_t ret_ref = (uintptr_t)ret_copy;
47324         return ret_ref;
47325 }
47326
47327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
47328         
47329         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47330         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
47331         int64_t ret_ref = (uintptr_t)ret_copy;
47332         return ret_ref;
47333 }
47334
47335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
47336         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
47337         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47338         *ret_copy = ParseError_malformed_signature(a_conv);
47339         int64_t ret_ref = (uintptr_t)ret_copy;
47340         return ret_ref;
47341 }
47342
47343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
47344         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47345         *ret_copy = ParseError_bad_prefix();
47346         int64_t ret_ref = (uintptr_t)ret_copy;
47347         return ret_ref;
47348 }
47349
47350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
47351         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47352         *ret_copy = ParseError_unknown_currency();
47353         int64_t ret_ref = (uintptr_t)ret_copy;
47354         return ret_ref;
47355 }
47356
47357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
47358         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47359         *ret_copy = ParseError_unknown_si_prefix();
47360         int64_t ret_ref = (uintptr_t)ret_copy;
47361         return ret_ref;
47362 }
47363
47364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
47365         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47366         *ret_copy = ParseError_malformed_hrp();
47367         int64_t ret_ref = (uintptr_t)ret_copy;
47368         return ret_ref;
47369 }
47370
47371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
47372         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47373         *ret_copy = ParseError_too_short_data_part();
47374         int64_t ret_ref = (uintptr_t)ret_copy;
47375         return ret_ref;
47376 }
47377
47378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
47379         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47380         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
47381         int64_t ret_ref = (uintptr_t)ret_copy;
47382         return ret_ref;
47383 }
47384
47385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
47386         
47387         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47388         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
47389         int64_t ret_ref = (uintptr_t)ret_copy;
47390         return ret_ref;
47391 }
47392
47393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
47394         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47395         *ret_copy = ParseError_padding_error();
47396         int64_t ret_ref = (uintptr_t)ret_copy;
47397         return ret_ref;
47398 }
47399
47400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
47401         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47402         *ret_copy = ParseError_integer_overflow_error();
47403         int64_t ret_ref = (uintptr_t)ret_copy;
47404         return ret_ref;
47405 }
47406
47407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
47408         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47409         *ret_copy = ParseError_invalid_seg_wit_program_length();
47410         int64_t ret_ref = (uintptr_t)ret_copy;
47411         return ret_ref;
47412 }
47413
47414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
47415         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47416         *ret_copy = ParseError_invalid_pub_key_hash_length();
47417         int64_t ret_ref = (uintptr_t)ret_copy;
47418         return ret_ref;
47419 }
47420
47421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
47422         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47423         *ret_copy = ParseError_invalid_script_hash_length();
47424         int64_t ret_ref = (uintptr_t)ret_copy;
47425         return ret_ref;
47426 }
47427
47428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
47429         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47430         *ret_copy = ParseError_invalid_recovery_id();
47431         int64_t ret_ref = (uintptr_t)ret_copy;
47432         return ret_ref;
47433 }
47434
47435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
47436         LDKStr a_conv = java_to_owned_str(env, a);
47437         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47438         *ret_copy = ParseError_invalid_slice_length(a_conv);
47439         int64_t ret_ref = (uintptr_t)ret_copy;
47440         return ret_ref;
47441 }
47442
47443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
47444         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47445         *ret_copy = ParseError_skip();
47446         int64_t ret_ref = (uintptr_t)ret_copy;
47447         return ret_ref;
47448 }
47449
47450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47451         if ((this_ptr & 1) != 0) return;
47452         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47453         CHECK_ACCESS(this_ptr_ptr);
47454         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
47455         FREE((void*)this_ptr);
47456         ParseOrSemanticError_free(this_ptr_conv);
47457 }
47458
47459 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
47460         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47461         *ret_copy = ParseOrSemanticError_clone(arg);
47462 int64_t ret_ref = (uintptr_t)ret_copy;
47463         return ret_ref;
47464 }
47465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47466         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
47467         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
47468         return ret_conv;
47469 }
47470
47471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47472         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
47473         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47474         *ret_copy = ParseOrSemanticError_clone(orig_conv);
47475         int64_t ret_ref = (uintptr_t)ret_copy;
47476         return ret_ref;
47477 }
47478
47479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
47480         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
47481         CHECK_ACCESS(a_ptr);
47482         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
47483         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
47484         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47485         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
47486         int64_t ret_ref = (uintptr_t)ret_copy;
47487         return ret_ref;
47488 }
47489
47490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
47491         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
47492         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47493         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
47494         int64_t ret_ref = (uintptr_t)ret_copy;
47495         return ret_ref;
47496 }
47497
47498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47499         LDKInvoice this_obj_conv;
47500         this_obj_conv.inner = (void*)(this_obj & (~1));
47501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47503         Invoice_free(this_obj_conv);
47504 }
47505
47506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47507         LDKInvoice a_conv;
47508         a_conv.inner = (void*)(a & (~1));
47509         a_conv.is_owned = false;
47510         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47511         LDKInvoice b_conv;
47512         b_conv.inner = (void*)(b & (~1));
47513         b_conv.is_owned = false;
47514         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47515         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
47516         return ret_conv;
47517 }
47518
47519 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
47520         LDKInvoice ret_var = Invoice_clone(arg);
47521 int64_t ret_ref = 0;
47522 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47523 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47524 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47525 ret_ref = (uintptr_t)ret_var.inner;
47526 if (ret_var.is_owned) {
47527         ret_ref |= 1;
47528 }
47529         return ret_ref;
47530 }
47531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47532         LDKInvoice arg_conv;
47533         arg_conv.inner = (void*)(arg & (~1));
47534         arg_conv.is_owned = false;
47535         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47536         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
47537         return ret_conv;
47538 }
47539
47540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47541         LDKInvoice orig_conv;
47542         orig_conv.inner = (void*)(orig & (~1));
47543         orig_conv.is_owned = false;
47544         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47545         LDKInvoice ret_var = Invoice_clone(&orig_conv);
47546         int64_t ret_ref = 0;
47547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47550         ret_ref = (uintptr_t)ret_var.inner;
47551         if (ret_var.is_owned) {
47552                 ret_ref |= 1;
47553         }
47554         return ret_ref;
47555 }
47556
47557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47558         LDKSignedRawInvoice this_obj_conv;
47559         this_obj_conv.inner = (void*)(this_obj & (~1));
47560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47562         SignedRawInvoice_free(this_obj_conv);
47563 }
47564
47565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47566         LDKSignedRawInvoice a_conv;
47567         a_conv.inner = (void*)(a & (~1));
47568         a_conv.is_owned = false;
47569         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47570         LDKSignedRawInvoice b_conv;
47571         b_conv.inner = (void*)(b & (~1));
47572         b_conv.is_owned = false;
47573         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47574         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
47575         return ret_conv;
47576 }
47577
47578 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
47579         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
47580 int64_t ret_ref = 0;
47581 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47582 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47583 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47584 ret_ref = (uintptr_t)ret_var.inner;
47585 if (ret_var.is_owned) {
47586         ret_ref |= 1;
47587 }
47588         return ret_ref;
47589 }
47590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47591         LDKSignedRawInvoice arg_conv;
47592         arg_conv.inner = (void*)(arg & (~1));
47593         arg_conv.is_owned = false;
47594         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47595         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
47596         return ret_conv;
47597 }
47598
47599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47600         LDKSignedRawInvoice orig_conv;
47601         orig_conv.inner = (void*)(orig & (~1));
47602         orig_conv.is_owned = false;
47603         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47604         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
47605         int64_t ret_ref = 0;
47606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47609         ret_ref = (uintptr_t)ret_var.inner;
47610         if (ret_var.is_owned) {
47611                 ret_ref |= 1;
47612         }
47613         return ret_ref;
47614 }
47615
47616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47617         LDKRawInvoice this_obj_conv;
47618         this_obj_conv.inner = (void*)(this_obj & (~1));
47619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47621         RawInvoice_free(this_obj_conv);
47622 }
47623
47624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
47625         LDKRawInvoice this_ptr_conv;
47626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47627         this_ptr_conv.is_owned = false;
47628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47629         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
47630         int64_t ret_ref = 0;
47631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47634         ret_ref = (uintptr_t)ret_var.inner;
47635         if (ret_var.is_owned) {
47636                 ret_ref |= 1;
47637         }
47638         return ret_ref;
47639 }
47640
47641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47642         LDKRawInvoice this_ptr_conv;
47643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47644         this_ptr_conv.is_owned = false;
47645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47646         LDKRawDataPart val_conv;
47647         val_conv.inner = (void*)(val & (~1));
47648         val_conv.is_owned = (val & 1) || (val == 0);
47649         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47650         val_conv = RawDataPart_clone(&val_conv);
47651         RawInvoice_set_data(&this_ptr_conv, val_conv);
47652 }
47653
47654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47655         LDKRawInvoice a_conv;
47656         a_conv.inner = (void*)(a & (~1));
47657         a_conv.is_owned = false;
47658         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47659         LDKRawInvoice b_conv;
47660         b_conv.inner = (void*)(b & (~1));
47661         b_conv.is_owned = false;
47662         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47663         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
47664         return ret_conv;
47665 }
47666
47667 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
47668         LDKRawInvoice ret_var = RawInvoice_clone(arg);
47669 int64_t ret_ref = 0;
47670 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47671 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47672 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47673 ret_ref = (uintptr_t)ret_var.inner;
47674 if (ret_var.is_owned) {
47675         ret_ref |= 1;
47676 }
47677         return ret_ref;
47678 }
47679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47680         LDKRawInvoice arg_conv;
47681         arg_conv.inner = (void*)(arg & (~1));
47682         arg_conv.is_owned = false;
47683         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47684         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
47685         return ret_conv;
47686 }
47687
47688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47689         LDKRawInvoice orig_conv;
47690         orig_conv.inner = (void*)(orig & (~1));
47691         orig_conv.is_owned = false;
47692         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47693         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
47694         int64_t ret_ref = 0;
47695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47698         ret_ref = (uintptr_t)ret_var.inner;
47699         if (ret_var.is_owned) {
47700                 ret_ref |= 1;
47701         }
47702         return ret_ref;
47703 }
47704
47705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47706         LDKRawDataPart this_obj_conv;
47707         this_obj_conv.inner = (void*)(this_obj & (~1));
47708         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47710         RawDataPart_free(this_obj_conv);
47711 }
47712
47713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
47714         LDKRawDataPart this_ptr_conv;
47715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47716         this_ptr_conv.is_owned = false;
47717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47718         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
47719         int64_t ret_ref = 0;
47720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47723         ret_ref = (uintptr_t)ret_var.inner;
47724         if (ret_var.is_owned) {
47725                 ret_ref |= 1;
47726         }
47727         return ret_ref;
47728 }
47729
47730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47731         LDKRawDataPart this_ptr_conv;
47732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47733         this_ptr_conv.is_owned = false;
47734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47735         LDKPositiveTimestamp val_conv;
47736         val_conv.inner = (void*)(val & (~1));
47737         val_conv.is_owned = (val & 1) || (val == 0);
47738         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47739         val_conv = PositiveTimestamp_clone(&val_conv);
47740         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
47741 }
47742
47743 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47744         LDKRawDataPart a_conv;
47745         a_conv.inner = (void*)(a & (~1));
47746         a_conv.is_owned = false;
47747         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47748         LDKRawDataPart b_conv;
47749         b_conv.inner = (void*)(b & (~1));
47750         b_conv.is_owned = false;
47751         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47752         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
47753         return ret_conv;
47754 }
47755
47756 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
47757         LDKRawDataPart ret_var = RawDataPart_clone(arg);
47758 int64_t ret_ref = 0;
47759 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47760 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47761 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47762 ret_ref = (uintptr_t)ret_var.inner;
47763 if (ret_var.is_owned) {
47764         ret_ref |= 1;
47765 }
47766         return ret_ref;
47767 }
47768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47769         LDKRawDataPart arg_conv;
47770         arg_conv.inner = (void*)(arg & (~1));
47771         arg_conv.is_owned = false;
47772         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47773         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
47774         return ret_conv;
47775 }
47776
47777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47778         LDKRawDataPart orig_conv;
47779         orig_conv.inner = (void*)(orig & (~1));
47780         orig_conv.is_owned = false;
47781         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47782         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
47783         int64_t ret_ref = 0;
47784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47787         ret_ref = (uintptr_t)ret_var.inner;
47788         if (ret_var.is_owned) {
47789                 ret_ref |= 1;
47790         }
47791         return ret_ref;
47792 }
47793
47794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47795         LDKPositiveTimestamp this_obj_conv;
47796         this_obj_conv.inner = (void*)(this_obj & (~1));
47797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47799         PositiveTimestamp_free(this_obj_conv);
47800 }
47801
47802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47803         LDKPositiveTimestamp a_conv;
47804         a_conv.inner = (void*)(a & (~1));
47805         a_conv.is_owned = false;
47806         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47807         LDKPositiveTimestamp b_conv;
47808         b_conv.inner = (void*)(b & (~1));
47809         b_conv.is_owned = false;
47810         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47811         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
47812         return ret_conv;
47813 }
47814
47815 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
47816         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
47817 int64_t ret_ref = 0;
47818 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47819 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47820 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47821 ret_ref = (uintptr_t)ret_var.inner;
47822 if (ret_var.is_owned) {
47823         ret_ref |= 1;
47824 }
47825         return ret_ref;
47826 }
47827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47828         LDKPositiveTimestamp arg_conv;
47829         arg_conv.inner = (void*)(arg & (~1));
47830         arg_conv.is_owned = false;
47831         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47832         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
47833         return ret_conv;
47834 }
47835
47836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47837         LDKPositiveTimestamp orig_conv;
47838         orig_conv.inner = (void*)(orig & (~1));
47839         orig_conv.is_owned = false;
47840         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47841         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
47842         int64_t ret_ref = 0;
47843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47846         ret_ref = (uintptr_t)ret_var.inner;
47847         if (ret_var.is_owned) {
47848                 ret_ref |= 1;
47849         }
47850         return ret_ref;
47851 }
47852
47853 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47854         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
47855         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
47856         return ret_conv;
47857 }
47858
47859 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
47860         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
47861         return ret_conv;
47862 }
47863
47864 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
47865         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
47866         return ret_conv;
47867 }
47868
47869 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
47870         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
47871         return ret_conv;
47872 }
47873
47874 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
47875         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
47876         return ret_conv;
47877 }
47878
47879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47880         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
47881         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
47882         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
47883         return ret_conv;
47884 }
47885
47886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
47887         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
47888         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
47889         return ret_conv;
47890 }
47891
47892 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47893         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
47894         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
47895         return ret_conv;
47896 }
47897
47898 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
47899         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
47900         return ret_conv;
47901 }
47902
47903 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
47904         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
47905         return ret_conv;
47906 }
47907
47908 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
47909         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
47910         return ret_conv;
47911 }
47912
47913 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
47914         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
47915         return ret_conv;
47916 }
47917
47918 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
47919         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
47920         return ret_conv;
47921 }
47922
47923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
47924         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
47925         int64_t ret_conv = Currency_hash(o_conv);
47926         return ret_conv;
47927 }
47928
47929 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47930         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
47931         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
47932         jboolean ret_conv = Currency_eq(a_conv, b_conv);
47933         return ret_conv;
47934 }
47935
47936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47937         LDKSha256 this_obj_conv;
47938         this_obj_conv.inner = (void*)(this_obj & (~1));
47939         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47941         Sha256_free(this_obj_conv);
47942 }
47943
47944 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
47945         LDKSha256 ret_var = Sha256_clone(arg);
47946 int64_t ret_ref = 0;
47947 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47948 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47949 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47950 ret_ref = (uintptr_t)ret_var.inner;
47951 if (ret_var.is_owned) {
47952         ret_ref |= 1;
47953 }
47954         return ret_ref;
47955 }
47956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47957         LDKSha256 arg_conv;
47958         arg_conv.inner = (void*)(arg & (~1));
47959         arg_conv.is_owned = false;
47960         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47961         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
47962         return ret_conv;
47963 }
47964
47965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47966         LDKSha256 orig_conv;
47967         orig_conv.inner = (void*)(orig & (~1));
47968         orig_conv.is_owned = false;
47969         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47970         LDKSha256 ret_var = Sha256_clone(&orig_conv);
47971         int64_t ret_ref = 0;
47972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47975         ret_ref = (uintptr_t)ret_var.inner;
47976         if (ret_var.is_owned) {
47977                 ret_ref |= 1;
47978         }
47979         return ret_ref;
47980 }
47981
47982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
47983         LDKSha256 o_conv;
47984         o_conv.inner = (void*)(o & (~1));
47985         o_conv.is_owned = false;
47986         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47987         int64_t ret_conv = Sha256_hash(&o_conv);
47988         return ret_conv;
47989 }
47990
47991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47992         LDKSha256 a_conv;
47993         a_conv.inner = (void*)(a & (~1));
47994         a_conv.is_owned = false;
47995         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47996         LDKSha256 b_conv;
47997         b_conv.inner = (void*)(b & (~1));
47998         b_conv.is_owned = false;
47999         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48000         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
48001         return ret_conv;
48002 }
48003
48004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48005         LDKDescription this_obj_conv;
48006         this_obj_conv.inner = (void*)(this_obj & (~1));
48007         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48009         Description_free(this_obj_conv);
48010 }
48011
48012 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
48013         LDKDescription ret_var = Description_clone(arg);
48014 int64_t ret_ref = 0;
48015 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48016 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48017 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48018 ret_ref = (uintptr_t)ret_var.inner;
48019 if (ret_var.is_owned) {
48020         ret_ref |= 1;
48021 }
48022         return ret_ref;
48023 }
48024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48025         LDKDescription arg_conv;
48026         arg_conv.inner = (void*)(arg & (~1));
48027         arg_conv.is_owned = false;
48028         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48029         int64_t ret_conv = Description_clone_ptr(&arg_conv);
48030         return ret_conv;
48031 }
48032
48033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48034         LDKDescription orig_conv;
48035         orig_conv.inner = (void*)(orig & (~1));
48036         orig_conv.is_owned = false;
48037         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48038         LDKDescription ret_var = Description_clone(&orig_conv);
48039         int64_t ret_ref = 0;
48040         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48041         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48043         ret_ref = (uintptr_t)ret_var.inner;
48044         if (ret_var.is_owned) {
48045                 ret_ref |= 1;
48046         }
48047         return ret_ref;
48048 }
48049
48050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
48051         LDKDescription o_conv;
48052         o_conv.inner = (void*)(o & (~1));
48053         o_conv.is_owned = false;
48054         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48055         int64_t ret_conv = Description_hash(&o_conv);
48056         return ret_conv;
48057 }
48058
48059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48060         LDKDescription a_conv;
48061         a_conv.inner = (void*)(a & (~1));
48062         a_conv.is_owned = false;
48063         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48064         LDKDescription b_conv;
48065         b_conv.inner = (void*)(b & (~1));
48066         b_conv.is_owned = false;
48067         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48068         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
48069         return ret_conv;
48070 }
48071
48072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48073         LDKPayeePubKey this_obj_conv;
48074         this_obj_conv.inner = (void*)(this_obj & (~1));
48075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48077         PayeePubKey_free(this_obj_conv);
48078 }
48079
48080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
48081         LDKPayeePubKey this_ptr_conv;
48082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48083         this_ptr_conv.is_owned = false;
48084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48085         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48086         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
48087         return ret_arr;
48088 }
48089
48090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
48091         LDKPayeePubKey this_ptr_conv;
48092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48093         this_ptr_conv.is_owned = false;
48094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48095         LDKPublicKey val_ref;
48096         CHECK((*env)->GetArrayLength(env, val) == 33);
48097         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
48098         PayeePubKey_set_a(&this_ptr_conv, val_ref);
48099 }
48100
48101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
48102         LDKPublicKey a_arg_ref;
48103         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
48104         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
48105         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
48106         int64_t ret_ref = 0;
48107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48110         ret_ref = (uintptr_t)ret_var.inner;
48111         if (ret_var.is_owned) {
48112                 ret_ref |= 1;
48113         }
48114         return ret_ref;
48115 }
48116
48117 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
48118         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
48119 int64_t ret_ref = 0;
48120 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48121 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48122 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48123 ret_ref = (uintptr_t)ret_var.inner;
48124 if (ret_var.is_owned) {
48125         ret_ref |= 1;
48126 }
48127         return ret_ref;
48128 }
48129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48130         LDKPayeePubKey arg_conv;
48131         arg_conv.inner = (void*)(arg & (~1));
48132         arg_conv.is_owned = false;
48133         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48134         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
48135         return ret_conv;
48136 }
48137
48138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48139         LDKPayeePubKey orig_conv;
48140         orig_conv.inner = (void*)(orig & (~1));
48141         orig_conv.is_owned = false;
48142         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48143         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
48144         int64_t ret_ref = 0;
48145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48148         ret_ref = (uintptr_t)ret_var.inner;
48149         if (ret_var.is_owned) {
48150                 ret_ref |= 1;
48151         }
48152         return ret_ref;
48153 }
48154
48155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
48156         LDKPayeePubKey o_conv;
48157         o_conv.inner = (void*)(o & (~1));
48158         o_conv.is_owned = false;
48159         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48160         int64_t ret_conv = PayeePubKey_hash(&o_conv);
48161         return ret_conv;
48162 }
48163
48164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48165         LDKPayeePubKey a_conv;
48166         a_conv.inner = (void*)(a & (~1));
48167         a_conv.is_owned = false;
48168         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48169         LDKPayeePubKey b_conv;
48170         b_conv.inner = (void*)(b & (~1));
48171         b_conv.is_owned = false;
48172         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48173         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
48174         return ret_conv;
48175 }
48176
48177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48178         LDKExpiryTime this_obj_conv;
48179         this_obj_conv.inner = (void*)(this_obj & (~1));
48180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48182         ExpiryTime_free(this_obj_conv);
48183 }
48184
48185 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
48186         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
48187 int64_t ret_ref = 0;
48188 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48189 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48190 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48191 ret_ref = (uintptr_t)ret_var.inner;
48192 if (ret_var.is_owned) {
48193         ret_ref |= 1;
48194 }
48195         return ret_ref;
48196 }
48197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48198         LDKExpiryTime arg_conv;
48199         arg_conv.inner = (void*)(arg & (~1));
48200         arg_conv.is_owned = false;
48201         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48202         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
48203         return ret_conv;
48204 }
48205
48206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48207         LDKExpiryTime orig_conv;
48208         orig_conv.inner = (void*)(orig & (~1));
48209         orig_conv.is_owned = false;
48210         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48211         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
48212         int64_t ret_ref = 0;
48213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48216         ret_ref = (uintptr_t)ret_var.inner;
48217         if (ret_var.is_owned) {
48218                 ret_ref |= 1;
48219         }
48220         return ret_ref;
48221 }
48222
48223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
48224         LDKExpiryTime o_conv;
48225         o_conv.inner = (void*)(o & (~1));
48226         o_conv.is_owned = false;
48227         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48228         int64_t ret_conv = ExpiryTime_hash(&o_conv);
48229         return ret_conv;
48230 }
48231
48232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48233         LDKExpiryTime a_conv;
48234         a_conv.inner = (void*)(a & (~1));
48235         a_conv.is_owned = false;
48236         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48237         LDKExpiryTime b_conv;
48238         b_conv.inner = (void*)(b & (~1));
48239         b_conv.is_owned = false;
48240         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48241         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
48242         return ret_conv;
48243 }
48244
48245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48246         LDKMinFinalCltvExpiry this_obj_conv;
48247         this_obj_conv.inner = (void*)(this_obj & (~1));
48248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48250         MinFinalCltvExpiry_free(this_obj_conv);
48251 }
48252
48253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
48254         LDKMinFinalCltvExpiry this_ptr_conv;
48255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48256         this_ptr_conv.is_owned = false;
48257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48258         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
48259         return ret_conv;
48260 }
48261
48262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48263         LDKMinFinalCltvExpiry this_ptr_conv;
48264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48265         this_ptr_conv.is_owned = false;
48266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48267         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
48268 }
48269
48270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
48271         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
48272         int64_t ret_ref = 0;
48273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48276         ret_ref = (uintptr_t)ret_var.inner;
48277         if (ret_var.is_owned) {
48278                 ret_ref |= 1;
48279         }
48280         return ret_ref;
48281 }
48282
48283 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
48284         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
48285 int64_t ret_ref = 0;
48286 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48287 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48288 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48289 ret_ref = (uintptr_t)ret_var.inner;
48290 if (ret_var.is_owned) {
48291         ret_ref |= 1;
48292 }
48293         return ret_ref;
48294 }
48295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48296         LDKMinFinalCltvExpiry arg_conv;
48297         arg_conv.inner = (void*)(arg & (~1));
48298         arg_conv.is_owned = false;
48299         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48300         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
48301         return ret_conv;
48302 }
48303
48304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48305         LDKMinFinalCltvExpiry orig_conv;
48306         orig_conv.inner = (void*)(orig & (~1));
48307         orig_conv.is_owned = false;
48308         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48309         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
48310         int64_t ret_ref = 0;
48311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48314         ret_ref = (uintptr_t)ret_var.inner;
48315         if (ret_var.is_owned) {
48316                 ret_ref |= 1;
48317         }
48318         return ret_ref;
48319 }
48320
48321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
48322         LDKMinFinalCltvExpiry o_conv;
48323         o_conv.inner = (void*)(o & (~1));
48324         o_conv.is_owned = false;
48325         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48326         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
48327         return ret_conv;
48328 }
48329
48330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48331         LDKMinFinalCltvExpiry a_conv;
48332         a_conv.inner = (void*)(a & (~1));
48333         a_conv.is_owned = false;
48334         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48335         LDKMinFinalCltvExpiry b_conv;
48336         b_conv.inner = (void*)(b & (~1));
48337         b_conv.is_owned = false;
48338         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48339         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
48340         return ret_conv;
48341 }
48342
48343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48344         if ((this_ptr & 1) != 0) return;
48345         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48346         CHECK_ACCESS(this_ptr_ptr);
48347         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
48348         FREE((void*)this_ptr);
48349         Fallback_free(this_ptr_conv);
48350 }
48351
48352 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
48353         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48354         *ret_copy = Fallback_clone(arg);
48355 int64_t ret_ref = (uintptr_t)ret_copy;
48356         return ret_ref;
48357 }
48358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48359         LDKFallback* arg_conv = (LDKFallback*)arg;
48360         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
48361         return ret_conv;
48362 }
48363
48364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48365         LDKFallback* orig_conv = (LDKFallback*)orig;
48366         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48367         *ret_copy = Fallback_clone(orig_conv);
48368         int64_t ret_ref = (uintptr_t)ret_copy;
48369         return ret_ref;
48370 }
48371
48372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
48373         
48374         LDKCVec_u8Z program_ref;
48375         program_ref.datalen = (*env)->GetArrayLength(env, program);
48376         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
48377         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
48378         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48379         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
48380         int64_t ret_ref = (uintptr_t)ret_copy;
48381         return ret_ref;
48382 }
48383
48384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
48385         LDKTwentyBytes a_ref;
48386         CHECK((*env)->GetArrayLength(env, a) == 20);
48387         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
48388         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48389         *ret_copy = Fallback_pub_key_hash(a_ref);
48390         int64_t ret_ref = (uintptr_t)ret_copy;
48391         return ret_ref;
48392 }
48393
48394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
48395         LDKTwentyBytes a_ref;
48396         CHECK((*env)->GetArrayLength(env, a) == 20);
48397         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
48398         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48399         *ret_copy = Fallback_script_hash(a_ref);
48400         int64_t ret_ref = (uintptr_t)ret_copy;
48401         return ret_ref;
48402 }
48403
48404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
48405         LDKFallback* o_conv = (LDKFallback*)o;
48406         int64_t ret_conv = Fallback_hash(o_conv);
48407         return ret_conv;
48408 }
48409
48410 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48411         LDKFallback* a_conv = (LDKFallback*)a;
48412         LDKFallback* b_conv = (LDKFallback*)b;
48413         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
48414         return ret_conv;
48415 }
48416
48417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48418         LDKInvoiceSignature this_obj_conv;
48419         this_obj_conv.inner = (void*)(this_obj & (~1));
48420         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48422         InvoiceSignature_free(this_obj_conv);
48423 }
48424
48425 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
48426         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
48427 int64_t ret_ref = 0;
48428 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48429 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48430 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48431 ret_ref = (uintptr_t)ret_var.inner;
48432 if (ret_var.is_owned) {
48433         ret_ref |= 1;
48434 }
48435         return ret_ref;
48436 }
48437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48438         LDKInvoiceSignature arg_conv;
48439         arg_conv.inner = (void*)(arg & (~1));
48440         arg_conv.is_owned = false;
48441         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48442         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
48443         return ret_conv;
48444 }
48445
48446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48447         LDKInvoiceSignature orig_conv;
48448         orig_conv.inner = (void*)(orig & (~1));
48449         orig_conv.is_owned = false;
48450         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48451         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
48452         int64_t ret_ref = 0;
48453         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48454         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48456         ret_ref = (uintptr_t)ret_var.inner;
48457         if (ret_var.is_owned) {
48458                 ret_ref |= 1;
48459         }
48460         return ret_ref;
48461 }
48462
48463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48464         LDKInvoiceSignature a_conv;
48465         a_conv.inner = (void*)(a & (~1));
48466         a_conv.is_owned = false;
48467         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48468         LDKInvoiceSignature b_conv;
48469         b_conv.inner = (void*)(b & (~1));
48470         b_conv.is_owned = false;
48471         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48472         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
48473         return ret_conv;
48474 }
48475
48476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48477         LDKPrivateRoute this_obj_conv;
48478         this_obj_conv.inner = (void*)(this_obj & (~1));
48479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48481         PrivateRoute_free(this_obj_conv);
48482 }
48483
48484 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
48485         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
48486 int64_t ret_ref = 0;
48487 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48488 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48489 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48490 ret_ref = (uintptr_t)ret_var.inner;
48491 if (ret_var.is_owned) {
48492         ret_ref |= 1;
48493 }
48494         return ret_ref;
48495 }
48496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48497         LDKPrivateRoute arg_conv;
48498         arg_conv.inner = (void*)(arg & (~1));
48499         arg_conv.is_owned = false;
48500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48501         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
48502         return ret_conv;
48503 }
48504
48505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48506         LDKPrivateRoute orig_conv;
48507         orig_conv.inner = (void*)(orig & (~1));
48508         orig_conv.is_owned = false;
48509         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48510         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
48511         int64_t ret_ref = 0;
48512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48515         ret_ref = (uintptr_t)ret_var.inner;
48516         if (ret_var.is_owned) {
48517                 ret_ref |= 1;
48518         }
48519         return ret_ref;
48520 }
48521
48522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
48523         LDKPrivateRoute o_conv;
48524         o_conv.inner = (void*)(o & (~1));
48525         o_conv.is_owned = false;
48526         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48527         int64_t ret_conv = PrivateRoute_hash(&o_conv);
48528         return ret_conv;
48529 }
48530
48531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48532         LDKPrivateRoute a_conv;
48533         a_conv.inner = (void*)(a & (~1));
48534         a_conv.is_owned = false;
48535         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48536         LDKPrivateRoute b_conv;
48537         b_conv.inner = (void*)(b & (~1));
48538         b_conv.is_owned = false;
48539         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48540         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
48541         return ret_conv;
48542 }
48543
48544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
48545         LDKSignedRawInvoice this_arg_conv;
48546         this_arg_conv.inner = (void*)(this_arg & (~1));
48547         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48549         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
48550         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
48551         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
48552         return ((int64_t)ret_conv);
48553 }
48554
48555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
48556         LDKSignedRawInvoice this_arg_conv;
48557         this_arg_conv.inner = (void*)(this_arg & (~1));
48558         this_arg_conv.is_owned = false;
48559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48560         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
48561         int64_t ret_ref = 0;
48562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48565         ret_ref = (uintptr_t)ret_var.inner;
48566         if (ret_var.is_owned) {
48567                 ret_ref |= 1;
48568         }
48569         return ret_ref;
48570 }
48571
48572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48573         LDKSignedRawInvoice this_arg_conv;
48574         this_arg_conv.inner = (void*)(this_arg & (~1));
48575         this_arg_conv.is_owned = false;
48576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48577         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48578         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
48579         return ret_arr;
48580 }
48581
48582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48583         LDKSignedRawInvoice this_arg_conv;
48584         this_arg_conv.inner = (void*)(this_arg & (~1));
48585         this_arg_conv.is_owned = false;
48586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48587         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
48588         int64_t ret_ref = 0;
48589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48592         ret_ref = (uintptr_t)ret_var.inner;
48593         if (ret_var.is_owned) {
48594                 ret_ref |= 1;
48595         }
48596         return ret_ref;
48597 }
48598
48599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48600         LDKSignedRawInvoice this_arg_conv;
48601         this_arg_conv.inner = (void*)(this_arg & (~1));
48602         this_arg_conv.is_owned = false;
48603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48604         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
48605         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
48606         return (int64_t)ret_conv;
48607 }
48608
48609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48610         LDKSignedRawInvoice this_arg_conv;
48611         this_arg_conv.inner = (void*)(this_arg & (~1));
48612         this_arg_conv.is_owned = false;
48613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48614         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
48615         return ret_conv;
48616 }
48617
48618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48619         LDKRawInvoice this_arg_conv;
48620         this_arg_conv.inner = (void*)(this_arg & (~1));
48621         this_arg_conv.is_owned = false;
48622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48623         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48624         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
48625         return ret_arr;
48626 }
48627
48628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48629         LDKRawInvoice this_arg_conv;
48630         this_arg_conv.inner = (void*)(this_arg & (~1));
48631         this_arg_conv.is_owned = false;
48632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48633         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
48634         int64_t ret_ref = 0;
48635         if ((uintptr_t)ret_var.inner > 4096) {
48636                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48637                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48639                 ret_ref = (uintptr_t)ret_var.inner;
48640                 if (ret_var.is_owned) {
48641                         ret_ref |= 1;
48642                 }
48643         }
48644         return ret_ref;
48645 }
48646
48647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
48648         LDKRawInvoice this_arg_conv;
48649         this_arg_conv.inner = (void*)(this_arg & (~1));
48650         this_arg_conv.is_owned = false;
48651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48652         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
48653         int64_t ret_ref = 0;
48654         if ((uintptr_t)ret_var.inner > 4096) {
48655                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48656                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48658                 ret_ref = (uintptr_t)ret_var.inner;
48659                 if (ret_var.is_owned) {
48660                         ret_ref |= 1;
48661                 }
48662         }
48663         return ret_ref;
48664 }
48665
48666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48667         LDKRawInvoice this_arg_conv;
48668         this_arg_conv.inner = (void*)(this_arg & (~1));
48669         this_arg_conv.is_owned = false;
48670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48671         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
48672         int64_t ret_ref = 0;
48673         if ((uintptr_t)ret_var.inner > 4096) {
48674                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48675                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48677                 ret_ref = (uintptr_t)ret_var.inner;
48678                 if (ret_var.is_owned) {
48679                         ret_ref |= 1;
48680                 }
48681         }
48682         return ret_ref;
48683 }
48684
48685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48686         LDKRawInvoice this_arg_conv;
48687         this_arg_conv.inner = (void*)(this_arg & (~1));
48688         this_arg_conv.is_owned = false;
48689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48690         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
48691         int64_t ret_ref = 0;
48692         if ((uintptr_t)ret_var.inner > 4096) {
48693                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48694                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48696                 ret_ref = (uintptr_t)ret_var.inner;
48697                 if (ret_var.is_owned) {
48698                         ret_ref |= 1;
48699                 }
48700         }
48701         return ret_ref;
48702 }
48703
48704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48705         LDKRawInvoice this_arg_conv;
48706         this_arg_conv.inner = (void*)(this_arg & (~1));
48707         this_arg_conv.is_owned = false;
48708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48709         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
48710         int64_t ret_ref = 0;
48711         if ((uintptr_t)ret_var.inner > 4096) {
48712                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48713                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48715                 ret_ref = (uintptr_t)ret_var.inner;
48716                 if (ret_var.is_owned) {
48717                         ret_ref |= 1;
48718                 }
48719         }
48720         return ret_ref;
48721 }
48722
48723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48724         LDKRawInvoice this_arg_conv;
48725         this_arg_conv.inner = (void*)(this_arg & (~1));
48726         this_arg_conv.is_owned = false;
48727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48728         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
48729         int64_t ret_ref = 0;
48730         if ((uintptr_t)ret_var.inner > 4096) {
48731                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48732                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48734                 ret_ref = (uintptr_t)ret_var.inner;
48735                 if (ret_var.is_owned) {
48736                         ret_ref |= 1;
48737                 }
48738         }
48739         return ret_ref;
48740 }
48741
48742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
48743         LDKRawInvoice this_arg_conv;
48744         this_arg_conv.inner = (void*)(this_arg & (~1));
48745         this_arg_conv.is_owned = false;
48746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48747         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48748         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
48749         return ret_arr;
48750 }
48751
48752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48753         LDKRawInvoice this_arg_conv;
48754         this_arg_conv.inner = (void*)(this_arg & (~1));
48755         this_arg_conv.is_owned = false;
48756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48757         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
48758         int64_t ret_ref = 0;
48759         if ((uintptr_t)ret_var.inner > 4096) {
48760                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48761                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48763                 ret_ref = (uintptr_t)ret_var.inner;
48764                 if (ret_var.is_owned) {
48765                         ret_ref |= 1;
48766                 }
48767         }
48768         return ret_ref;
48769 }
48770
48771 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
48772         LDKRawInvoice this_arg_conv;
48773         this_arg_conv.inner = (void*)(this_arg & (~1));
48774         this_arg_conv.is_owned = false;
48775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48776         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
48777         int64_tArray ret_arr = NULL;
48778         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48779         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48780         for (size_t o = 0; o < ret_var.datalen; o++) {
48781                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
48782                 int64_t ret_conv_14_ref = 0;
48783                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48784                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48785                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
48786                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
48787                 if (ret_conv_14_var.is_owned) {
48788                         ret_conv_14_ref |= 1;
48789                 }
48790                 ret_arr_ptr[o] = ret_conv_14_ref;
48791         }
48792         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48793         FREE(ret_var.data);
48794         return ret_arr;
48795 }
48796
48797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
48798         LDKRawInvoice this_arg_conv;
48799         this_arg_conv.inner = (void*)(this_arg & (~1));
48800         this_arg_conv.is_owned = false;
48801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48802         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48803         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
48804         int64_t ret_ref = (uintptr_t)ret_copy;
48805         return ret_ref;
48806 }
48807
48808 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
48809         LDKRawInvoice this_arg_conv;
48810         this_arg_conv.inner = (void*)(this_arg & (~1));
48811         this_arg_conv.is_owned = false;
48812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48813         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
48814         return ret_conv;
48815 }
48816
48817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
48818         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48819         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
48820         return (int64_t)ret_conv;
48821 }
48822
48823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
48824         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48825         *ret_conv = PositiveTimestamp_from_system_time(time);
48826         return (int64_t)ret_conv;
48827 }
48828
48829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
48830         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48831         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
48832         return (int64_t)ret_conv;
48833 }
48834
48835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
48836         LDKPositiveTimestamp this_arg_conv;
48837         this_arg_conv.inner = (void*)(this_arg & (~1));
48838         this_arg_conv.is_owned = false;
48839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48840         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
48841         return ret_conv;
48842 }
48843
48844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
48845         LDKPositiveTimestamp this_arg_conv;
48846         this_arg_conv.inner = (void*)(this_arg & (~1));
48847         this_arg_conv.is_owned = false;
48848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48849         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
48850         return ret_conv;
48851 }
48852
48853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48854         LDKPositiveTimestamp this_arg_conv;
48855         this_arg_conv.inner = (void*)(this_arg & (~1));
48856         this_arg_conv.is_owned = false;
48857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48858         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
48859         return ret_conv;
48860 }
48861
48862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
48863         LDKInvoice this_arg_conv;
48864         this_arg_conv.inner = (void*)(this_arg & (~1));
48865         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48867         this_arg_conv = Invoice_clone(&this_arg_conv);
48868         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
48869         int64_t ret_ref = 0;
48870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48873         ret_ref = (uintptr_t)ret_var.inner;
48874         if (ret_var.is_owned) {
48875                 ret_ref |= 1;
48876         }
48877         return ret_ref;
48878 }
48879
48880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48881         LDKInvoice this_arg_conv;
48882         this_arg_conv.inner = (void*)(this_arg & (~1));
48883         this_arg_conv.is_owned = false;
48884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48885         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
48886         *ret_conv = Invoice_check_signature(&this_arg_conv);
48887         return (int64_t)ret_conv;
48888 }
48889
48890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
48891         LDKSignedRawInvoice signed_invoice_conv;
48892         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
48893         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
48894         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
48895         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
48896         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
48897         *ret_conv = Invoice_from_signed(signed_invoice_conv);
48898         return (int64_t)ret_conv;
48899 }
48900
48901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
48902         LDKInvoice this_arg_conv;
48903         this_arg_conv.inner = (void*)(this_arg & (~1));
48904         this_arg_conv.is_owned = false;
48905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48906         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
48907         return ret_conv;
48908 }
48909
48910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
48911         LDKInvoice this_arg_conv;
48912         this_arg_conv.inner = (void*)(this_arg & (~1));
48913         this_arg_conv.is_owned = false;
48914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48915         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
48916         return ret_conv;
48917 }
48918
48919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48920         LDKInvoice this_arg_conv;
48921         this_arg_conv.inner = (void*)(this_arg & (~1));
48922         this_arg_conv.is_owned = false;
48923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48924         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48925         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
48926         return ret_arr;
48927 }
48928
48929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48930         LDKInvoice this_arg_conv;
48931         this_arg_conv.inner = (void*)(this_arg & (~1));
48932         this_arg_conv.is_owned = false;
48933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48934         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
48936         return ret_arr;
48937 }
48938
48939 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
48940         LDKInvoice this_arg_conv;
48941         this_arg_conv.inner = (void*)(this_arg & (~1));
48942         this_arg_conv.is_owned = false;
48943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48944         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48945         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
48946         return ret_arr;
48947 }
48948
48949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48950         LDKInvoice this_arg_conv;
48951         this_arg_conv.inner = (void*)(this_arg & (~1));
48952         this_arg_conv.is_owned = false;
48953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48954         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
48955         int64_t ret_ref = 0;
48956         if ((uintptr_t)ret_var.inner > 4096) {
48957                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48958                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48960                 ret_ref = (uintptr_t)ret_var.inner;
48961                 if (ret_var.is_owned) {
48962                         ret_ref |= 1;
48963                 }
48964         }
48965         return ret_ref;
48966 }
48967
48968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48969         LDKInvoice this_arg_conv;
48970         this_arg_conv.inner = (void*)(this_arg & (~1));
48971         this_arg_conv.is_owned = false;
48972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48973         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48974         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
48975         return ret_arr;
48976 }
48977
48978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48979         LDKInvoice this_arg_conv;
48980         this_arg_conv.inner = (void*)(this_arg & (~1));
48981         this_arg_conv.is_owned = false;
48982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48983         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
48984         return ret_conv;
48985 }
48986
48987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
48988         LDKInvoice this_arg_conv;
48989         this_arg_conv.inner = (void*)(this_arg & (~1));
48990         this_arg_conv.is_owned = false;
48991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48992         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
48993         return ret_conv;
48994 }
48995
48996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
48997         LDKInvoice this_arg_conv;
48998         this_arg_conv.inner = (void*)(this_arg & (~1));
48999         this_arg_conv.is_owned = false;
49000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49001         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
49002         return ret_conv;
49003 }
49004
49005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
49006         LDKInvoice this_arg_conv;
49007         this_arg_conv.inner = (void*)(this_arg & (~1));
49008         this_arg_conv.is_owned = false;
49009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49010         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
49011         return ret_conv;
49012 }
49013
49014 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
49015         LDKInvoice this_arg_conv;
49016         this_arg_conv.inner = (void*)(this_arg & (~1));
49017         this_arg_conv.is_owned = false;
49018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49019         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
49020         int64_tArray ret_arr = NULL;
49021         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49022         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49023         for (size_t o = 0; o < ret_var.datalen; o++) {
49024                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
49025                 int64_t ret_conv_14_ref = 0;
49026                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49027                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49028                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
49029                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
49030                 if (ret_conv_14_var.is_owned) {
49031                         ret_conv_14_ref |= 1;
49032                 }
49033                 ret_arr_ptr[o] = ret_conv_14_ref;
49034         }
49035         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49036         FREE(ret_var.data);
49037         return ret_arr;
49038 }
49039
49040 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
49041         LDKInvoice this_arg_conv;
49042         this_arg_conv.inner = (void*)(this_arg & (~1));
49043         this_arg_conv.is_owned = false;
49044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49045         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
49046         int64_tArray ret_arr = NULL;
49047         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49048         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49049         for (size_t l = 0; l < ret_var.datalen; l++) {
49050                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
49051                 int64_t ret_conv_11_ref = 0;
49052                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49053                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49054                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
49055                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
49056                 if (ret_conv_11_var.is_owned) {
49057                         ret_conv_11_ref |= 1;
49058                 }
49059                 ret_arr_ptr[l] = ret_conv_11_ref;
49060         }
49061         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49062         FREE(ret_var.data);
49063         return ret_arr;
49064 }
49065
49066 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
49067         LDKInvoice this_arg_conv;
49068         this_arg_conv.inner = (void*)(this_arg & (~1));
49069         this_arg_conv.is_owned = false;
49070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49071         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
49072         return ret_conv;
49073 }
49074
49075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
49076         LDKInvoice this_arg_conv;
49077         this_arg_conv.inner = (void*)(this_arg & (~1));
49078         this_arg_conv.is_owned = false;
49079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49080         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49081         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
49082         int64_t ret_ref = (uintptr_t)ret_copy;
49083         return ret_ref;
49084 }
49085
49086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
49087         LDKStr description_conv = java_to_owned_str(env, description);
49088         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
49089         *ret_conv = Description_new(description_conv);
49090         return (int64_t)ret_conv;
49091 }
49092
49093 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
49094         LDKDescription this_arg_conv;
49095         this_arg_conv.inner = (void*)(this_arg & (~1));
49096         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
49097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49098         this_arg_conv = Description_clone(&this_arg_conv);
49099         LDKStr ret_str = Description_into_inner(this_arg_conv);
49100         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49101         Str_free(ret_str);
49102         return ret_conv;
49103 }
49104
49105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
49106         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
49107         int64_t ret_ref = 0;
49108         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49109         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49111         ret_ref = (uintptr_t)ret_var.inner;
49112         if (ret_var.is_owned) {
49113                 ret_ref |= 1;
49114         }
49115         return ret_ref;
49116 }
49117
49118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
49119         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
49120         int64_t ret_ref = 0;
49121         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49122         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49124         ret_ref = (uintptr_t)ret_var.inner;
49125         if (ret_var.is_owned) {
49126                 ret_ref |= 1;
49127         }
49128         return ret_ref;
49129 }
49130
49131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
49132         LDKExpiryTime this_arg_conv;
49133         this_arg_conv.inner = (void*)(this_arg & (~1));
49134         this_arg_conv.is_owned = false;
49135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49136         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
49137         return ret_conv;
49138 }
49139
49140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
49141         LDKExpiryTime this_arg_conv;
49142         this_arg_conv.inner = (void*)(this_arg & (~1));
49143         this_arg_conv.is_owned = false;
49144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49145         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
49146         return ret_conv;
49147 }
49148
49149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
49150         LDKRouteHint hops_conv;
49151         hops_conv.inner = (void*)(hops & (~1));
49152         hops_conv.is_owned = (hops & 1) || (hops == 0);
49153         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
49154         hops_conv = RouteHint_clone(&hops_conv);
49155         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
49156         *ret_conv = PrivateRoute_new(hops_conv);
49157         return (int64_t)ret_conv;
49158 }
49159
49160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
49161         LDKPrivateRoute this_arg_conv;
49162         this_arg_conv.inner = (void*)(this_arg & (~1));
49163         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
49164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49165         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
49166         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
49167         int64_t ret_ref = 0;
49168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49171         ret_ref = (uintptr_t)ret_var.inner;
49172         if (ret_var.is_owned) {
49173                 ret_ref |= 1;
49174         }
49175         return ret_ref;
49176 }
49177
49178 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49179         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
49180         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
49181         return ret_conv;
49182 }
49183
49184 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
49185         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
49186         return ret_conv;
49187 }
49188
49189 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
49190         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
49191         return ret_conv;
49192 }
49193
49194 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
49195         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
49196         return ret_conv;
49197 }
49198
49199 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
49200         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
49201         return ret_conv;
49202 }
49203
49204 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
49205         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
49206         return ret_conv;
49207 }
49208
49209 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49210         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
49211         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
49212         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
49213         return ret_conv;
49214 }
49215
49216 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49217         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
49218         LDKStr ret_str = CreationError_to_str(o_conv);
49219         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49220         Str_free(ret_str);
49221         return ret_conv;
49222 }
49223
49224 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49225         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
49226         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
49227         return ret_conv;
49228 }
49229
49230 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
49231         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
49232         return ret_conv;
49233 }
49234
49235 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
49236         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
49237         return ret_conv;
49238 }
49239
49240 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
49241         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
49242         return ret_conv;
49243 }
49244
49245 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
49246         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
49247         return ret_conv;
49248 }
49249
49250 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
49251         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
49252         return ret_conv;
49253 }
49254
49255 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
49256         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
49257         return ret_conv;
49258 }
49259
49260 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
49261         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
49262         return ret_conv;
49263 }
49264
49265 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
49266         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
49267         return ret_conv;
49268 }
49269
49270 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
49271         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
49272         return ret_conv;
49273 }
49274
49275 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
49276         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
49277         return ret_conv;
49278 }
49279
49280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49281         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
49282         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
49283         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
49284         return ret_conv;
49285 }
49286
49287 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49288         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
49289         LDKStr ret_str = SemanticError_to_str(o_conv);
49290         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49291         Str_free(ret_str);
49292         return ret_conv;
49293 }
49294
49295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49296         if ((this_ptr & 1) != 0) return;
49297         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49298         CHECK_ACCESS(this_ptr_ptr);
49299         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
49300         FREE((void*)this_ptr);
49301         SignOrCreationError_free(this_ptr_conv);
49302 }
49303
49304 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
49305         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49306         *ret_copy = SignOrCreationError_clone(arg);
49307 int64_t ret_ref = (uintptr_t)ret_copy;
49308         return ret_ref;
49309 }
49310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49311         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
49312         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
49313         return ret_conv;
49314 }
49315
49316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49317         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
49318         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49319         *ret_copy = SignOrCreationError_clone(orig_conv);
49320         int64_t ret_ref = (uintptr_t)ret_copy;
49321         return ret_ref;
49322 }
49323
49324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
49325         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49326         *ret_copy = SignOrCreationError_sign_error();
49327         int64_t ret_ref = (uintptr_t)ret_copy;
49328         return ret_ref;
49329 }
49330
49331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
49332         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
49333         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49334         *ret_copy = SignOrCreationError_creation_error(a_conv);
49335         int64_t ret_ref = (uintptr_t)ret_copy;
49336         return ret_ref;
49337 }
49338
49339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49340         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
49341         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
49342         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
49343         return ret_conv;
49344 }
49345
49346 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49347         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
49348         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
49349         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49350         Str_free(ret_str);
49351         return ret_conv;
49352 }
49353
49354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49355         LDKInvoicePayer this_obj_conv;
49356         this_obj_conv.inner = (void*)(this_obj & (~1));
49357         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49359         InvoicePayer_free(this_obj_conv);
49360 }
49361
49362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49363         if ((this_ptr & 1) != 0) return;
49364         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49365         CHECK_ACCESS(this_ptr_ptr);
49366         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
49367         FREE((void*)this_ptr);
49368         Payer_free(this_ptr_conv);
49369 }
49370
49371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49372         if ((this_ptr & 1) != 0) return;
49373         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49374         CHECK_ACCESS(this_ptr_ptr);
49375         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
49376         FREE((void*)this_ptr);
49377         Router_free(this_ptr_conv);
49378 }
49379
49380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49381         if ((this_ptr & 1) != 0) return;
49382         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49383         CHECK_ACCESS(this_ptr_ptr);
49384         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
49385         FREE((void*)this_ptr);
49386         Retry_free(this_ptr_conv);
49387 }
49388
49389 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
49390         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49391         *ret_copy = Retry_clone(arg);
49392 int64_t ret_ref = (uintptr_t)ret_copy;
49393         return ret_ref;
49394 }
49395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49396         LDKRetry* arg_conv = (LDKRetry*)arg;
49397         int64_t ret_conv = Retry_clone_ptr(arg_conv);
49398         return ret_conv;
49399 }
49400
49401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49402         LDKRetry* orig_conv = (LDKRetry*)orig;
49403         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49404         *ret_copy = Retry_clone(orig_conv);
49405         int64_t ret_ref = (uintptr_t)ret_copy;
49406         return ret_ref;
49407 }
49408
49409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
49410         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49411         *ret_copy = Retry_attempts(a);
49412         int64_t ret_ref = (uintptr_t)ret_copy;
49413         return ret_ref;
49414 }
49415
49416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
49417         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49418         *ret_copy = Retry_timeout(a);
49419         int64_t ret_ref = (uintptr_t)ret_copy;
49420         return ret_ref;
49421 }
49422
49423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49424         LDKRetry* a_conv = (LDKRetry*)a;
49425         LDKRetry* b_conv = (LDKRetry*)b;
49426         jboolean ret_conv = Retry_eq(a_conv, b_conv);
49427         return ret_conv;
49428 }
49429
49430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
49431         LDKRetry* o_conv = (LDKRetry*)o;
49432         int64_t ret_conv = Retry_hash(o_conv);
49433         return ret_conv;
49434 }
49435
49436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49437         if ((this_ptr & 1) != 0) return;
49438         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49439         CHECK_ACCESS(this_ptr_ptr);
49440         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
49441         FREE((void*)this_ptr);
49442         PaymentError_free(this_ptr_conv);
49443 }
49444
49445 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
49446         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49447         *ret_copy = PaymentError_clone(arg);
49448 int64_t ret_ref = (uintptr_t)ret_copy;
49449         return ret_ref;
49450 }
49451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49452         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
49453         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
49454         return ret_conv;
49455 }
49456
49457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49458         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
49459         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49460         *ret_copy = PaymentError_clone(orig_conv);
49461         int64_t ret_ref = (uintptr_t)ret_copy;
49462         return ret_ref;
49463 }
49464
49465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
49466         LDKStr a_conv = java_to_owned_str(env, a);
49467         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49468         *ret_copy = PaymentError_invoice(a_conv);
49469         int64_t ret_ref = (uintptr_t)ret_copy;
49470         return ret_ref;
49471 }
49472
49473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
49474         LDKLightningError a_conv;
49475         a_conv.inner = (void*)(a & (~1));
49476         a_conv.is_owned = (a & 1) || (a == 0);
49477         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49478         a_conv = LightningError_clone(&a_conv);
49479         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49480         *ret_copy = PaymentError_routing(a_conv);
49481         int64_t ret_ref = (uintptr_t)ret_copy;
49482         return ret_ref;
49483 }
49484
49485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
49486         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
49487         CHECK_ACCESS(a_ptr);
49488         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
49489         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
49490         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49491         *ret_copy = PaymentError_sending(a_conv);
49492         int64_t ret_ref = (uintptr_t)ret_copy;
49493         return ret_ref;
49494 }
49495
49496 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) {
49497         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
49498         CHECK_ACCESS(payer_ptr);
49499         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
49500         if (payer_conv.free == LDKPayer_JCalls_free) {
49501                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49502                 LDKPayer_JCalls_cloned(&payer_conv);
49503         }
49504         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
49505         CHECK_ACCESS(router_ptr);
49506         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
49507         if (router_conv.free == LDKRouter_JCalls_free) {
49508                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49509                 LDKRouter_JCalls_cloned(&router_conv);
49510         }
49511         LDKMultiThreadedLockableScore scorer_conv;
49512         scorer_conv.inner = (void*)(scorer & (~1));
49513         scorer_conv.is_owned = false;
49514         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
49515         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
49516         CHECK_ACCESS(logger_ptr);
49517         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49518         if (logger_conv.free == LDKLogger_JCalls_free) {
49519                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49520                 LDKLogger_JCalls_cloned(&logger_conv);
49521         }
49522         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
49523         CHECK_ACCESS(event_handler_ptr);
49524         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
49525         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
49526                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49527                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
49528         }
49529         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
49530         CHECK_ACCESS(retry_ptr);
49531         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
49532         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
49533         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
49534         int64_t ret_ref = 0;
49535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49538         ret_ref = (uintptr_t)ret_var.inner;
49539         if (ret_var.is_owned) {
49540                 ret_ref |= 1;
49541         }
49542         return ret_ref;
49543 }
49544
49545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
49546         LDKInvoicePayer this_arg_conv;
49547         this_arg_conv.inner = (void*)(this_arg & (~1));
49548         this_arg_conv.is_owned = false;
49549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49550         LDKInvoice invoice_conv;
49551         invoice_conv.inner = (void*)(invoice & (~1));
49552         invoice_conv.is_owned = false;
49553         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
49554         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49555         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
49556         return (int64_t)ret_conv;
49557 }
49558
49559 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) {
49560         LDKInvoicePayer this_arg_conv;
49561         this_arg_conv.inner = (void*)(this_arg & (~1));
49562         this_arg_conv.is_owned = false;
49563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49564         LDKInvoice invoice_conv;
49565         invoice_conv.inner = (void*)(invoice & (~1));
49566         invoice_conv.is_owned = false;
49567         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
49568         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49569         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
49570         return (int64_t)ret_conv;
49571 }
49572
49573 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) {
49574         LDKInvoicePayer this_arg_conv;
49575         this_arg_conv.inner = (void*)(this_arg & (~1));
49576         this_arg_conv.is_owned = false;
49577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49578         LDKPublicKey pubkey_ref;
49579         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
49580         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
49581         LDKThirtyTwoBytes payment_preimage_ref;
49582         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
49583         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
49584         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49585         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
49586         return (int64_t)ret_conv;
49587 }
49588
49589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
49590         LDKInvoicePayer this_arg_conv;
49591         this_arg_conv.inner = (void*)(this_arg & (~1));
49592         this_arg_conv.is_owned = false;
49593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49594         unsigned char payment_hash_arr[32];
49595         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49596         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
49597         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
49598         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
49599 }
49600
49601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
49602         LDKInvoicePayer this_arg_conv;
49603         this_arg_conv.inner = (void*)(this_arg & (~1));
49604         this_arg_conv.is_owned = false;
49605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49606         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
49607         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
49608         return (int64_t)ret_ret;
49609 }
49610
49611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, jstring description, int32_t invoice_expiry_delta_secs, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
49612         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49613         CHECK_ACCESS(amt_msat_ptr);
49614         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49615         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49616         LDKThirtyTwoBytes payment_hash_ref;
49617         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49618         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
49619         LDKStr description_conv = java_to_owned_str(env, description);
49620         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
49621         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
49622         if (phantom_route_hints_constr.datalen > 0)
49623                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
49624         else
49625                 phantom_route_hints_constr.data = NULL;
49626         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
49627         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
49628                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
49629                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
49630                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
49631                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
49632                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
49633                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
49634                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
49635         }
49636         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
49637         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49638         CHECK_ACCESS(keys_manager_ptr);
49639         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49640         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49641                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49642                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49643         }
49644         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49645         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49646         *ret_conv = create_phantom_invoice(amt_msat_conv, payment_hash_ref, description_conv, invoice_expiry_delta_secs, phantom_route_hints_constr, keys_manager_conv, network_conv);
49647         return (int64_t)ret_conv;
49648 }
49649
49650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t description_hash, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
49651         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49652         CHECK_ACCESS(amt_msat_ptr);
49653         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49654         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49655         LDKThirtyTwoBytes payment_hash_ref;
49656         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49657         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
49658         LDKSha256 description_hash_conv;
49659         description_hash_conv.inner = (void*)(description_hash & (~1));
49660         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49661         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49662         description_hash_conv = Sha256_clone(&description_hash_conv);
49663         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
49664         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
49665         if (phantom_route_hints_constr.datalen > 0)
49666                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
49667         else
49668                 phantom_route_hints_constr.data = NULL;
49669         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
49670         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
49671                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
49672                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
49673                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
49674                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
49675                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
49676                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
49677                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
49678         }
49679         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
49680         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49681         CHECK_ACCESS(keys_manager_ptr);
49682         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49683         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49684                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49685                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49686         }
49687         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49688         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49689         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, description_hash_conv, phantom_route_hints_constr, keys_manager_conv, network_conv);
49690         return (int64_t)ret_conv;
49691 }
49692
49693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int32_t invoice_expiry_delta_secs) {
49694         LDKChannelManager channelmanager_conv;
49695         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49696         channelmanager_conv.is_owned = false;
49697         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49698         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49699         CHECK_ACCESS(keys_manager_ptr);
49700         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49701         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49702                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49703                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49704         }
49705         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49706         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49707         CHECK_ACCESS(amt_msat_ptr);
49708         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49709         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49710         LDKStr description_conv = java_to_owned_str(env, description);
49711         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49712         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
49713         return (int64_t)ret_conv;
49714 }
49715
49716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int32_t invoice_expiry_delta_secs) {
49717         LDKChannelManager channelmanager_conv;
49718         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49719         channelmanager_conv.is_owned = false;
49720         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49721         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49722         CHECK_ACCESS(keys_manager_ptr);
49723         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49724         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49725                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49726                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49727         }
49728         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49729         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49730         CHECK_ACCESS(amt_msat_ptr);
49731         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49732         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49733         LDKSha256 description_hash_conv;
49734         description_hash_conv.inner = (void*)(description_hash & (~1));
49735         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49736         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49737         description_hash_conv = Sha256_clone(&description_hash_conv);
49738         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49739         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, invoice_expiry_delta_secs);
49740         return (int64_t)ret_conv;
49741 }
49742
49743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
49744         LDKChannelManager channelmanager_conv;
49745         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49746         channelmanager_conv.is_owned = false;
49747         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49748         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49749         CHECK_ACCESS(keys_manager_ptr);
49750         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49751         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49752                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49753                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49754         }
49755         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49756         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49757         CHECK_ACCESS(amt_msat_ptr);
49758         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49759         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49760         LDKSha256 description_hash_conv;
49761         description_hash_conv.inner = (void*)(description_hash & (~1));
49762         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49763         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49764         description_hash_conv = Sha256_clone(&description_hash_conv);
49765         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49766         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs);
49767         return (int64_t)ret_conv;
49768 }
49769
49770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
49771         LDKChannelManager channelmanager_conv;
49772         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49773         channelmanager_conv.is_owned = false;
49774         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49775         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49776         CHECK_ACCESS(keys_manager_ptr);
49777         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49778         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49779                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49780                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49781         }
49782         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49783         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49784         CHECK_ACCESS(amt_msat_ptr);
49785         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49786         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49787         LDKStr description_conv = java_to_owned_str(env, description);
49788         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49789         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs);
49790         return (int64_t)ret_conv;
49791 }
49792
49793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49794         LDKDefaultRouter this_obj_conv;
49795         this_obj_conv.inner = (void*)(this_obj & (~1));
49796         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49798         DefaultRouter_free(this_obj_conv);
49799 }
49800
49801 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) {
49802         LDKNetworkGraph network_graph_conv;
49803         network_graph_conv.inner = (void*)(network_graph & (~1));
49804         network_graph_conv.is_owned = false;
49805         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49806         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
49807         CHECK_ACCESS(logger_ptr);
49808         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49809         if (logger_conv.free == LDKLogger_JCalls_free) {
49810                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49811                 LDKLogger_JCalls_cloned(&logger_conv);
49812         }
49813         LDKThirtyTwoBytes random_seed_bytes_ref;
49814         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
49815         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
49816         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
49817         int64_t ret_ref = 0;
49818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49821         ret_ref = (uintptr_t)ret_var.inner;
49822         if (ret_var.is_owned) {
49823                 ret_ref |= 1;
49824         }
49825         return ret_ref;
49826 }
49827
49828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
49829         LDKDefaultRouter this_arg_conv;
49830         this_arg_conv.inner = (void*)(this_arg & (~1));
49831         this_arg_conv.is_owned = false;
49832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49833         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
49834         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
49835         return (int64_t)ret_ret;
49836 }
49837
49838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
49839         LDKChannelManager this_arg_conv;
49840         this_arg_conv.inner = (void*)(this_arg & (~1));
49841         this_arg_conv.is_owned = false;
49842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49843         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
49844         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
49845         return (int64_t)ret_ret;
49846 }
49847
49848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49849         LDKStr s_conv = java_to_owned_str(env, s);
49850         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
49851         *ret_conv = SiPrefix_from_str(s_conv);
49852         return (int64_t)ret_conv;
49853 }
49854
49855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49856         LDKStr s_conv = java_to_owned_str(env, s);
49857         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
49858         *ret_conv = Invoice_from_str(s_conv);
49859         return (int64_t)ret_conv;
49860 }
49861
49862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49863         LDKStr s_conv = java_to_owned_str(env, s);
49864         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
49865         *ret_conv = SignedRawInvoice_from_str(s_conv);
49866         return (int64_t)ret_conv;
49867 }
49868
49869 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49870         LDKParseError* o_conv = (LDKParseError*)o;
49871         LDKStr ret_str = ParseError_to_str(o_conv);
49872         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49873         Str_free(ret_str);
49874         return ret_conv;
49875 }
49876
49877 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49878         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
49879         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
49880         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49881         Str_free(ret_str);
49882         return ret_conv;
49883 }
49884
49885 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49886         LDKInvoice o_conv;
49887         o_conv.inner = (void*)(o & (~1));
49888         o_conv.is_owned = false;
49889         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49890         LDKStr ret_str = Invoice_to_str(&o_conv);
49891         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49892         Str_free(ret_str);
49893         return ret_conv;
49894 }
49895
49896 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49897         LDKSignedRawInvoice o_conv;
49898         o_conv.inner = (void*)(o & (~1));
49899         o_conv.is_owned = false;
49900         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49901         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
49902         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49903         Str_free(ret_str);
49904         return ret_conv;
49905 }
49906
49907 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49908         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
49909         LDKStr ret_str = Currency_to_str(o_conv);
49910         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49911         Str_free(ret_str);
49912         return ret_conv;
49913 }
49914
49915 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49916         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
49917         LDKStr ret_str = SiPrefix_to_str(o_conv);
49918         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49919         Str_free(ret_str);
49920         return ret_conv;
49921 }
49922
49923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49924         LDKRapidGossipSync this_obj_conv;
49925         this_obj_conv.inner = (void*)(this_obj & (~1));
49926         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49928         RapidGossipSync_free(this_obj_conv);
49929 }
49930
49931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
49932         LDKNetworkGraph network_graph_conv;
49933         network_graph_conv.inner = (void*)(network_graph & (~1));
49934         network_graph_conv.is_owned = false;
49935         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49936         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
49937         int64_t ret_ref = 0;
49938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49941         ret_ref = (uintptr_t)ret_var.inner;
49942         if (ret_var.is_owned) {
49943                 ret_ref |= 1;
49944         }
49945         return ret_ref;
49946 }
49947
49948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1sync_1network_1graph_1with_1file_1path(JNIEnv *env, jclass clz, int64_t this_arg, jstring sync_path) {
49949         LDKRapidGossipSync this_arg_conv;
49950         this_arg_conv.inner = (void*)(this_arg & (~1));
49951         this_arg_conv.is_owned = false;
49952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49953         LDKStr sync_path_conv = java_to_owned_str(env, sync_path);
49954         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
49955         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
49956         return (int64_t)ret_conv;
49957 }
49958
49959 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
49960         LDKRapidGossipSync this_arg_conv;
49961         this_arg_conv.inner = (void*)(this_arg & (~1));
49962         this_arg_conv.is_owned = false;
49963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49964         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
49965         return ret_conv;
49966 }
49967
49968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49969         if ((this_ptr & 1) != 0) return;
49970         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49971         CHECK_ACCESS(this_ptr_ptr);
49972         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
49973         FREE((void*)this_ptr);
49974         GraphSyncError_free(this_ptr_conv);
49975 }
49976
49977 static inline uintptr_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
49978         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49979         *ret_copy = GraphSyncError_clone(arg);
49980 int64_t ret_ref = (uintptr_t)ret_copy;
49981         return ret_ref;
49982 }
49983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49984         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)arg;
49985         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
49986         return ret_conv;
49987 }
49988
49989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49990         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)orig;
49991         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49992         *ret_copy = GraphSyncError_clone(orig_conv);
49993         int64_t ret_ref = (uintptr_t)ret_copy;
49994         return ret_ref;
49995 }
49996
49997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
49998         LDKDecodeError a_conv;
49999         a_conv.inner = (void*)(a & (~1));
50000         a_conv.is_owned = (a & 1) || (a == 0);
50001         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50002         a_conv = DecodeError_clone(&a_conv);
50003         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
50004         *ret_copy = GraphSyncError_decode_error(a_conv);
50005         int64_t ret_ref = (uintptr_t)ret_copy;
50006         return ret_ref;
50007 }
50008
50009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
50010         LDKLightningError a_conv;
50011         a_conv.inner = (void*)(a & (~1));
50012         a_conv.is_owned = (a & 1) || (a == 0);
50013         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50014         a_conv = LightningError_clone(&a_conv);
50015         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
50016         *ret_copy = GraphSyncError_lightning_error(a_conv);
50017         int64_t ret_ref = (uintptr_t)ret_copy;
50018         return ret_ref;
50019 }
50020
50021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1update_1network_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray update_data) {
50022         LDKRapidGossipSync this_arg_conv;
50023         this_arg_conv.inner = (void*)(this_arg & (~1));
50024         this_arg_conv.is_owned = false;
50025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50026         LDKu8slice update_data_ref;
50027         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
50028         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
50029         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
50030         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
50031         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
50032         return (int64_t)ret_conv;
50033 }
50034