4250dc0739e4dadbb4ca3d1c82dfa1d78f15f465
[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_InvalidRecoveryId;
685                 case 6: return LDKSecp256k1Error_InvalidTweak;
686                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
687                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
688         }
689         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
690         abort(); // Unreachable, but will let the compiler know we don't return here
691 }
692 static jclass Secp256k1Error_class = NULL;
693 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
694 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
700 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
701 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
702 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
703         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
704         CHECK(Secp256k1Error_class != NULL);
705         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
706         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
707         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
708         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
709         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
717         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
719         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
721         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
722         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
723 }
724 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
725         switch (val) {
726                 case LDKSecp256k1Error_IncorrectSignature:
727                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
728                 case LDKSecp256k1Error_InvalidMessage:
729                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
730                 case LDKSecp256k1Error_InvalidPublicKey:
731                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
732                 case LDKSecp256k1Error_InvalidSignature:
733                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
734                 case LDKSecp256k1Error_InvalidSecretKey:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
736                 case LDKSecp256k1Error_InvalidRecoveryId:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
738                 case LDKSecp256k1Error_InvalidTweak:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
740                 case LDKSecp256k1Error_TweakCheckFailed:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
742                 case LDKSecp256k1Error_NotEnoughMemory:
743                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
744                 default: abort();
745         }
746 }
747
748 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
749         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
750         if (UNLIKELY((*env)->ExceptionCheck(env))) {
751                 (*env)->ExceptionDescribe(env);
752                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
753         }
754         switch (ord) {
755                 case 0: return LDKSemanticError_NoPaymentHash;
756                 case 1: return LDKSemanticError_MultiplePaymentHashes;
757                 case 2: return LDKSemanticError_NoDescription;
758                 case 3: return LDKSemanticError_MultipleDescriptions;
759                 case 4: return LDKSemanticError_NoPaymentSecret;
760                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
761                 case 6: return LDKSemanticError_InvalidFeatures;
762                 case 7: return LDKSemanticError_InvalidRecoveryId;
763                 case 8: return LDKSemanticError_InvalidSignature;
764                 case 9: return LDKSemanticError_ImpreciseAmount;
765         }
766         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
767         abort(); // Unreachable, but will let the compiler know we don't return here
768 }
769 static jclass SemanticError_class = NULL;
770 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
771 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
772 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
773 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
774 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
775 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
776 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
777 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
778 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
779 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
780 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
781         SemanticError_class = (*env)->NewGlobalRef(env, clz);
782         CHECK(SemanticError_class != NULL);
783         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
784         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
785         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
786         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
787         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
788         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
789         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
790         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
791         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
792         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
793         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
794         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
795         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
797         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
799         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
801         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
802         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
803 }
804 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
805         switch (val) {
806                 case LDKSemanticError_NoPaymentHash:
807                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
808                 case LDKSemanticError_MultiplePaymentHashes:
809                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
810                 case LDKSemanticError_NoDescription:
811                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
812                 case LDKSemanticError_MultipleDescriptions:
813                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
814                 case LDKSemanticError_NoPaymentSecret:
815                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
816                 case LDKSemanticError_MultiplePaymentSecrets:
817                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
818                 case LDKSemanticError_InvalidFeatures:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
820                 case LDKSemanticError_InvalidRecoveryId:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
822                 case LDKSemanticError_InvalidSignature:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
824                 case LDKSemanticError_ImpreciseAmount:
825                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
826                 default: abort();
827         }
828 }
829
830 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
831         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
832         if (UNLIKELY((*env)->ExceptionCheck(env))) {
833                 (*env)->ExceptionDescribe(env);
834                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
835         }
836         switch (ord) {
837                 case 0: return LDKSiPrefix_Milli;
838                 case 1: return LDKSiPrefix_Micro;
839                 case 2: return LDKSiPrefix_Nano;
840                 case 3: return LDKSiPrefix_Pico;
841         }
842         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
843         abort(); // Unreachable, but will let the compiler know we don't return here
844 }
845 static jclass SiPrefix_class = NULL;
846 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
847 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
848 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
849 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
850 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
851         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
852         CHECK(SiPrefix_class != NULL);
853         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
854         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
855         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
856         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
857         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
858         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
859         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
860         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
861 }
862 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
863         switch (val) {
864                 case LDKSiPrefix_Milli:
865                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
866                 case LDKSiPrefix_Micro:
867                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
868                 case LDKSiPrefix_Nano:
869                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
870                 case LDKSiPrefix_Pico:
871                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
872                 default: abort();
873         }
874 }
875
876 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
877         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
878         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
879         return ret;
880 }
881 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) {
882         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
883         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
884         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
885         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
886         CVec_u8Z_free(ret_var);
887         return ret_arr;
888 }
889
890 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) {
891         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
892         int64_t ret_val = TxOut_get_value(thing_conv);
893         return ret_val;
894 }
895
896 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
897 CHECK(owner->result_ok);
898         return *owner->contents.result;
899 }
900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
901         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
902         CResult_NoneNoneZ_get_ok(owner_conv);
903 }
904
905 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
906 CHECK(!owner->result_ok);
907         return *owner->contents.err;
908 }
909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
910         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
911         CResult_NoneNoneZ_get_err(owner_conv);
912 }
913
914 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
915 CHECK(owner->result_ok);
916         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
917 }
918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
919         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
920         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
921         int64_t ret_ref = 0;
922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
925         ret_ref = (uintptr_t)ret_var.inner;
926         if (ret_var.is_owned) {
927                 ret_ref |= 1;
928         }
929         return ret_ref;
930 }
931
932 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
933 CHECK(!owner->result_ok);
934         return DecodeError_clone(&*owner->contents.err);
935 }
936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
937         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
938         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
939         int64_t ret_ref = 0;
940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
943         ret_ref = (uintptr_t)ret_var.inner;
944         if (ret_var.is_owned) {
945                 ret_ref |= 1;
946         }
947         return ret_ref;
948 }
949
950 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
951 CHECK(owner->result_ok);
952         return *owner->contents.result;
953 }
954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
955         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
956         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
958         return ret_arr;
959 }
960
961 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
962 CHECK(!owner->result_ok);
963         return *owner->contents.err;
964 }
965 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
966         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
967         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
968         return ret_conv;
969 }
970
971 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
972 CHECK(owner->result_ok);
973         return *owner->contents.result;
974 }
975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
976         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
977         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
978         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
979         return ret_arr;
980 }
981
982 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
983 CHECK(!owner->result_ok);
984         return *owner->contents.err;
985 }
986 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
987         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
988         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
989         return ret_conv;
990 }
991
992 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
993 CHECK(owner->result_ok);
994         return TxCreationKeys_clone(&*owner->contents.result);
995 }
996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
997         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
998         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
999         int64_t ret_ref = 0;
1000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1003         ret_ref = (uintptr_t)ret_var.inner;
1004         if (ret_var.is_owned) {
1005                 ret_ref |= 1;
1006         }
1007         return ret_ref;
1008 }
1009
1010 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1011 CHECK(!owner->result_ok);
1012         return DecodeError_clone(&*owner->contents.err);
1013 }
1014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1015         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1016         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1017         int64_t ret_ref = 0;
1018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1021         ret_ref = (uintptr_t)ret_var.inner;
1022         if (ret_var.is_owned) {
1023                 ret_ref |= 1;
1024         }
1025         return ret_ref;
1026 }
1027
1028 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1029 CHECK(owner->result_ok);
1030         return ChannelPublicKeys_clone(&*owner->contents.result);
1031 }
1032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1033         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1034         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1035         int64_t ret_ref = 0;
1036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1039         ret_ref = (uintptr_t)ret_var.inner;
1040         if (ret_var.is_owned) {
1041                 ret_ref |= 1;
1042         }
1043         return ret_ref;
1044 }
1045
1046 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1047 CHECK(!owner->result_ok);
1048         return DecodeError_clone(&*owner->contents.err);
1049 }
1050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1051         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1052         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1053         int64_t ret_ref = 0;
1054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1057         ret_ref = (uintptr_t)ret_var.inner;
1058         if (ret_var.is_owned) {
1059                 ret_ref |= 1;
1060         }
1061         return ret_ref;
1062 }
1063
1064 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1065 CHECK(owner->result_ok);
1066         return TxCreationKeys_clone(&*owner->contents.result);
1067 }
1068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1069         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1070         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1071         int64_t ret_ref = 0;
1072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1075         ret_ref = (uintptr_t)ret_var.inner;
1076         if (ret_var.is_owned) {
1077                 ret_ref |= 1;
1078         }
1079         return ret_ref;
1080 }
1081
1082 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1083 CHECK(!owner->result_ok);
1084         return *owner->contents.err;
1085 }
1086 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1087         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1088         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1089         return ret_conv;
1090 }
1091
1092 static jclass LDKCOption_u32Z_Some_class = NULL;
1093 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1094 static jclass LDKCOption_u32Z_None_class = NULL;
1095 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1097         LDKCOption_u32Z_Some_class =
1098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1099         CHECK(LDKCOption_u32Z_Some_class != NULL);
1100         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1101         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1102         LDKCOption_u32Z_None_class =
1103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1104         CHECK(LDKCOption_u32Z_None_class != NULL);
1105         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1106         CHECK(LDKCOption_u32Z_None_meth != NULL);
1107 }
1108 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1109         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1110         switch(obj->tag) {
1111                 case LDKCOption_u32Z_Some: {
1112                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
1113                 }
1114                 case LDKCOption_u32Z_None: {
1115                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1116                 }
1117                 default: abort();
1118         }
1119 }
1120 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1121 CHECK(owner->result_ok);
1122         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1123 }
1124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1125         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1126         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_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_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *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_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1143         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1144         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_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 LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1157 CHECK(owner->result_ok);
1158         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1159 }
1160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1161         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1162         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_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 struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1175 CHECK(!owner->result_ok);
1176         return DecodeError_clone(&*owner->contents.err);
1177 }
1178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1179         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1180         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1181         int64_t ret_ref = 0;
1182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1185         ret_ref = (uintptr_t)ret_var.inner;
1186         if (ret_var.is_owned) {
1187                 ret_ref |= 1;
1188         }
1189         return ret_ref;
1190 }
1191
1192 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1193 CHECK(owner->result_ok);
1194         return ChannelTransactionParameters_clone(&*owner->contents.result);
1195 }
1196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1197         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1198         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1199         int64_t ret_ref = 0;
1200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1203         ret_ref = (uintptr_t)ret_var.inner;
1204         if (ret_var.is_owned) {
1205                 ret_ref |= 1;
1206         }
1207         return ret_ref;
1208 }
1209
1210 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1211 CHECK(!owner->result_ok);
1212         return DecodeError_clone(&*owner->contents.err);
1213 }
1214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1215         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1216         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1217         int64_t ret_ref = 0;
1218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1221         ret_ref = (uintptr_t)ret_var.inner;
1222         if (ret_var.is_owned) {
1223                 ret_ref |= 1;
1224         }
1225         return ret_ref;
1226 }
1227
1228 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1229 CHECK(owner->result_ok);
1230         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1231 }
1232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1233         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1234         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1235         int64_t ret_ref = 0;
1236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1239         ret_ref = (uintptr_t)ret_var.inner;
1240         if (ret_var.is_owned) {
1241                 ret_ref |= 1;
1242         }
1243         return ret_ref;
1244 }
1245
1246 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1247 CHECK(!owner->result_ok);
1248         return DecodeError_clone(&*owner->contents.err);
1249 }
1250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1251         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1252         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1253         int64_t ret_ref = 0;
1254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1257         ret_ref = (uintptr_t)ret_var.inner;
1258         if (ret_var.is_owned) {
1259                 ret_ref |= 1;
1260         }
1261         return ret_ref;
1262 }
1263
1264 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1265 CHECK(owner->result_ok);
1266         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1267 }
1268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1269         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1270         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1271         int64_t ret_ref = 0;
1272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1275         ret_ref = (uintptr_t)ret_var.inner;
1276         if (ret_var.is_owned) {
1277                 ret_ref |= 1;
1278         }
1279         return ret_ref;
1280 }
1281
1282 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1283 CHECK(!owner->result_ok);
1284         return DecodeError_clone(&*owner->contents.err);
1285 }
1286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1287         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1288         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1289         int64_t ret_ref = 0;
1290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1293         ret_ref = (uintptr_t)ret_var.inner;
1294         if (ret_var.is_owned) {
1295                 ret_ref |= 1;
1296         }
1297         return ret_ref;
1298 }
1299
1300 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1301 CHECK(owner->result_ok);
1302         return &*owner->contents.result;
1303 }
1304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1305         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1306         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1307         int64_t ret_ref = 0;
1308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1311         ret_ref = (uintptr_t)ret_var.inner & ~1;
1312         return ret_ref;
1313 }
1314
1315 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1316 CHECK(!owner->result_ok);
1317         return *owner->contents.err;
1318 }
1319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1320         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1321         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1322 }
1323
1324 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1325 CHECK(owner->result_ok);
1326         return CommitmentTransaction_clone(&*owner->contents.result);
1327 }
1328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1329         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1330         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1331         int64_t ret_ref = 0;
1332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1335         ret_ref = (uintptr_t)ret_var.inner;
1336         if (ret_var.is_owned) {
1337                 ret_ref |= 1;
1338         }
1339         return ret_ref;
1340 }
1341
1342 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1343 CHECK(!owner->result_ok);
1344         return DecodeError_clone(&*owner->contents.err);
1345 }
1346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1347         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1348         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1349         int64_t ret_ref = 0;
1350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1353         ret_ref = (uintptr_t)ret_var.inner;
1354         if (ret_var.is_owned) {
1355                 ret_ref |= 1;
1356         }
1357         return ret_ref;
1358 }
1359
1360 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1361 CHECK(owner->result_ok);
1362         return &*owner->contents.result;
1363 }
1364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1365         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1366         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1367         int64_t ret_ref = 0;
1368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1371         ret_ref = (uintptr_t)ret_var.inner & ~1;
1372         return ret_ref;
1373 }
1374
1375 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1376 CHECK(!owner->result_ok);
1377         return *owner->contents.err;
1378 }
1379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1380         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1381         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1382 }
1383
1384 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1385 CHECK(owner->result_ok);
1386         return *owner->contents.result;
1387 }
1388 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1389         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1390         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1391         jobjectArray ret_arr = NULL;
1392         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1393         ;
1394         for (size_t i = 0; i < ret_var.datalen; i++) {
1395                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1396                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1397                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1398         }
1399         
1400         return ret_arr;
1401 }
1402
1403 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1404 CHECK(!owner->result_ok);
1405         return *owner->contents.err;
1406 }
1407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1408         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1409         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1410 }
1411
1412 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1413 CHECK(owner->result_ok);
1414         return ShutdownScript_clone(&*owner->contents.result);
1415 }
1416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1417         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1418         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1419         int64_t ret_ref = 0;
1420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1423         ret_ref = (uintptr_t)ret_var.inner;
1424         if (ret_var.is_owned) {
1425                 ret_ref |= 1;
1426         }
1427         return ret_ref;
1428 }
1429
1430 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1431 CHECK(!owner->result_ok);
1432         return DecodeError_clone(&*owner->contents.err);
1433 }
1434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1435         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1436         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1437         int64_t ret_ref = 0;
1438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1441         ret_ref = (uintptr_t)ret_var.inner;
1442         if (ret_var.is_owned) {
1443                 ret_ref |= 1;
1444         }
1445         return ret_ref;
1446 }
1447
1448 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1449 CHECK(owner->result_ok);
1450         return ShutdownScript_clone(&*owner->contents.result);
1451 }
1452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1453         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1454         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1455         int64_t ret_ref = 0;
1456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1459         ret_ref = (uintptr_t)ret_var.inner;
1460         if (ret_var.is_owned) {
1461                 ret_ref |= 1;
1462         }
1463         return ret_ref;
1464 }
1465
1466 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1467 CHECK(!owner->result_ok);
1468         return InvalidShutdownScript_clone(&*owner->contents.err);
1469 }
1470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1471         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1472         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1473         int64_t ret_ref = 0;
1474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1477         ret_ref = (uintptr_t)ret_var.inner;
1478         if (ret_var.is_owned) {
1479                 ret_ref |= 1;
1480         }
1481         return ret_ref;
1482 }
1483
1484 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1485 CHECK(owner->result_ok);
1486         return *owner->contents.result;
1487 }
1488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1489         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1490         CResult_NoneErrorZ_get_ok(owner_conv);
1491 }
1492
1493 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1494 CHECK(!owner->result_ok);
1495         return *owner->contents.err;
1496 }
1497 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1498         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1499         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1500         return ret_conv;
1501 }
1502
1503 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1504 CHECK(owner->result_ok);
1505         return RouteHop_clone(&*owner->contents.result);
1506 }
1507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1508         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1509         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1510         int64_t ret_ref = 0;
1511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1514         ret_ref = (uintptr_t)ret_var.inner;
1515         if (ret_var.is_owned) {
1516                 ret_ref |= 1;
1517         }
1518         return ret_ref;
1519 }
1520
1521 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1522 CHECK(!owner->result_ok);
1523         return DecodeError_clone(&*owner->contents.err);
1524 }
1525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1526         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1527         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1528         int64_t ret_ref = 0;
1529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1532         ret_ref = (uintptr_t)ret_var.inner;
1533         if (ret_var.is_owned) {
1534                 ret_ref |= 1;
1535         }
1536         return ret_ref;
1537 }
1538
1539 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1540         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1541         for (size_t i = 0; i < ret.datalen; i++) {
1542                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1543         }
1544         return ret;
1545 }
1546 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1547         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1548         for (size_t i = 0; i < ret.datalen; i++) {
1549                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1550         }
1551         return ret;
1552 }
1553 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1554 CHECK(owner->result_ok);
1555         return Route_clone(&*owner->contents.result);
1556 }
1557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1558         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1559         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1560         int64_t ret_ref = 0;
1561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1564         ret_ref = (uintptr_t)ret_var.inner;
1565         if (ret_var.is_owned) {
1566                 ret_ref |= 1;
1567         }
1568         return ret_ref;
1569 }
1570
1571 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1572 CHECK(!owner->result_ok);
1573         return DecodeError_clone(&*owner->contents.err);
1574 }
1575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1576         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1577         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1578         int64_t ret_ref = 0;
1579         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1580         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1582         ret_ref = (uintptr_t)ret_var.inner;
1583         if (ret_var.is_owned) {
1584                 ret_ref |= 1;
1585         }
1586         return ret_ref;
1587 }
1588
1589 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1590 CHECK(owner->result_ok);
1591         return RouteParameters_clone(&*owner->contents.result);
1592 }
1593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1594         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1595         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1596         int64_t ret_ref = 0;
1597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1600         ret_ref = (uintptr_t)ret_var.inner;
1601         if (ret_var.is_owned) {
1602                 ret_ref |= 1;
1603         }
1604         return ret_ref;
1605 }
1606
1607 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1608 CHECK(!owner->result_ok);
1609         return DecodeError_clone(&*owner->contents.err);
1610 }
1611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1612         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1613         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1614         int64_t ret_ref = 0;
1615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1618         ret_ref = (uintptr_t)ret_var.inner;
1619         if (ret_var.is_owned) {
1620                 ret_ref |= 1;
1621         }
1622         return ret_ref;
1623 }
1624
1625 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1626         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1627         for (size_t i = 0; i < ret.datalen; i++) {
1628                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1629         }
1630         return ret;
1631 }
1632 static jclass LDKCOption_u64Z_Some_class = NULL;
1633 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1634 static jclass LDKCOption_u64Z_None_class = NULL;
1635 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1637         LDKCOption_u64Z_Some_class =
1638                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1639         CHECK(LDKCOption_u64Z_Some_class != NULL);
1640         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1641         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1642         LDKCOption_u64Z_None_class =
1643                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1644         CHECK(LDKCOption_u64Z_None_class != NULL);
1645         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1646         CHECK(LDKCOption_u64Z_None_meth != NULL);
1647 }
1648 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1649         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1650         switch(obj->tag) {
1651                 case LDKCOption_u64Z_Some: {
1652                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1653                 }
1654                 case LDKCOption_u64Z_None: {
1655                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1656                 }
1657                 default: abort();
1658         }
1659 }
1660 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1661 CHECK(owner->result_ok);
1662         return PaymentParameters_clone(&*owner->contents.result);
1663 }
1664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1665         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1666         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1667         int64_t ret_ref = 0;
1668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1671         ret_ref = (uintptr_t)ret_var.inner;
1672         if (ret_var.is_owned) {
1673                 ret_ref |= 1;
1674         }
1675         return ret_ref;
1676 }
1677
1678 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1679 CHECK(!owner->result_ok);
1680         return DecodeError_clone(&*owner->contents.err);
1681 }
1682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1683         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1684         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1685         int64_t ret_ref = 0;
1686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1689         ret_ref = (uintptr_t)ret_var.inner;
1690         if (ret_var.is_owned) {
1691                 ret_ref |= 1;
1692         }
1693         return ret_ref;
1694 }
1695
1696 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1697         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1698         for (size_t i = 0; i < ret.datalen; i++) {
1699                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1700         }
1701         return ret;
1702 }
1703 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1704 CHECK(owner->result_ok);
1705         return RouteHint_clone(&*owner->contents.result);
1706 }
1707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1708         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1709         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1710         int64_t ret_ref = 0;
1711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1714         ret_ref = (uintptr_t)ret_var.inner;
1715         if (ret_var.is_owned) {
1716                 ret_ref |= 1;
1717         }
1718         return ret_ref;
1719 }
1720
1721 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1722 CHECK(!owner->result_ok);
1723         return DecodeError_clone(&*owner->contents.err);
1724 }
1725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1726         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1727         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1728         int64_t ret_ref = 0;
1729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1732         ret_ref = (uintptr_t)ret_var.inner;
1733         if (ret_var.is_owned) {
1734                 ret_ref |= 1;
1735         }
1736         return ret_ref;
1737 }
1738
1739 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1740 CHECK(owner->result_ok);
1741         return RouteHintHop_clone(&*owner->contents.result);
1742 }
1743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1744         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1745         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1746         int64_t ret_ref = 0;
1747         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1748         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1750         ret_ref = (uintptr_t)ret_var.inner;
1751         if (ret_var.is_owned) {
1752                 ret_ref |= 1;
1753         }
1754         return ret_ref;
1755 }
1756
1757 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1758 CHECK(!owner->result_ok);
1759         return DecodeError_clone(&*owner->contents.err);
1760 }
1761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1762         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1763         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1764         int64_t ret_ref = 0;
1765         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1766         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1768         ret_ref = (uintptr_t)ret_var.inner;
1769         if (ret_var.is_owned) {
1770                 ret_ref |= 1;
1771         }
1772         return ret_ref;
1773 }
1774
1775 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1776         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1777         for (size_t i = 0; i < ret.datalen; i++) {
1778                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1779         }
1780         return ret;
1781 }
1782 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1783 CHECK(owner->result_ok);
1784         return Route_clone(&*owner->contents.result);
1785 }
1786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1787         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1788         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1789         int64_t ret_ref = 0;
1790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1793         ret_ref = (uintptr_t)ret_var.inner;
1794         if (ret_var.is_owned) {
1795                 ret_ref |= 1;
1796         }
1797         return ret_ref;
1798 }
1799
1800 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1801 CHECK(!owner->result_ok);
1802         return LightningError_clone(&*owner->contents.err);
1803 }
1804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1805         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1806         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1807         int64_t ret_ref = 0;
1808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1811         ret_ref = (uintptr_t)ret_var.inner;
1812         if (ret_var.is_owned) {
1813                 ret_ref |= 1;
1814         }
1815         return ret_ref;
1816 }
1817
1818 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1819 CHECK(owner->result_ok);
1820         return TxOut_clone(&*owner->contents.result);
1821 }
1822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1823         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1824         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1825         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1826         return (int64_t)ret_ref;
1827 }
1828
1829 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1830 CHECK(!owner->result_ok);
1831         return AccessError_clone(&*owner->contents.err);
1832 }
1833 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1834         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1835         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
1836         return ret_conv;
1837 }
1838
1839 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1840         return owner->a;
1841 }
1842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
1843         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1844         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1845         return ret_val;
1846 }
1847
1848 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1849         return owner->b;
1850 }
1851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
1852         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1853         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1854         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1855         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1856         return ret_arr;
1857 }
1858
1859 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1860         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1861         for (size_t i = 0; i < ret.datalen; i++) {
1862                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1863         }
1864         return ret;
1865 }
1866 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1867         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1868         for (size_t i = 0; i < ret.datalen; i++) {
1869                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1870         }
1871         return ret;
1872 }
1873 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1874 CHECK(owner->result_ok);
1875         return *owner->contents.result;
1876 }
1877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1878         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1879         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1880 }
1881
1882 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1883 CHECK(!owner->result_ok);
1884         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1885 }
1886 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1887         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1888         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1889         return ret_conv;
1890 }
1891
1892 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1893 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1894 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1895 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1896 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1897 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1898 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1899 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1901         LDKMonitorEvent_HTLCEvent_class =
1902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
1903         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1904         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1905         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1906         LDKMonitorEvent_CommitmentTxConfirmed_class =
1907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
1908         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1909         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1910         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1911         LDKMonitorEvent_UpdateCompleted_class =
1912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
1913         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1914         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1915         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1916         LDKMonitorEvent_UpdateFailed_class =
1917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
1918         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
1919         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
1920         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
1921 }
1922 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1923         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1924         switch(obj->tag) {
1925                 case LDKMonitorEvent_HTLCEvent: {
1926                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1927                         int64_t htlc_event_ref = 0;
1928                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1929                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1930                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1931                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1932                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1933                 }
1934                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1935                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1936                         int64_t commitment_tx_confirmed_ref = 0;
1937                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1938                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1939                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1940                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1941                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
1942                 }
1943                 case LDKMonitorEvent_UpdateCompleted: {
1944                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1945                         int64_t funding_txo_ref = 0;
1946                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1947                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1948                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1949                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1950                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
1951                 }
1952                 case LDKMonitorEvent_UpdateFailed: {
1953                         LDKOutPoint update_failed_var = obj->update_failed;
1954                         int64_t update_failed_ref = 0;
1955                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1956                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1957                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1958                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1959                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
1960                 }
1961                 default: abort();
1962         }
1963 }
1964 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1965         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1966         for (size_t i = 0; i < ret.datalen; i++) {
1967                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1968         }
1969         return ret;
1970 }
1971 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1972 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1973 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1974 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1976         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1977                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
1978         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1979         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1980         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1981         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1982                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
1983         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1984         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1985         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1986 }
1987 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1988         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1989         switch(obj->tag) {
1990                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1991                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1992                         *some_conv = obj->some;
1993                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1994                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
1995                 }
1996                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1997                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1998                 }
1999                 default: abort();
2000         }
2001 }
2002 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2003 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2004 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2005 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2006 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2007 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2008 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2009 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2010 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2011 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2012 static jclass LDKClosureReason_ProcessingError_class = NULL;
2013 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2014 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2015 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2016 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2017 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2019         LDKClosureReason_CounterpartyForceClosed_class =
2020                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2021         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2022         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2023         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2024         LDKClosureReason_HolderForceClosed_class =
2025                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2026         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2027         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2028         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2029         LDKClosureReason_CooperativeClosure_class =
2030                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2031         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2032         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2033         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2034         LDKClosureReason_CommitmentTxConfirmed_class =
2035                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2036         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2037         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2038         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2039         LDKClosureReason_FundingTimedOut_class =
2040                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2041         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2042         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2043         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2044         LDKClosureReason_ProcessingError_class =
2045                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2046         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2047         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2048         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2049         LDKClosureReason_DisconnectedPeer_class =
2050                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2051         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2052         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2053         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2054         LDKClosureReason_OutdatedChannelManager_class =
2055                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2056         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2057         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2058         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2059 }
2060 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2061         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2062         switch(obj->tag) {
2063                 case LDKClosureReason_CounterpartyForceClosed: {
2064                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2065                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2066                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2067                 }
2068                 case LDKClosureReason_HolderForceClosed: {
2069                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2070                 }
2071                 case LDKClosureReason_CooperativeClosure: {
2072                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2073                 }
2074                 case LDKClosureReason_CommitmentTxConfirmed: {
2075                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2076                 }
2077                 case LDKClosureReason_FundingTimedOut: {
2078                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2079                 }
2080                 case LDKClosureReason_ProcessingError: {
2081                         LDKStr err_str = obj->processing_error.err;
2082                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2083                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2084                 }
2085                 case LDKClosureReason_DisconnectedPeer: {
2086                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2087                 }
2088                 case LDKClosureReason_OutdatedChannelManager: {
2089                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2090                 }
2091                 default: abort();
2092         }
2093 }
2094 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2095 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2096 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2097 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2099         LDKCOption_ClosureReasonZ_Some_class =
2100                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2101         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2102         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2103         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2104         LDKCOption_ClosureReasonZ_None_class =
2105                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2106         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2107         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2108         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2109 }
2110 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2111         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2112         switch(obj->tag) {
2113                 case LDKCOption_ClosureReasonZ_Some: {
2114                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2115                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2116                 }
2117                 case LDKCOption_ClosureReasonZ_None: {
2118                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2119                 }
2120                 default: abort();
2121         }
2122 }
2123 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2124 CHECK(owner->result_ok);
2125         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2126 }
2127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2128         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2129         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2130         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2131         int64_t ret_ref = (uintptr_t)ret_copy;
2132         return ret_ref;
2133 }
2134
2135 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2136 CHECK(!owner->result_ok);
2137         return DecodeError_clone(&*owner->contents.err);
2138 }
2139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2140         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2141         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2142         int64_t ret_ref = 0;
2143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2146         ret_ref = (uintptr_t)ret_var.inner;
2147         if (ret_var.is_owned) {
2148                 ret_ref |= 1;
2149         }
2150         return ret_ref;
2151 }
2152
2153 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2154 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2155 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
2156 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
2157 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2158 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2160         LDKNetworkUpdate_ChannelUpdateMessage_class =
2161                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2162         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2163         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2164         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2165         LDKNetworkUpdate_ChannelClosed_class =
2166                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed"));
2167         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
2168         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
2169         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
2170         LDKNetworkUpdate_NodeFailure_class =
2171                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2172         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2173         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2174         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2175 }
2176 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2177         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2178         switch(obj->tag) {
2179                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2180                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2181                         int64_t msg_ref = 0;
2182                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2183                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2184                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2185                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2186                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2187                 }
2188                 case LDKNetworkUpdate_ChannelClosed: {
2189                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
2190                 }
2191                 case LDKNetworkUpdate_NodeFailure: {
2192                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2193                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2194                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
2195                 }
2196                 default: abort();
2197         }
2198 }
2199 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2200 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2201 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2202 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2204         LDKCOption_NetworkUpdateZ_Some_class =
2205                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2206         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2207         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2208         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2209         LDKCOption_NetworkUpdateZ_None_class =
2210                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2211         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2212         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2213         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2214 }
2215 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2216         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2217         switch(obj->tag) {
2218                 case LDKCOption_NetworkUpdateZ_Some: {
2219                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2220                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2221                 }
2222                 case LDKCOption_NetworkUpdateZ_None: {
2223                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2224                 }
2225                 default: abort();
2226         }
2227 }
2228 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2229 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2230 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2231 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2232 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2233 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2235         LDKSpendableOutputDescriptor_StaticOutput_class =
2236                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2237         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2238         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2239         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2240         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2241                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2242         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2243         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2244         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2245         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2246                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2247         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2248         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2249         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2250 }
2251 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2252         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2253         switch(obj->tag) {
2254                 case LDKSpendableOutputDescriptor_StaticOutput: {
2255                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2256                         int64_t outpoint_ref = 0;
2257                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2258                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2259                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2260                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2261                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2262                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2263                 }
2264                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2265                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2266                         int64_t delayed_payment_output_ref = 0;
2267                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2268                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2269                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2270                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2271                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2272                 }
2273                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2274                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2275                         int64_t static_payment_output_ref = 0;
2276                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2277                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2278                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2279                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2280                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2281                 }
2282                 default: abort();
2283         }
2284 }
2285 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2286         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2287         for (size_t i = 0; i < ret.datalen; i++) {
2288                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2289         }
2290         return ret;
2291 }
2292 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2293 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2294 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2295 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2297         LDKPaymentPurpose_InvoicePayment_class =
2298                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2299         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2300         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2301         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2302         LDKPaymentPurpose_SpontaneousPayment_class =
2303                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2304         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2305         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2306         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2307 }
2308 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2309         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
2310         switch(obj->tag) {
2311                 case LDKPaymentPurpose_InvoicePayment: {
2312                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2313                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2314                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2315                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2316                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2317                 }
2318                 case LDKPaymentPurpose_SpontaneousPayment: {
2319                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2320                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2321                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2322                 }
2323                 default: abort();
2324         }
2325 }
2326 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2327 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2328 static jclass LDKEvent_PaymentReceived_class = NULL;
2329 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2330 static jclass LDKEvent_PaymentSent_class = NULL;
2331 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2332 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2333 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2334 static jclass LDKEvent_PaymentFailed_class = NULL;
2335 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2336 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2337 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2338 static jclass LDKEvent_SpendableOutputs_class = NULL;
2339 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2340 static jclass LDKEvent_PaymentForwarded_class = NULL;
2341 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2342 static jclass LDKEvent_ChannelClosed_class = NULL;
2343 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2344 static jclass LDKEvent_DiscardFunding_class = NULL;
2345 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2346 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2347 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2348 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2349 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2351         LDKEvent_FundingGenerationReady_class =
2352                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2353         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2354         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
2355         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2356         LDKEvent_PaymentReceived_class =
2357                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2358         CHECK(LDKEvent_PaymentReceived_class != NULL);
2359         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2360         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2361         LDKEvent_PaymentSent_class =
2362                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2363         CHECK(LDKEvent_PaymentSent_class != NULL);
2364         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2365         CHECK(LDKEvent_PaymentSent_meth != NULL);
2366         LDKEvent_PaymentPathFailed_class =
2367                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2368         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2369         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2370         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2371         LDKEvent_PaymentFailed_class =
2372                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2373         CHECK(LDKEvent_PaymentFailed_class != NULL);
2374         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2375         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2376         LDKEvent_PendingHTLCsForwardable_class =
2377                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2378         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2379         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2380         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2381         LDKEvent_SpendableOutputs_class =
2382                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2383         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2384         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2385         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2386         LDKEvent_PaymentForwarded_class =
2387                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2388         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2389         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
2390         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2391         LDKEvent_ChannelClosed_class =
2392                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2393         CHECK(LDKEvent_ChannelClosed_class != NULL);
2394         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2395         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2396         LDKEvent_DiscardFunding_class =
2397                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2398         CHECK(LDKEvent_DiscardFunding_class != NULL);
2399         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2400         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2401         LDKEvent_PaymentPathSuccessful_class =
2402                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2403         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2404         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2405         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2406         LDKEvent_OpenChannelRequest_class =
2407                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2408         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2409         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJ)V");
2410         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2411 }
2412 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2413         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2414         switch(obj->tag) {
2415                 case LDKEvent_FundingGenerationReady: {
2416                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2417                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2418                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2419                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2420                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2421                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, obj->funding_generation_ready.channel_value_satoshis, output_script_arr, obj->funding_generation_ready.user_channel_id);
2422                 }
2423                 case LDKEvent_PaymentReceived: {
2424                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2425                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2426                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2427                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
2428                 }
2429                 case LDKEvent_PaymentSent: {
2430                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2431                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2432                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2433                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2434                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2435                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2436                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2437                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2438                 }
2439                 case LDKEvent_PaymentPathFailed: {
2440                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2441                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2442                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2443                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2444                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2445                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2446                         int64_tArray path_arr = NULL;
2447                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2448                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2449                         for (size_t k = 0; k < path_var.datalen; k++) {
2450                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2451                                 int64_t path_conv_10_ref = 0;
2452                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2453                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2454                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2455                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2456                                 path_arr_ptr[k] = path_conv_10_ref;
2457                         }
2458                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2459                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2460                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2461                         int64_t retry_ref = 0;
2462                         if ((uintptr_t)retry_var.inner > 4096) {
2463                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2464                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2465                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2466                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2467                         }
2468                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr, short_channel_id_ref, retry_ref);
2469                 }
2470                 case LDKEvent_PaymentFailed: {
2471                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2472                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2473                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2474                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2475                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2476                 }
2477                 case LDKEvent_PendingHTLCsForwardable: {
2478                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
2479                 }
2480                 case LDKEvent_SpendableOutputs: {
2481                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2482                         int64_tArray outputs_arr = NULL;
2483                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2484                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2485                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2486                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2487                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2488                         }
2489                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2490                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2491                 }
2492                 case LDKEvent_PaymentForwarded: {
2493                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2494                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
2495                 }
2496                 case LDKEvent_ChannelClosed: {
2497                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2498                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2499                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2500                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
2501                 }
2502                 case LDKEvent_DiscardFunding: {
2503                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2504                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2505                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2506                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2507                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2508                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2509                 }
2510                 case LDKEvent_PaymentPathSuccessful: {
2511                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2512                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2513                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2514                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2515                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2516                         int64_tArray path_arr = NULL;
2517                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2518                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2519                         for (size_t k = 0; k < path_var.datalen; k++) {
2520                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2521                                 int64_t path_conv_10_ref = 0;
2522                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2523                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2524                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2525                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2526                                 path_arr_ptr[k] = path_conv_10_ref;
2527                         }
2528                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2529                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2530                 }
2531                 case LDKEvent_OpenChannelRequest: {
2532                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2533                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2534                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2535                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2536                         return (*env)->NewObject(env, LDKEvent_OpenChannelRequest_class, LDKEvent_OpenChannelRequest_meth, temporary_channel_id_arr, counterparty_node_id_arr, obj->open_channel_request.funding_satoshis, obj->open_channel_request.push_msat);
2537                 }
2538                 default: abort();
2539         }
2540 }
2541 static jclass LDKCOption_EventZ_Some_class = NULL;
2542 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2543 static jclass LDKCOption_EventZ_None_class = NULL;
2544 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2546         LDKCOption_EventZ_Some_class =
2547                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2548         CHECK(LDKCOption_EventZ_Some_class != NULL);
2549         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2550         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2551         LDKCOption_EventZ_None_class =
2552                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2553         CHECK(LDKCOption_EventZ_None_class != NULL);
2554         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2555         CHECK(LDKCOption_EventZ_None_meth != NULL);
2556 }
2557 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2558         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2559         switch(obj->tag) {
2560                 case LDKCOption_EventZ_Some: {
2561                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2562                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2563                 }
2564                 case LDKCOption_EventZ_None: {
2565                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2566                 }
2567                 default: abort();
2568         }
2569 }
2570 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2571 CHECK(owner->result_ok);
2572         return COption_EventZ_clone(&*owner->contents.result);
2573 }
2574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2575         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2576         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2577         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2578         int64_t ret_ref = (uintptr_t)ret_copy;
2579         return ret_ref;
2580 }
2581
2582 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2583 CHECK(!owner->result_ok);
2584         return DecodeError_clone(&*owner->contents.err);
2585 }
2586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2587         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2588         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2589         int64_t ret_ref = 0;
2590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2593         ret_ref = (uintptr_t)ret_var.inner;
2594         if (ret_var.is_owned) {
2595                 ret_ref |= 1;
2596         }
2597         return ret_ref;
2598 }
2599
2600 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2601 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2602 static jclass LDKErrorAction_IgnoreError_class = NULL;
2603 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2604 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2605 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2606 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2607 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2608 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2609 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2610 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2611 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2613         LDKErrorAction_DisconnectPeer_class =
2614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2615         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2616         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2617         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2618         LDKErrorAction_IgnoreError_class =
2619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2620         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2621         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2622         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2623         LDKErrorAction_IgnoreAndLog_class =
2624                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2625         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2626         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2627         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2628         LDKErrorAction_IgnoreDuplicateGossip_class =
2629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2630         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2631         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2632         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2633         LDKErrorAction_SendErrorMessage_class =
2634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2635         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2636         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2637         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2638         LDKErrorAction_SendWarningMessage_class =
2639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2640         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2641         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2642         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2643 }
2644 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2645         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2646         switch(obj->tag) {
2647                 case LDKErrorAction_DisconnectPeer: {
2648                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2649                         int64_t msg_ref = 0;
2650                         if ((uintptr_t)msg_var.inner > 4096) {
2651                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2652                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2653                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2654                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2655                         }
2656                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2657                 }
2658                 case LDKErrorAction_IgnoreError: {
2659                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2660                 }
2661                 case LDKErrorAction_IgnoreAndLog: {
2662                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2663                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2664                 }
2665                 case LDKErrorAction_IgnoreDuplicateGossip: {
2666                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2667                 }
2668                 case LDKErrorAction_SendErrorMessage: {
2669                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2670                         int64_t msg_ref = 0;
2671                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2672                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2673                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2674                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2675                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2676                 }
2677                 case LDKErrorAction_SendWarningMessage: {
2678                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2679                         int64_t msg_ref = 0;
2680                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2681                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2682                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2683                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2684                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2685                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2686                 }
2687                 default: abort();
2688         }
2689 }
2690 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2691 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2692 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2693 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2694 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2695 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2696 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2697 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2698 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2699 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2700 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2701 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2702 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2703 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2704 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2705 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2706 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2707 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2708 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2709 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2710 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2711 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2712 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2713 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2714 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2715 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2716 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2717 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2718 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2719 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2720 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2721 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2722 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2723 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2724 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2725 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2726 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2727 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2729         LDKMessageSendEvent_SendAcceptChannel_class =
2730                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2731         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2732         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2733         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2734         LDKMessageSendEvent_SendOpenChannel_class =
2735                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2736         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2737         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2738         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2739         LDKMessageSendEvent_SendFundingCreated_class =
2740                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2741         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2742         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2743         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2744         LDKMessageSendEvent_SendFundingSigned_class =
2745                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2746         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2747         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2748         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2749         LDKMessageSendEvent_SendFundingLocked_class =
2750                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked"));
2751         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2752         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2753         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2754         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2755                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2756         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2757         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2758         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2759         LDKMessageSendEvent_UpdateHTLCs_class =
2760                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2761         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2762         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2763         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2764         LDKMessageSendEvent_SendRevokeAndACK_class =
2765                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2766         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2767         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2768         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2769         LDKMessageSendEvent_SendClosingSigned_class =
2770                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2771         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2772         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2773         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2774         LDKMessageSendEvent_SendShutdown_class =
2775                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2776         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2777         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2778         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2779         LDKMessageSendEvent_SendChannelReestablish_class =
2780                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2781         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2782         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2783         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2784         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2785                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2786         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2787         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2788         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2789         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2790                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2791         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2792         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2793         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2794         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2795                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2796         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2797         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2798         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2799         LDKMessageSendEvent_SendChannelUpdate_class =
2800                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2801         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2802         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2803         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2804         LDKMessageSendEvent_HandleError_class =
2805                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2806         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2807         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2808         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2809         LDKMessageSendEvent_SendChannelRangeQuery_class =
2810                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2811         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2812         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2813         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2814         LDKMessageSendEvent_SendShortIdsQuery_class =
2815                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2816         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2817         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2818         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2819         LDKMessageSendEvent_SendReplyChannelRange_class =
2820                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2821         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2822         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2823         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2824 }
2825 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2826         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2827         switch(obj->tag) {
2828                 case LDKMessageSendEvent_SendAcceptChannel: {
2829                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2830                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2831                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2832                         int64_t msg_ref = 0;
2833                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2834                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2835                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2836                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2837                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2838                 }
2839                 case LDKMessageSendEvent_SendOpenChannel: {
2840                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2841                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2842                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2843                         int64_t msg_ref = 0;
2844                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2845                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2846                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2847                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2848                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2849                 }
2850                 case LDKMessageSendEvent_SendFundingCreated: {
2851                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2852                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2853                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2854                         int64_t msg_ref = 0;
2855                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2856                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2857                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2858                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2859                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2860                 }
2861                 case LDKMessageSendEvent_SendFundingSigned: {
2862                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2863                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2864                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2865                         int64_t msg_ref = 0;
2866                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2867                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2868                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2869                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2870                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2871                 }
2872                 case LDKMessageSendEvent_SendFundingLocked: {
2873                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2874                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2875                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2876                         int64_t msg_ref = 0;
2877                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2878                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2879                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2880                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2881                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2882                 }
2883                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2884                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2885                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2886                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2887                         int64_t msg_ref = 0;
2888                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2889                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2890                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2891                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2892                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2893                 }
2894                 case LDKMessageSendEvent_UpdateHTLCs: {
2895                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2896                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2897                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2898                         int64_t updates_ref = 0;
2899                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2900                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2901                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2902                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2903                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2904                 }
2905                 case LDKMessageSendEvent_SendRevokeAndACK: {
2906                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2907                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2908                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2909                         int64_t msg_ref = 0;
2910                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2911                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2912                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2913                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2914                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2915                 }
2916                 case LDKMessageSendEvent_SendClosingSigned: {
2917                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2918                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2919                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2920                         int64_t msg_ref = 0;
2921                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2922                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2923                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2924                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2925                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2926                 }
2927                 case LDKMessageSendEvent_SendShutdown: {
2928                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2929                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2930                         LDKShutdown msg_var = obj->send_shutdown.msg;
2931                         int64_t msg_ref = 0;
2932                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2933                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2934                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2935                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2936                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2937                 }
2938                 case LDKMessageSendEvent_SendChannelReestablish: {
2939                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2940                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2941                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2942                         int64_t msg_ref = 0;
2943                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2944                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2945                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2946                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2947                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2948                 }
2949                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2950                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2951                         int64_t msg_ref = 0;
2952                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2953                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2954                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2955                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2956                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2957                         int64_t update_msg_ref = 0;
2958                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2959                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2960                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2961                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2962                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2963                 }
2964                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2965                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2966                         int64_t msg_ref = 0;
2967                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2968                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2969                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2970                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2971                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2972                 }
2973                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2974                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2975                         int64_t msg_ref = 0;
2976                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2977                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2978                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2979                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2980                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2981                 }
2982                 case LDKMessageSendEvent_SendChannelUpdate: {
2983                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2984                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2985                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2986                         int64_t msg_ref = 0;
2987                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2988                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2989                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2990                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2991                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2992                 }
2993                 case LDKMessageSendEvent_HandleError: {
2994                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2995                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2996                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2997                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2998                 }
2999                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3000                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3001                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3002                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3003                         int64_t msg_ref = 0;
3004                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3005                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3006                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3007                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3008                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3009                 }
3010                 case LDKMessageSendEvent_SendShortIdsQuery: {
3011                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3012                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3013                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3014                         int64_t msg_ref = 0;
3015                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3016                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3017                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3018                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3019                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3020                 }
3021                 case LDKMessageSendEvent_SendReplyChannelRange: {
3022                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3023                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3024                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3025                         int64_t msg_ref = 0;
3026                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3027                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3028                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3029                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3030                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3031                 }
3032                 default: abort();
3033         }
3034 }
3035 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3036         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3037         for (size_t i = 0; i < ret.datalen; i++) {
3038                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3039         }
3040         return ret;
3041 }
3042 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3043 CHECK(owner->result_ok);
3044         return FixedPenaltyScorer_clone(&*owner->contents.result);
3045 }
3046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3047         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3048         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3049         int64_t ret_ref = 0;
3050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3053         ret_ref = (uintptr_t)ret_var.inner;
3054         if (ret_var.is_owned) {
3055                 ret_ref |= 1;
3056         }
3057         return ret_ref;
3058 }
3059
3060 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3061 CHECK(!owner->result_ok);
3062         return DecodeError_clone(&*owner->contents.err);
3063 }
3064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3065         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3066         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3067         int64_t ret_ref = 0;
3068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3071         ret_ref = (uintptr_t)ret_var.inner;
3072         if (ret_var.is_owned) {
3073                 ret_ref |= 1;
3074         }
3075         return ret_ref;
3076 }
3077
3078 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3079 CHECK(owner->result_ok);
3080         return ScoringParameters_clone(&*owner->contents.result);
3081 }
3082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3083         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3084         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
3085         int64_t ret_ref = 0;
3086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3089         ret_ref = (uintptr_t)ret_var.inner;
3090         if (ret_var.is_owned) {
3091                 ret_ref |= 1;
3092         }
3093         return ret_ref;
3094 }
3095
3096 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3097 CHECK(!owner->result_ok);
3098         return DecodeError_clone(&*owner->contents.err);
3099 }
3100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3101         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3102         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
3103         int64_t ret_ref = 0;
3104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3107         ret_ref = (uintptr_t)ret_var.inner;
3108         if (ret_var.is_owned) {
3109                 ret_ref |= 1;
3110         }
3111         return ret_ref;
3112 }
3113
3114 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3115 CHECK(owner->result_ok);
3116         return &*owner->contents.result;
3117 }
3118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3119         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3120         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
3121         int64_t ret_ref = 0;
3122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3125         ret_ref = (uintptr_t)ret_var.inner & ~1;
3126         return ret_ref;
3127 }
3128
3129 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3130 CHECK(!owner->result_ok);
3131         return DecodeError_clone(&*owner->contents.err);
3132 }
3133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3134         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3135         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
3136         int64_t ret_ref = 0;
3137         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3138         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3140         ret_ref = (uintptr_t)ret_var.inner;
3141         if (ret_var.is_owned) {
3142                 ret_ref |= 1;
3143         }
3144         return ret_ref;
3145 }
3146
3147 static inline struct LDKProbabilisticScoringParameters CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3148 CHECK(owner->result_ok);
3149         return ProbabilisticScoringParameters_clone(&*owner->contents.result);
3150 }
3151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3152         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
3153         LDKProbabilisticScoringParameters ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(owner_conv);
3154         int64_t ret_ref = 0;
3155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3158         ret_ref = (uintptr_t)ret_var.inner;
3159         if (ret_var.is_owned) {
3160                 ret_ref |= 1;
3161         }
3162         return ret_ref;
3163 }
3164
3165 static inline struct LDKDecodeError CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3166 CHECK(!owner->result_ok);
3167         return DecodeError_clone(&*owner->contents.err);
3168 }
3169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3170         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
3171         LDKDecodeError ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(owner_conv);
3172         int64_t ret_ref = 0;
3173         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3174         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3176         ret_ref = (uintptr_t)ret_var.inner;
3177         if (ret_var.is_owned) {
3178                 ret_ref |= 1;
3179         }
3180         return ret_ref;
3181 }
3182
3183 static inline struct LDKProbabilisticScoringParameters C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR owner){
3184         return ProbabilisticScoringParameters_clone(&owner->a);
3185 }
3186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1ProbabilisticScoringParametersNetworkGraphZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3187         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* owner_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(owner & ~1);
3188         LDKProbabilisticScoringParameters ret_var = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_a(owner_conv);
3189         int64_t ret_ref = 0;
3190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3193         ret_ref = (uintptr_t)ret_var.inner;
3194         if (ret_var.is_owned) {
3195                 ret_ref |= 1;
3196         }
3197         return ret_ref;
3198 }
3199
3200 static inline struct LDKNetworkGraph C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR owner){
3201         return NetworkGraph_clone(&owner->b);
3202 }
3203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1ProbabilisticScoringParametersNetworkGraphZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3204         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* owner_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(owner & ~1);
3205         LDKNetworkGraph ret_var = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_get_b(owner_conv);
3206         int64_t ret_ref = 0;
3207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3210         ret_ref = (uintptr_t)ret_var.inner;
3211         if (ret_var.is_owned) {
3212                 ret_ref |= 1;
3213         }
3214         return ret_ref;
3215 }
3216
3217 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3218 CHECK(owner->result_ok);
3219         return &*owner->contents.result;
3220 }
3221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3222         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3223         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3224         int64_t ret_ref = 0;
3225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3228         ret_ref = (uintptr_t)ret_var.inner & ~1;
3229         return ret_ref;
3230 }
3231
3232 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3233 CHECK(!owner->result_ok);
3234         return DecodeError_clone(&*owner->contents.err);
3235 }
3236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3237         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3238         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3239         int64_t ret_ref = 0;
3240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3243         ret_ref = (uintptr_t)ret_var.inner;
3244         if (ret_var.is_owned) {
3245                 ret_ref |= 1;
3246         }
3247         return ret_ref;
3248 }
3249
3250 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3251 CHECK(owner->result_ok);
3252         return InitFeatures_clone(&*owner->contents.result);
3253 }
3254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3255         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3256         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3257         int64_t ret_ref = 0;
3258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3261         ret_ref = (uintptr_t)ret_var.inner;
3262         if (ret_var.is_owned) {
3263                 ret_ref |= 1;
3264         }
3265         return ret_ref;
3266 }
3267
3268 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3269 CHECK(!owner->result_ok);
3270         return DecodeError_clone(&*owner->contents.err);
3271 }
3272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3273         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3274         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3275         int64_t ret_ref = 0;
3276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3279         ret_ref = (uintptr_t)ret_var.inner;
3280         if (ret_var.is_owned) {
3281                 ret_ref |= 1;
3282         }
3283         return ret_ref;
3284 }
3285
3286 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3287 CHECK(owner->result_ok);
3288         return ChannelFeatures_clone(&*owner->contents.result);
3289 }
3290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3291         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3292         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3293         int64_t ret_ref = 0;
3294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3297         ret_ref = (uintptr_t)ret_var.inner;
3298         if (ret_var.is_owned) {
3299                 ret_ref |= 1;
3300         }
3301         return ret_ref;
3302 }
3303
3304 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3305 CHECK(!owner->result_ok);
3306         return DecodeError_clone(&*owner->contents.err);
3307 }
3308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3309         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3310         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3311         int64_t ret_ref = 0;
3312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3315         ret_ref = (uintptr_t)ret_var.inner;
3316         if (ret_var.is_owned) {
3317                 ret_ref |= 1;
3318         }
3319         return ret_ref;
3320 }
3321
3322 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3323 CHECK(owner->result_ok);
3324         return NodeFeatures_clone(&*owner->contents.result);
3325 }
3326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3327         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3328         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3329         int64_t ret_ref = 0;
3330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3333         ret_ref = (uintptr_t)ret_var.inner;
3334         if (ret_var.is_owned) {
3335                 ret_ref |= 1;
3336         }
3337         return ret_ref;
3338 }
3339
3340 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3341 CHECK(!owner->result_ok);
3342         return DecodeError_clone(&*owner->contents.err);
3343 }
3344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3345         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3346         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3347         int64_t ret_ref = 0;
3348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3351         ret_ref = (uintptr_t)ret_var.inner;
3352         if (ret_var.is_owned) {
3353                 ret_ref |= 1;
3354         }
3355         return ret_ref;
3356 }
3357
3358 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3359 CHECK(owner->result_ok);
3360         return InvoiceFeatures_clone(&*owner->contents.result);
3361 }
3362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3363         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3364         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3365         int64_t ret_ref = 0;
3366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3369         ret_ref = (uintptr_t)ret_var.inner;
3370         if (ret_var.is_owned) {
3371                 ret_ref |= 1;
3372         }
3373         return ret_ref;
3374 }
3375
3376 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3377 CHECK(!owner->result_ok);
3378         return DecodeError_clone(&*owner->contents.err);
3379 }
3380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3381         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3382         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3383         int64_t ret_ref = 0;
3384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3387         ret_ref = (uintptr_t)ret_var.inner;
3388         if (ret_var.is_owned) {
3389                 ret_ref |= 1;
3390         }
3391         return ret_ref;
3392 }
3393
3394 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3395 CHECK(owner->result_ok);
3396         return ChannelTypeFeatures_clone(&*owner->contents.result);
3397 }
3398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3399         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3400         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3401         int64_t ret_ref = 0;
3402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3405         ret_ref = (uintptr_t)ret_var.inner;
3406         if (ret_var.is_owned) {
3407                 ret_ref |= 1;
3408         }
3409         return ret_ref;
3410 }
3411
3412 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3413 CHECK(!owner->result_ok);
3414         return DecodeError_clone(&*owner->contents.err);
3415 }
3416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3417         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3418         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3419         int64_t ret_ref = 0;
3420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3423         ret_ref = (uintptr_t)ret_var.inner;
3424         if (ret_var.is_owned) {
3425                 ret_ref |= 1;
3426         }
3427         return ret_ref;
3428 }
3429
3430 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3431 CHECK(owner->result_ok);
3432         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3433 }
3434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3435         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3436         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3437         int64_t ret_ref = 0;
3438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3441         ret_ref = (uintptr_t)ret_var.inner;
3442         if (ret_var.is_owned) {
3443                 ret_ref |= 1;
3444         }
3445         return ret_ref;
3446 }
3447
3448 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3449 CHECK(!owner->result_ok);
3450         return DecodeError_clone(&*owner->contents.err);
3451 }
3452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3453         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3454         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3455         int64_t ret_ref = 0;
3456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3459         ret_ref = (uintptr_t)ret_var.inner;
3460         if (ret_var.is_owned) {
3461                 ret_ref |= 1;
3462         }
3463         return ret_ref;
3464 }
3465
3466 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3467 CHECK(owner->result_ok);
3468         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3469 }
3470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3471         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3472         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3473         int64_t ret_ref = 0;
3474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3477         ret_ref = (uintptr_t)ret_var.inner;
3478         if (ret_var.is_owned) {
3479                 ret_ref |= 1;
3480         }
3481         return ret_ref;
3482 }
3483
3484 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3485 CHECK(!owner->result_ok);
3486         return DecodeError_clone(&*owner->contents.err);
3487 }
3488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3489         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3490         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3491         int64_t ret_ref = 0;
3492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3495         ret_ref = (uintptr_t)ret_var.inner;
3496         if (ret_var.is_owned) {
3497                 ret_ref |= 1;
3498         }
3499         return ret_ref;
3500 }
3501
3502 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3503 CHECK(owner->result_ok);
3504         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3505 }
3506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3507         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3508         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3509         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3510         int64_t ret_ref = (uintptr_t)ret_copy;
3511         return ret_ref;
3512 }
3513
3514 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3515 CHECK(!owner->result_ok);
3516         return DecodeError_clone(&*owner->contents.err);
3517 }
3518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3519         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3520         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3521         int64_t ret_ref = 0;
3522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3525         ret_ref = (uintptr_t)ret_var.inner;
3526         if (ret_var.is_owned) {
3527                 ret_ref |= 1;
3528         }
3529         return ret_ref;
3530 }
3531
3532 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3533         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3534         for (size_t i = 0; i < ret.datalen; i++) {
3535                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3536         }
3537         return ret;
3538 }
3539 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3540         return owner->a;
3541 }
3542 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3543         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3544         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3545         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
3546         return ret_arr;
3547 }
3548
3549 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3550         return owner->b;
3551 }
3552 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3553         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3554         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3555         jobjectArray ret_arr = NULL;
3556         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
3557         ;
3558         for (size_t i = 0; i < ret_var.datalen; i++) {
3559                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
3560                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
3561                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
3562         }
3563         
3564         return ret_arr;
3565 }
3566
3567 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3568 CHECK(owner->result_ok);
3569         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3570 }
3571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3572         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3573         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3574         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3575         return ((int64_t)ret_conv);
3576 }
3577
3578 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3579 CHECK(!owner->result_ok);
3580         return *owner->contents.err;
3581 }
3582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3583         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3584         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3585 }
3586
3587 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3588 CHECK(owner->result_ok);
3589         return *owner->contents.result;
3590 }
3591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3592         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3593         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
3595         return ret_arr;
3596 }
3597
3598 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3599 CHECK(!owner->result_ok);
3600         return *owner->contents.err;
3601 }
3602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3603         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3604         CResult_SignatureNoneZ_get_err(owner_conv);
3605 }
3606
3607 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3608         return owner->a;
3609 }
3610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3611         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3612         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3613         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
3614         return ret_arr;
3615 }
3616
3617 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3618         return owner->b;
3619 }
3620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3621         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3622         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3623         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
3624         return ret_arr;
3625 }
3626
3627 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3628 CHECK(owner->result_ok);
3629         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3630 }
3631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3632         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3633         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3634         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3635         return ((int64_t)ret_conv);
3636 }
3637
3638 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3639 CHECK(!owner->result_ok);
3640         return *owner->contents.err;
3641 }
3642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3643         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3644         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3645 }
3646
3647 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3648 CHECK(owner->result_ok);
3649         return *owner->contents.result;
3650 }
3651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3652         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3653         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3654         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
3655         return ret_arr;
3656 }
3657
3658 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3659 CHECK(!owner->result_ok);
3660         return *owner->contents.err;
3661 }
3662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3663         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3664         CResult_SecretKeyNoneZ_get_err(owner_conv);
3665 }
3666
3667 typedef struct LDKBaseSign_JCalls {
3668         atomic_size_t refcnt;
3669         JavaVM *vm;
3670         jweak o;
3671         jmethodID get_per_commitment_point_meth;
3672         jmethodID release_commitment_secret_meth;
3673         jmethodID validate_holder_commitment_meth;
3674         jmethodID channel_keys_id_meth;
3675         jmethodID sign_counterparty_commitment_meth;
3676         jmethodID validate_counterparty_revocation_meth;
3677         jmethodID sign_holder_commitment_and_htlcs_meth;
3678         jmethodID sign_justice_revoked_output_meth;
3679         jmethodID sign_justice_revoked_htlc_meth;
3680         jmethodID sign_counterparty_htlc_transaction_meth;
3681         jmethodID sign_closing_transaction_meth;
3682         jmethodID sign_channel_announcement_meth;
3683         jmethodID ready_channel_meth;
3684 } LDKBaseSign_JCalls;
3685 static void LDKBaseSign_JCalls_free(void* this_arg) {
3686         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3687         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3688                 JNIEnv *env;
3689                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3690                 if (get_jenv_res == JNI_EDETACHED) {
3691                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3692                 } else {
3693                         DO_ASSERT(get_jenv_res == JNI_OK);
3694                 }
3695                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3696                 if (get_jenv_res == JNI_EDETACHED) {
3697                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3698                 }
3699                 FREE(j_calls);
3700         }
3701 }
3702 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3703         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3704         JNIEnv *env;
3705         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3706         if (get_jenv_res == JNI_EDETACHED) {
3707                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3708         } else {
3709                 DO_ASSERT(get_jenv_res == JNI_OK);
3710         }
3711         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3712         CHECK(obj != NULL);
3713         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
3714         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3715                 (*env)->ExceptionDescribe(env);
3716                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
3717         }
3718         LDKPublicKey ret_ref;
3719         CHECK((*env)->GetArrayLength(env, ret) == 33);
3720         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3721         if (get_jenv_res == JNI_EDETACHED) {
3722                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3723         }
3724         return ret_ref;
3725 }
3726 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3727         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3728         JNIEnv *env;
3729         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3730         if (get_jenv_res == JNI_EDETACHED) {
3731                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3732         } else {
3733                 DO_ASSERT(get_jenv_res == JNI_OK);
3734         }
3735         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3736         CHECK(obj != NULL);
3737         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
3738         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3739                 (*env)->ExceptionDescribe(env);
3740                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
3741         }
3742         LDKThirtyTwoBytes ret_ref;
3743         CHECK((*env)->GetArrayLength(env, ret) == 32);
3744         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3745         if (get_jenv_res == JNI_EDETACHED) {
3746                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3747         }
3748         return ret_ref;
3749 }
3750 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3751         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3752         JNIEnv *env;
3753         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3754         if (get_jenv_res == JNI_EDETACHED) {
3755                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3756         } else {
3757                 DO_ASSERT(get_jenv_res == JNI_OK);
3758         }
3759         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3760         int64_t holder_tx_ref = 0;
3761         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3762         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3763         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3764         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3765         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3766         if (holder_tx_var.is_owned) {
3767                 holder_tx_ref |= 1;
3768         }
3769         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3770         jobjectArray preimages_arr = NULL;
3771         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3772         ;
3773         for (size_t i = 0; i < preimages_var.datalen; i++) {
3774                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3775                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3776                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3777         }
3778         
3779         FREE(preimages_var.data);
3780         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3781         CHECK(obj != NULL);
3782         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
3783         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3784                 (*env)->ExceptionDescribe(env);
3785                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
3786         }
3787         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3788         CHECK_ACCESS(ret_ptr);
3789         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3790         FREE((void*)ret);
3791         if (get_jenv_res == JNI_EDETACHED) {
3792                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3793         }
3794         return ret_conv;
3795 }
3796 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3797         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3798         JNIEnv *env;
3799         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3800         if (get_jenv_res == JNI_EDETACHED) {
3801                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3802         } else {
3803                 DO_ASSERT(get_jenv_res == JNI_OK);
3804         }
3805         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3806         CHECK(obj != NULL);
3807         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
3808         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3809                 (*env)->ExceptionDescribe(env);
3810                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
3811         }
3812         LDKThirtyTwoBytes ret_ref;
3813         CHECK((*env)->GetArrayLength(env, ret) == 32);
3814         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3815         if (get_jenv_res == JNI_EDETACHED) {
3816                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3817         }
3818         return ret_ref;
3819 }
3820 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3821         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3822         JNIEnv *env;
3823         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3824         if (get_jenv_res == JNI_EDETACHED) {
3825                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3826         } else {
3827                 DO_ASSERT(get_jenv_res == JNI_OK);
3828         }
3829         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3830         int64_t commitment_tx_ref = 0;
3831         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3832         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3833         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3834         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3835         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3836         if (commitment_tx_var.is_owned) {
3837                 commitment_tx_ref |= 1;
3838         }
3839         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3840         jobjectArray preimages_arr = NULL;
3841         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3842         ;
3843         for (size_t i = 0; i < preimages_var.datalen; i++) {
3844                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3845                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3846                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3847         }
3848         
3849         FREE(preimages_var.data);
3850         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3851         CHECK(obj != NULL);
3852         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
3853         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3854                 (*env)->ExceptionDescribe(env);
3855                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
3856         }
3857         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3858         CHECK_ACCESS(ret_ptr);
3859         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3860         FREE((void*)ret);
3861         if (get_jenv_res == JNI_EDETACHED) {
3862                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3863         }
3864         return ret_conv;
3865 }
3866 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3867         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3868         JNIEnv *env;
3869         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3870         if (get_jenv_res == JNI_EDETACHED) {
3871                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3872         } else {
3873                 DO_ASSERT(get_jenv_res == JNI_OK);
3874         }
3875         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
3876         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
3877         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3878         CHECK(obj != NULL);
3879         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
3880         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3881                 (*env)->ExceptionDescribe(env);
3882                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
3883         }
3884         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3885         CHECK_ACCESS(ret_ptr);
3886         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3887         FREE((void*)ret);
3888         if (get_jenv_res == JNI_EDETACHED) {
3889                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3890         }
3891         return ret_conv;
3892 }
3893 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3894         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3895         JNIEnv *env;
3896         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3897         if (get_jenv_res == JNI_EDETACHED) {
3898                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3899         } else {
3900                 DO_ASSERT(get_jenv_res == JNI_OK);
3901         }
3902         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3903         int64_t commitment_tx_ref = 0;
3904         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3905         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3906         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3907         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3908         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3909         if (commitment_tx_var.is_owned) {
3910                 commitment_tx_ref |= 1;
3911         }
3912         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3913         CHECK(obj != NULL);
3914         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
3915         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3916                 (*env)->ExceptionDescribe(env);
3917                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
3918         }
3919         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3920         CHECK_ACCESS(ret_ptr);
3921         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3922         FREE((void*)ret);
3923         if (get_jenv_res == JNI_EDETACHED) {
3924                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3925         }
3926         return ret_conv;
3927 }
3928 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]) {
3929         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3930         JNIEnv *env;
3931         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3932         if (get_jenv_res == JNI_EDETACHED) {
3933                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3934         } else {
3935                 DO_ASSERT(get_jenv_res == JNI_OK);
3936         }
3937         LDKTransaction justice_tx_var = justice_tx;
3938         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3939         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3940         Transaction_free(justice_tx_var);
3941         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3942         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3943         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3944         CHECK(obj != NULL);
3945         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
3946         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3947                 (*env)->ExceptionDescribe(env);
3948                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
3949         }
3950         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3951         CHECK_ACCESS(ret_ptr);
3952         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3953         FREE((void*)ret);
3954         if (get_jenv_res == JNI_EDETACHED) {
3955                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3956         }
3957         return ret_conv;
3958 }
3959 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) {
3960         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3961         JNIEnv *env;
3962         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3963         if (get_jenv_res == JNI_EDETACHED) {
3964                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3965         } else {
3966                 DO_ASSERT(get_jenv_res == JNI_OK);
3967         }
3968         LDKTransaction justice_tx_var = justice_tx;
3969         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3970         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3971         Transaction_free(justice_tx_var);
3972         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3973         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3974         LDKHTLCOutputInCommitment htlc_var = *htlc;
3975         int64_t htlc_ref = 0;
3976         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3977         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3978         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3979         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3980         htlc_ref = (uintptr_t)htlc_var.inner;
3981         if (htlc_var.is_owned) {
3982                 htlc_ref |= 1;
3983         }
3984         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3985         CHECK(obj != NULL);
3986         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
3987         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3988                 (*env)->ExceptionDescribe(env);
3989                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
3990         }
3991         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3992         CHECK_ACCESS(ret_ptr);
3993         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3994         FREE((void*)ret);
3995         if (get_jenv_res == JNI_EDETACHED) {
3996                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3997         }
3998         return ret_conv;
3999 }
4000 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) {
4001         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4002         JNIEnv *env;
4003         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4004         if (get_jenv_res == JNI_EDETACHED) {
4005                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4006         } else {
4007                 DO_ASSERT(get_jenv_res == JNI_OK);
4008         }
4009         LDKTransaction htlc_tx_var = htlc_tx;
4010         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
4011         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
4012         Transaction_free(htlc_tx_var);
4013         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
4014         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
4015         LDKHTLCOutputInCommitment htlc_var = *htlc;
4016         int64_t htlc_ref = 0;
4017         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4018         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4019         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4020         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4021         htlc_ref = (uintptr_t)htlc_var.inner;
4022         if (htlc_var.is_owned) {
4023                 htlc_ref |= 1;
4024         }
4025         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4026         CHECK(obj != NULL);
4027         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
4028         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4029                 (*env)->ExceptionDescribe(env);
4030                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
4031         }
4032         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4033         CHECK_ACCESS(ret_ptr);
4034         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4035         FREE((void*)ret);
4036         if (get_jenv_res == JNI_EDETACHED) {
4037                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4038         }
4039         return ret_conv;
4040 }
4041 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4042         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4043         JNIEnv *env;
4044         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4045         if (get_jenv_res == JNI_EDETACHED) {
4046                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4047         } else {
4048                 DO_ASSERT(get_jenv_res == JNI_OK);
4049         }
4050         LDKClosingTransaction closing_tx_var = *closing_tx;
4051         int64_t closing_tx_ref = 0;
4052         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4053         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4054         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4055         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4056         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4057         if (closing_tx_var.is_owned) {
4058                 closing_tx_ref |= 1;
4059         }
4060         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4061         CHECK(obj != NULL);
4062         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
4063         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4064                 (*env)->ExceptionDescribe(env);
4065                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
4066         }
4067         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4068         CHECK_ACCESS(ret_ptr);
4069         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4070         FREE((void*)ret);
4071         if (get_jenv_res == JNI_EDETACHED) {
4072                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4073         }
4074         return ret_conv;
4075 }
4076 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4077         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4078         JNIEnv *env;
4079         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4080         if (get_jenv_res == JNI_EDETACHED) {
4081                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4082         } else {
4083                 DO_ASSERT(get_jenv_res == JNI_OK);
4084         }
4085         LDKUnsignedChannelAnnouncement msg_var = *msg;
4086         int64_t msg_ref = 0;
4087         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4088         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4089         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4090         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4091         msg_ref = (uintptr_t)msg_var.inner;
4092         if (msg_var.is_owned) {
4093                 msg_ref |= 1;
4094         }
4095         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4096         CHECK(obj != NULL);
4097         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
4098         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4099                 (*env)->ExceptionDescribe(env);
4100                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
4101         }
4102         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4103         CHECK_ACCESS(ret_ptr);
4104         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4105         FREE((void*)ret);
4106         if (get_jenv_res == JNI_EDETACHED) {
4107                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4108         }
4109         return ret_conv;
4110 }
4111 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4112         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4113         JNIEnv *env;
4114         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4115         if (get_jenv_res == JNI_EDETACHED) {
4116                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4117         } else {
4118                 DO_ASSERT(get_jenv_res == JNI_OK);
4119         }
4120         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4121         int64_t channel_parameters_ref = 0;
4122         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4123         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4124         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4125         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4126         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4127         if (channel_parameters_var.is_owned) {
4128                 channel_parameters_ref |= 1;
4129         }
4130         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4131         CHECK(obj != NULL);
4132         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
4133         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4134                 (*env)->ExceptionDescribe(env);
4135                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
4136         }
4137         if (get_jenv_res == JNI_EDETACHED) {
4138                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4139         }
4140 }
4141 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4142         jclass c = (*env)->GetObjectClass(env, o);
4143         CHECK(c != NULL);
4144         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4145         atomic_init(&calls->refcnt, 1);
4146         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4147         calls->o = (*env)->NewWeakGlobalRef(env, o);
4148         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
4149         CHECK(calls->get_per_commitment_point_meth != NULL);
4150         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
4151         CHECK(calls->release_commitment_secret_meth != NULL);
4152         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
4153         CHECK(calls->validate_holder_commitment_meth != NULL);
4154         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
4155         CHECK(calls->channel_keys_id_meth != NULL);
4156         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
4157         CHECK(calls->sign_counterparty_commitment_meth != NULL);
4158         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
4159         CHECK(calls->validate_counterparty_revocation_meth != NULL);
4160         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
4161         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
4162         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
4163         CHECK(calls->sign_justice_revoked_output_meth != NULL);
4164         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
4165         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
4166         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
4167         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
4168         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
4169         CHECK(calls->sign_closing_transaction_meth != NULL);
4170         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
4171         CHECK(calls->sign_channel_announcement_meth != NULL);
4172         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
4173         CHECK(calls->ready_channel_meth != NULL);
4174
4175         LDKChannelPublicKeys pubkeys_conv;
4176         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4177         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4178         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4179
4180         LDKBaseSign ret = {
4181                 .this_arg = (void*) calls,
4182                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4183                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4184                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4185                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4186                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4187                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4188                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4189                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4190                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4191                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4192                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4193                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4194                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4195                 .free = LDKBaseSign_JCalls_free,
4196                 .pubkeys = pubkeys_conv,
4197                 .set_pubkeys = NULL,
4198         };
4199         return ret;
4200 }
4201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4202         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4203         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
4204         return (uint64_t)res_ptr;
4205 }
4206 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) {
4207         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4208         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4209         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4210         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4211         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
4212         return ret_arr;
4213 }
4214
4215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
4216         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4217         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4218         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4219         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
4221         return ret_arr;
4222 }
4223
4224 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) {
4225         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4226         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4227         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4228         LDKHolderCommitmentTransaction holder_tx_conv;
4229         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4230         holder_tx_conv.is_owned = false;
4231         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4232         LDKCVec_PaymentPreimageZ preimages_constr;
4233         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4234         if (preimages_constr.datalen > 0)
4235                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4236         else
4237                 preimages_constr.data = NULL;
4238         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4239                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4240                 LDKThirtyTwoBytes preimages_conv_8_ref;
4241                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4242                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4243                 preimages_constr.data[i] = preimages_conv_8_ref;
4244         }
4245         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4246         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4247         return (int64_t)ret_conv;
4248 }
4249
4250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
4251         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4252         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4253         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4254         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4255         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
4256         return ret_arr;
4257 }
4258
4259 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) {
4260         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4261         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4262         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4263         LDKCommitmentTransaction commitment_tx_conv;
4264         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4265         commitment_tx_conv.is_owned = false;
4266         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4267         LDKCVec_PaymentPreimageZ preimages_constr;
4268         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4269         if (preimages_constr.datalen > 0)
4270                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4271         else
4272                 preimages_constr.data = NULL;
4273         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4274                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4275                 LDKThirtyTwoBytes preimages_conv_8_ref;
4276                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4277                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4278                 preimages_constr.data[i] = preimages_conv_8_ref;
4279         }
4280         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4281         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4282         return (int64_t)ret_conv;
4283 }
4284
4285 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) {
4286         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4287         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4288         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4289         unsigned char secret_arr[32];
4290         CHECK((*env)->GetArrayLength(env, secret) == 32);
4291         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
4292         unsigned char (*secret_ref)[32] = &secret_arr;
4293         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4294         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4295         return (int64_t)ret_conv;
4296 }
4297
4298 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) {
4299         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4300         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4301         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4302         LDKHolderCommitmentTransaction commitment_tx_conv;
4303         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4304         commitment_tx_conv.is_owned = false;
4305         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4306         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4307         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4308         return (int64_t)ret_conv;
4309 }
4310
4311 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) {
4312         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4313         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4314         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4315         LDKTransaction justice_tx_ref;
4316         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4317         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4318         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4319         justice_tx_ref.data_is_owned = true;
4320         unsigned char per_commitment_key_arr[32];
4321         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4322         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4323         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4324         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4325         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4326         return (int64_t)ret_conv;
4327 }
4328
4329 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) {
4330         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4331         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4332         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4333         LDKTransaction justice_tx_ref;
4334         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4335         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4336         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4337         justice_tx_ref.data_is_owned = true;
4338         unsigned char per_commitment_key_arr[32];
4339         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4340         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4341         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4342         LDKHTLCOutputInCommitment htlc_conv;
4343         htlc_conv.inner = (void*)(htlc & (~1));
4344         htlc_conv.is_owned = false;
4345         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4346         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4347         *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);
4348         return (int64_t)ret_conv;
4349 }
4350
4351 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) {
4352         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4353         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4354         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4355         LDKTransaction htlc_tx_ref;
4356         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
4357         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4358         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
4359         htlc_tx_ref.data_is_owned = true;
4360         LDKPublicKey per_commitment_point_ref;
4361         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
4362         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
4363         LDKHTLCOutputInCommitment htlc_conv;
4364         htlc_conv.inner = (void*)(htlc & (~1));
4365         htlc_conv.is_owned = false;
4366         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4367         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4368         *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);
4369         return (int64_t)ret_conv;
4370 }
4371
4372 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) {
4373         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4374         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4375         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4376         LDKClosingTransaction closing_tx_conv;
4377         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4378         closing_tx_conv.is_owned = false;
4379         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4380         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4381         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4382         return (int64_t)ret_conv;
4383 }
4384
4385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
4386         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4387         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4388         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4389         LDKUnsignedChannelAnnouncement msg_conv;
4390         msg_conv.inner = (void*)(msg & (~1));
4391         msg_conv.is_owned = false;
4392         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4393         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4394         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4395         return (int64_t)ret_conv;
4396 }
4397
4398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
4399         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4400         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4401         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4402         LDKChannelTransactionParameters channel_parameters_conv;
4403         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4404         channel_parameters_conv.is_owned = false;
4405         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4406         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4407 }
4408
4409 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4410         if (this_arg->set_pubkeys != NULL)
4411                 this_arg->set_pubkeys(this_arg);
4412         return this_arg->pubkeys;
4413 }
4414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
4415         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4416         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4417         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4418         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4419         int64_t ret_ref = 0;
4420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4423         ret_ref = (uintptr_t)ret_var.inner;
4424         if (ret_var.is_owned) {
4425                 ret_ref |= 1;
4426         }
4427         return ret_ref;
4428 }
4429
4430 typedef struct LDKSign_JCalls {
4431         atomic_size_t refcnt;
4432         JavaVM *vm;
4433         jweak o;
4434         LDKBaseSign_JCalls* BaseSign;
4435         jmethodID write_meth;
4436 } LDKSign_JCalls;
4437 static void LDKSign_JCalls_free(void* this_arg) {
4438         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4439         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4440                 JNIEnv *env;
4441                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4442                 if (get_jenv_res == JNI_EDETACHED) {
4443                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4444                 } else {
4445                         DO_ASSERT(get_jenv_res == JNI_OK);
4446                 }
4447                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4448                 if (get_jenv_res == JNI_EDETACHED) {
4449                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4450                 }
4451                 FREE(j_calls);
4452         }
4453 }
4454 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4455         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4456         JNIEnv *env;
4457         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4458         if (get_jenv_res == JNI_EDETACHED) {
4459                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4460         } else {
4461                 DO_ASSERT(get_jenv_res == JNI_OK);
4462         }
4463         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4464         CHECK(obj != NULL);
4465         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4466         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4467                 (*env)->ExceptionDescribe(env);
4468                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
4469         }
4470         LDKCVec_u8Z ret_ref;
4471         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4472         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4473         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4474         if (get_jenv_res == JNI_EDETACHED) {
4475                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4476         }
4477         return ret_ref;
4478 }
4479 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4480         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4481         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4482         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4483 }
4484 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4485         jclass c = (*env)->GetObjectClass(env, o);
4486         CHECK(c != NULL);
4487         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4488         atomic_init(&calls->refcnt, 1);
4489         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4490         calls->o = (*env)->NewWeakGlobalRef(env, o);
4491         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4492         CHECK(calls->write_meth != NULL);
4493
4494         LDKChannelPublicKeys pubkeys_conv;
4495         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4496         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4497         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4498
4499         LDKSign ret = {
4500                 .this_arg = (void*) calls,
4501                 .write = write_LDKSign_jcall,
4502                 .cloned = LDKSign_JCalls_cloned,
4503                 .free = LDKSign_JCalls_free,
4504                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
4505         };
4506         calls->BaseSign = ret.BaseSign.this_arg;
4507         return ret;
4508 }
4509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4510         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4511         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
4512         return (uint64_t)res_ptr;
4513 }
4514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
4515         LDKSign *inp = (LDKSign *)(arg & ~1);
4516         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
4517         DO_ASSERT((res_ptr & 1) == 0);
4518         return (int64_t)(res_ptr | 1);
4519 }
4520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
4521         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4522         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4523         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4524         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4525         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4526         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4527         CVec_u8Z_free(ret_var);
4528         return ret_arr;
4529 }
4530
4531 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4532 CHECK(owner->result_ok);
4533         return Sign_clone(&*owner->contents.result);
4534 }
4535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4536         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4537         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4538         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4539         return (int64_t)ret_ret;
4540 }
4541
4542 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4543 CHECK(!owner->result_ok);
4544         return DecodeError_clone(&*owner->contents.err);
4545 }
4546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4547         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4548         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4549         int64_t ret_ref = 0;
4550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4553         ret_ref = (uintptr_t)ret_var.inner;
4554         if (ret_var.is_owned) {
4555                 ret_ref |= 1;
4556         }
4557         return ret_ref;
4558 }
4559
4560 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4561 CHECK(owner->result_ok);
4562         return *owner->contents.result;
4563 }
4564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4565         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4566         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
4567         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
4568         return ret_arr;
4569 }
4570
4571 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4572 CHECK(!owner->result_ok);
4573         return *owner->contents.err;
4574 }
4575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4576         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4577         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4578 }
4579
4580 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4581         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4582         for (size_t i = 0; i < ret.datalen; i++) {
4583                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4584         }
4585         return ret;
4586 }
4587 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4588 CHECK(owner->result_ok);
4589         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4590 }
4591 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4592         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4593         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4594         jobjectArray ret_arr = NULL;
4595         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4596         ;
4597         for (size_t i = 0; i < ret_var.datalen; i++) {
4598                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
4599                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
4600                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
4601                 CVec_u8Z_free(ret_conv_8_var);
4602                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4603         }
4604         
4605         FREE(ret_var.data);
4606         return ret_arr;
4607 }
4608
4609 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4610 CHECK(!owner->result_ok);
4611         return *owner->contents.err;
4612 }
4613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4614         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4615         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4616 }
4617
4618 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4619 CHECK(owner->result_ok);
4620         return InMemorySigner_clone(&*owner->contents.result);
4621 }
4622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4623         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4624         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4625         int64_t ret_ref = 0;
4626         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4627         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4629         ret_ref = (uintptr_t)ret_var.inner;
4630         if (ret_var.is_owned) {
4631                 ret_ref |= 1;
4632         }
4633         return ret_ref;
4634 }
4635
4636 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4637 CHECK(!owner->result_ok);
4638         return DecodeError_clone(&*owner->contents.err);
4639 }
4640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4641         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4642         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4643         int64_t ret_ref = 0;
4644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4647         ret_ref = (uintptr_t)ret_var.inner;
4648         if (ret_var.is_owned) {
4649                 ret_ref |= 1;
4650         }
4651         return ret_ref;
4652 }
4653
4654 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4655         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4656         for (size_t i = 0; i < ret.datalen; i++) {
4657                 ret.data[i] = TxOut_clone(&orig->data[i]);
4658         }
4659         return ret;
4660 }
4661 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4662 CHECK(owner->result_ok);
4663         return *owner->contents.result;
4664 }
4665 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4666         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4667         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4668         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4669         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4670         return ret_arr;
4671 }
4672
4673 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4674 CHECK(!owner->result_ok);
4675         return *owner->contents.err;
4676 }
4677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4678         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4679         CResult_TransactionNoneZ_get_err(owner_conv);
4680 }
4681
4682 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4683         return ThirtyTwoBytes_clone(&owner->a);
4684 }
4685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4686         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4687         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
4689         return ret_arr;
4690 }
4691
4692 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4693         return ChannelMonitor_clone(&owner->b);
4694 }
4695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4696         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4697         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
4698         int64_t ret_ref = 0;
4699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4702         ret_ref = (uintptr_t)ret_var.inner;
4703         if (ret_var.is_owned) {
4704                 ret_ref |= 1;
4705         }
4706         return ret_ref;
4707 }
4708
4709 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
4710         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
4711         for (size_t i = 0; i < ret.datalen; i++) {
4712                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
4713         }
4714         return ret;
4715 }
4716 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4717 CHECK(owner->result_ok);
4718         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
4719 }
4720 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4721         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4722         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
4723         int64_tArray ret_arr = NULL;
4724         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4725         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4726         for (size_t j = 0; j < ret_var.datalen; j++) {
4727                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4728                 *ret_conv_35_conv = ret_var.data[j];
4729                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
4730         }
4731         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4732         FREE(ret_var.data);
4733         return ret_arr;
4734 }
4735
4736 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4737 CHECK(!owner->result_ok);
4738         return *owner->contents.err;
4739 }
4740 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4741         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4742         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
4743         return ret_conv;
4744 }
4745
4746 static jclass LDKCOption_u16Z_Some_class = NULL;
4747 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
4748 static jclass LDKCOption_u16Z_None_class = NULL;
4749 static jmethodID LDKCOption_u16Z_None_meth = NULL;
4750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
4751         LDKCOption_u16Z_Some_class =
4752                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
4753         CHECK(LDKCOption_u16Z_Some_class != NULL);
4754         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
4755         CHECK(LDKCOption_u16Z_Some_meth != NULL);
4756         LDKCOption_u16Z_None_class =
4757                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
4758         CHECK(LDKCOption_u16Z_None_class != NULL);
4759         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
4760         CHECK(LDKCOption_u16Z_None_meth != NULL);
4761 }
4762 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4763         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4764         switch(obj->tag) {
4765                 case LDKCOption_u16Z_Some: {
4766                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
4767                 }
4768                 case LDKCOption_u16Z_None: {
4769                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
4770                 }
4771                 default: abort();
4772         }
4773 }
4774 static jclass LDKAPIError_APIMisuseError_class = NULL;
4775 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
4776 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
4777 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
4778 static jclass LDKAPIError_RouteError_class = NULL;
4779 static jmethodID LDKAPIError_RouteError_meth = NULL;
4780 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
4781 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
4782 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
4783 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
4784 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
4785 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
4786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
4787         LDKAPIError_APIMisuseError_class =
4788                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
4789         CHECK(LDKAPIError_APIMisuseError_class != NULL);
4790         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
4791         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
4792         LDKAPIError_FeeRateTooHigh_class =
4793                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
4794         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
4795         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
4796         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
4797         LDKAPIError_RouteError_class =
4798                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
4799         CHECK(LDKAPIError_RouteError_class != NULL);
4800         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
4801         CHECK(LDKAPIError_RouteError_meth != NULL);
4802         LDKAPIError_ChannelUnavailable_class =
4803                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
4804         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
4805         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
4806         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
4807         LDKAPIError_MonitorUpdateFailed_class =
4808                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
4809         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
4810         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
4811         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
4812         LDKAPIError_IncompatibleShutdownScript_class =
4813                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
4814         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
4815         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
4816         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
4817 }
4818 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4819         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4820         switch(obj->tag) {
4821                 case LDKAPIError_APIMisuseError: {
4822                         LDKStr err_str = obj->api_misuse_error.err;
4823                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4824                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
4825                 }
4826                 case LDKAPIError_FeeRateTooHigh: {
4827                         LDKStr err_str = obj->fee_rate_too_high.err;
4828                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4829                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
4830                 }
4831                 case LDKAPIError_RouteError: {
4832                         LDKStr err_str = obj->route_error.err;
4833                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4834                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
4835                 }
4836                 case LDKAPIError_ChannelUnavailable: {
4837                         LDKStr err_str = obj->channel_unavailable.err;
4838                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4839                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
4840                 }
4841                 case LDKAPIError_MonitorUpdateFailed: {
4842                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
4843                 }
4844                 case LDKAPIError_IncompatibleShutdownScript: {
4845                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4846                         int64_t script_ref = 0;
4847                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4848                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4849                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4850                         script_ref = (uintptr_t)script_var.inner & ~1;
4851                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
4852                 }
4853                 default: abort();
4854         }
4855 }
4856 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4857 CHECK(owner->result_ok);
4858         return *owner->contents.result;
4859 }
4860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4861         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4862         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4863 }
4864
4865 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4866 CHECK(!owner->result_ok);
4867         return APIError_clone(&*owner->contents.err);
4868 }
4869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4870         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4871         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4872         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4873         int64_t ret_ref = (uintptr_t)ret_copy;
4874         return ret_ref;
4875 }
4876
4877 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4878         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4879         for (size_t i = 0; i < ret.datalen; i++) {
4880                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4881         }
4882         return ret;
4883 }
4884 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4885         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4886         for (size_t i = 0; i < ret.datalen; i++) {
4887                 ret.data[i] = APIError_clone(&orig->data[i]);
4888         }
4889         return ret;
4890 }
4891 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4892 CHECK(owner->result_ok);
4893         return ThirtyTwoBytes_clone(&*owner->contents.result);
4894 }
4895 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4896         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4897         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4898         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
4899         return ret_arr;
4900 }
4901
4902 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4903 CHECK(!owner->result_ok);
4904         return APIError_clone(&*owner->contents.err);
4905 }
4906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4907         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4908         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4909         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4910         int64_t ret_ref = (uintptr_t)ret_copy;
4911         return ret_ref;
4912 }
4913
4914 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
4915 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
4916 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
4917 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
4918 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
4919 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
4920 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
4921 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
4922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
4923         LDKPaymentSendFailure_ParameterError_class =
4924                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
4925         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
4926         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
4927         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
4928         LDKPaymentSendFailure_PathParameterError_class =
4929                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
4930         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
4931         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
4932         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
4933         LDKPaymentSendFailure_AllFailedRetrySafe_class =
4934                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
4935         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
4936         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
4937         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
4938         LDKPaymentSendFailure_PartialFailure_class =
4939                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
4940         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
4941         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
4942         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
4943 }
4944 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4945         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4946         switch(obj->tag) {
4947                 case LDKPaymentSendFailure_ParameterError: {
4948                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4949                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
4950                 }
4951                 case LDKPaymentSendFailure_PathParameterError: {
4952                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4953                         int64_tArray path_parameter_error_arr = NULL;
4954                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
4955                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
4956                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4957                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4958                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4959                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4960                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
4961                         }
4962                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
4963                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
4964                 }
4965                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
4966                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4967                         int64_tArray all_failed_retry_safe_arr = NULL;
4968                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
4969                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
4970                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4971                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
4972                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4973                         }
4974                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
4975                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
4976                 }
4977                 case LDKPaymentSendFailure_PartialFailure: {
4978                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4979                         int64_tArray results_arr = NULL;
4980                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
4981                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
4982                         for (size_t w = 0; w < results_var.datalen; w++) {
4983                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4984                                 *results_conv_22_conv = results_var.data[w];
4985                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4986                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
4987                         }
4988                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
4989                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4990                         int64_t failed_paths_retry_ref = 0;
4991                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
4992                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4993                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4994                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4995                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
4996                         }
4997                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4998                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
4999                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
5000                 }
5001                 default: abort();
5002         }
5003 }
5004 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5005 CHECK(owner->result_ok);
5006         return ThirtyTwoBytes_clone(&*owner->contents.result);
5007 }
5008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5009         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5010         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5011         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
5012         return ret_arr;
5013 }
5014
5015 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5016 CHECK(!owner->result_ok);
5017         return PaymentSendFailure_clone(&*owner->contents.err);
5018 }
5019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5020         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5021         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5022         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
5023         int64_t ret_ref = (uintptr_t)ret_copy;
5024         return ret_ref;
5025 }
5026
5027 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5028 CHECK(owner->result_ok);
5029         return *owner->contents.result;
5030 }
5031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5032         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5033         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5034 }
5035
5036 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5037 CHECK(!owner->result_ok);
5038         return PaymentSendFailure_clone(&*owner->contents.err);
5039 }
5040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5041         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5042         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5043         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5044         int64_t ret_ref = (uintptr_t)ret_copy;
5045         return ret_ref;
5046 }
5047
5048 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5049         return ThirtyTwoBytes_clone(&owner->a);
5050 }
5051 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5052         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5053         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5054         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
5055         return ret_arr;
5056 }
5057
5058 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5059         return ThirtyTwoBytes_clone(&owner->b);
5060 }
5061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5062         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5063         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5064         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
5065         return ret_arr;
5066 }
5067
5068 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5069 CHECK(owner->result_ok);
5070         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
5071 }
5072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5073         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5074         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
5075         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
5076         return ((int64_t)ret_conv);
5077 }
5078
5079 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5080 CHECK(!owner->result_ok);
5081         return PaymentSendFailure_clone(&*owner->contents.err);
5082 }
5083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5084         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5085         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5086         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
5087         int64_t ret_ref = (uintptr_t)ret_copy;
5088         return ret_ref;
5089 }
5090
5091 static jclass LDKNetAddress_IPv4_class = NULL;
5092 static jmethodID LDKNetAddress_IPv4_meth = NULL;
5093 static jclass LDKNetAddress_IPv6_class = NULL;
5094 static jmethodID LDKNetAddress_IPv6_meth = NULL;
5095 static jclass LDKNetAddress_OnionV2_class = NULL;
5096 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
5097 static jclass LDKNetAddress_OnionV3_class = NULL;
5098 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
5099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
5100         LDKNetAddress_IPv4_class =
5101                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
5102         CHECK(LDKNetAddress_IPv4_class != NULL);
5103         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
5104         CHECK(LDKNetAddress_IPv4_meth != NULL);
5105         LDKNetAddress_IPv6_class =
5106                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
5107         CHECK(LDKNetAddress_IPv6_class != NULL);
5108         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
5109         CHECK(LDKNetAddress_IPv6_meth != NULL);
5110         LDKNetAddress_OnionV2_class =
5111                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
5112         CHECK(LDKNetAddress_OnionV2_class != NULL);
5113         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
5114         CHECK(LDKNetAddress_OnionV2_meth != NULL);
5115         LDKNetAddress_OnionV3_class =
5116                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
5117         CHECK(LDKNetAddress_OnionV3_class != NULL);
5118         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
5119         CHECK(LDKNetAddress_OnionV3_meth != NULL);
5120 }
5121 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5122         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
5123         switch(obj->tag) {
5124                 case LDKNetAddress_IPv4: {
5125                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
5126                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
5127                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
5128                 }
5129                 case LDKNetAddress_IPv6: {
5130                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
5131                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
5132                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
5133                 }
5134                 case LDKNetAddress_OnionV2: {
5135                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
5136                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
5137                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
5138                 }
5139                 case LDKNetAddress_OnionV3: {
5140                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
5141                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
5142                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, obj->onion_v3.checksum, obj->onion_v3.version, obj->onion_v3.port);
5143                 }
5144                 default: abort();
5145         }
5146 }
5147 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
5148         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
5149         for (size_t i = 0; i < ret.datalen; i++) {
5150                 ret.data[i] = NetAddress_clone(&orig->data[i]);
5151         }
5152         return ret;
5153 }
5154 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5155         return ThirtyTwoBytes_clone(&owner->a);
5156 }
5157 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5158         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5159         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5160         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
5161         return ret_arr;
5162 }
5163
5164 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5165         return ThirtyTwoBytes_clone(&owner->b);
5166 }
5167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5168         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5169         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5170         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
5171         return ret_arr;
5172 }
5173
5174 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5175 CHECK(owner->result_ok);
5176         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5177 }
5178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5179         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5180         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5181         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5182         return ((int64_t)ret_conv);
5183 }
5184
5185 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5186 CHECK(!owner->result_ok);
5187         return *owner->contents.err;
5188 }
5189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5190         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5191         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5192 }
5193
5194 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5195 CHECK(owner->result_ok);
5196         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5197 }
5198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5199         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5200         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5201         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5202         return ((int64_t)ret_conv);
5203 }
5204
5205 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5206 CHECK(!owner->result_ok);
5207         return APIError_clone(&*owner->contents.err);
5208 }
5209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5210         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5211         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5212         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5213         int64_t ret_ref = (uintptr_t)ret_copy;
5214         return ret_ref;
5215 }
5216
5217 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5218 CHECK(owner->result_ok);
5219         return ThirtyTwoBytes_clone(&*owner->contents.result);
5220 }
5221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5222         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5223         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5224         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
5225         return ret_arr;
5226 }
5227
5228 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5229 CHECK(!owner->result_ok);
5230         return *owner->contents.err;
5231 }
5232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5233         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5234         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5235 }
5236
5237 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5238 CHECK(owner->result_ok);
5239         return ThirtyTwoBytes_clone(&*owner->contents.result);
5240 }
5241 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5242         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5243         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5244         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
5245         return ret_arr;
5246 }
5247
5248 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5249 CHECK(!owner->result_ok);
5250         return APIError_clone(&*owner->contents.err);
5251 }
5252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5253         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5254         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5255         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
5256         int64_t ret_ref = (uintptr_t)ret_copy;
5257         return ret_ref;
5258 }
5259
5260 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5261 CHECK(owner->result_ok);
5262         return ThirtyTwoBytes_clone(&*owner->contents.result);
5263 }
5264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5265         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5266         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5267         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
5268         return ret_arr;
5269 }
5270
5271 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5272 CHECK(!owner->result_ok);
5273         return APIError_clone(&*owner->contents.err);
5274 }
5275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5276         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5277         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5278         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
5279         int64_t ret_ref = (uintptr_t)ret_copy;
5280         return ret_ref;
5281 }
5282
5283 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5284 CHECK(owner->result_ok);
5285         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
5286 }
5287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5288         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5289         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5290         int64_t ret_ref = 0;
5291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5294         ret_ref = (uintptr_t)ret_var.inner;
5295         if (ret_var.is_owned) {
5296                 ret_ref |= 1;
5297         }
5298         return ret_ref;
5299 }
5300
5301 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5302 CHECK(!owner->result_ok);
5303         return DecodeError_clone(&*owner->contents.err);
5304 }
5305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5306         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5307         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5308         int64_t ret_ref = 0;
5309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5312         ret_ref = (uintptr_t)ret_var.inner;
5313         if (ret_var.is_owned) {
5314                 ret_ref |= 1;
5315         }
5316         return ret_ref;
5317 }
5318
5319 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5320 CHECK(owner->result_ok);
5321         return ChannelCounterparty_clone(&*owner->contents.result);
5322 }
5323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5324         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5325         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5326         int64_t ret_ref = 0;
5327         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5328         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5330         ret_ref = (uintptr_t)ret_var.inner;
5331         if (ret_var.is_owned) {
5332                 ret_ref |= 1;
5333         }
5334         return ret_ref;
5335 }
5336
5337 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5338 CHECK(!owner->result_ok);
5339         return DecodeError_clone(&*owner->contents.err);
5340 }
5341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5342         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5343         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5344         int64_t ret_ref = 0;
5345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5348         ret_ref = (uintptr_t)ret_var.inner;
5349         if (ret_var.is_owned) {
5350                 ret_ref |= 1;
5351         }
5352         return ret_ref;
5353 }
5354
5355 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5356 CHECK(owner->result_ok);
5357         return ChannelDetails_clone(&*owner->contents.result);
5358 }
5359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5360         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5361         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5362         int64_t ret_ref = 0;
5363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5366         ret_ref = (uintptr_t)ret_var.inner;
5367         if (ret_var.is_owned) {
5368                 ret_ref |= 1;
5369         }
5370         return ret_ref;
5371 }
5372
5373 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5374 CHECK(!owner->result_ok);
5375         return DecodeError_clone(&*owner->contents.err);
5376 }
5377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5378         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5379         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5380         int64_t ret_ref = 0;
5381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5384         ret_ref = (uintptr_t)ret_var.inner;
5385         if (ret_var.is_owned) {
5386                 ret_ref |= 1;
5387         }
5388         return ret_ref;
5389 }
5390
5391 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5392 CHECK(owner->result_ok);
5393         return PhantomRouteHints_clone(&*owner->contents.result);
5394 }
5395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5396         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5397         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5398         int64_t ret_ref = 0;
5399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5402         ret_ref = (uintptr_t)ret_var.inner;
5403         if (ret_var.is_owned) {
5404                 ret_ref |= 1;
5405         }
5406         return ret_ref;
5407 }
5408
5409 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5410 CHECK(!owner->result_ok);
5411         return DecodeError_clone(&*owner->contents.err);
5412 }
5413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5414         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5415         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5416         int64_t ret_ref = 0;
5417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5420         ret_ref = (uintptr_t)ret_var.inner;
5421         if (ret_var.is_owned) {
5422                 ret_ref |= 1;
5423         }
5424         return ret_ref;
5425 }
5426
5427 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5428         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5429         for (size_t i = 0; i < ret.datalen; i++) {
5430                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5431         }
5432         return ret;
5433 }
5434 typedef struct LDKWatch_JCalls {
5435         atomic_size_t refcnt;
5436         JavaVM *vm;
5437         jweak o;
5438         jmethodID watch_channel_meth;
5439         jmethodID update_channel_meth;
5440         jmethodID release_pending_monitor_events_meth;
5441 } LDKWatch_JCalls;
5442 static void LDKWatch_JCalls_free(void* this_arg) {
5443         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5444         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5445                 JNIEnv *env;
5446                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5447                 if (get_jenv_res == JNI_EDETACHED) {
5448                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5449                 } else {
5450                         DO_ASSERT(get_jenv_res == JNI_OK);
5451                 }
5452                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5453                 if (get_jenv_res == JNI_EDETACHED) {
5454                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5455                 }
5456                 FREE(j_calls);
5457         }
5458 }
5459 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5460         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5461         JNIEnv *env;
5462         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5463         if (get_jenv_res == JNI_EDETACHED) {
5464                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5465         } else {
5466                 DO_ASSERT(get_jenv_res == JNI_OK);
5467         }
5468         LDKOutPoint funding_txo_var = funding_txo;
5469         int64_t funding_txo_ref = 0;
5470         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5471         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5472         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5473         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5474         if (funding_txo_var.is_owned) {
5475                 funding_txo_ref |= 1;
5476         }
5477         LDKChannelMonitor monitor_var = monitor;
5478         int64_t monitor_ref = 0;
5479         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5480         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5481         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5482         monitor_ref = (uintptr_t)monitor_var.inner;
5483         if (monitor_var.is_owned) {
5484                 monitor_ref |= 1;
5485         }
5486         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5487         CHECK(obj != NULL);
5488         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
5489         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5490                 (*env)->ExceptionDescribe(env);
5491                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
5492         }
5493         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5494         CHECK_ACCESS(ret_ptr);
5495         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5496         FREE((void*)ret);
5497         if (get_jenv_res == JNI_EDETACHED) {
5498                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5499         }
5500         return ret_conv;
5501 }
5502 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5503         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5504         JNIEnv *env;
5505         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5506         if (get_jenv_res == JNI_EDETACHED) {
5507                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5508         } else {
5509                 DO_ASSERT(get_jenv_res == JNI_OK);
5510         }
5511         LDKOutPoint funding_txo_var = funding_txo;
5512         int64_t funding_txo_ref = 0;
5513         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5514         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5515         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5516         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5517         if (funding_txo_var.is_owned) {
5518                 funding_txo_ref |= 1;
5519         }
5520         LDKChannelMonitorUpdate update_var = update;
5521         int64_t update_ref = 0;
5522         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5523         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5524         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5525         update_ref = (uintptr_t)update_var.inner;
5526         if (update_var.is_owned) {
5527                 update_ref |= 1;
5528         }
5529         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5530         CHECK(obj != NULL);
5531         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
5532         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5533                 (*env)->ExceptionDescribe(env);
5534                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
5535         }
5536         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5537         CHECK_ACCESS(ret_ptr);
5538         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5539         FREE((void*)ret);
5540         if (get_jenv_res == JNI_EDETACHED) {
5541                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5542         }
5543         return ret_conv;
5544 }
5545 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5546         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5547         JNIEnv *env;
5548         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5549         if (get_jenv_res == JNI_EDETACHED) {
5550                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5551         } else {
5552                 DO_ASSERT(get_jenv_res == JNI_OK);
5553         }
5554         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5555         CHECK(obj != NULL);
5556         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
5557         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5558                 (*env)->ExceptionDescribe(env);
5559                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
5560         }
5561         LDKCVec_MonitorEventZ ret_constr;
5562         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5563         if (ret_constr.datalen > 0)
5564                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
5565         else
5566                 ret_constr.data = NULL;
5567         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5568         for (size_t o = 0; o < ret_constr.datalen; o++) {
5569                 int64_t ret_conv_14 = ret_vals[o];
5570                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
5571                 CHECK_ACCESS(ret_conv_14_ptr);
5572                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
5573                 FREE((void*)ret_conv_14);
5574                 ret_constr.data[o] = ret_conv_14_conv;
5575         }
5576         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5577         if (get_jenv_res == JNI_EDETACHED) {
5578                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5579         }
5580         return ret_constr;
5581 }
5582 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5583         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5584         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5585 }
5586 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
5587         jclass c = (*env)->GetObjectClass(env, o);
5588         CHECK(c != NULL);
5589         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_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->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
5594         CHECK(calls->watch_channel_meth != NULL);
5595         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
5596         CHECK(calls->update_channel_meth != NULL);
5597         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
5598         CHECK(calls->release_pending_monitor_events_meth != NULL);
5599
5600         LDKWatch ret = {
5601                 .this_arg = (void*) calls,
5602                 .watch_channel = watch_channel_LDKWatch_jcall,
5603                 .update_channel = update_channel_LDKWatch_jcall,
5604                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5605                 .free = LDKWatch_JCalls_free,
5606         };
5607         return ret;
5608 }
5609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
5610         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5611         *res_ptr = LDKWatch_init(env, clz, o);
5612         return (uint64_t)res_ptr;
5613 }
5614 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) {
5615         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5616         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5617         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5618         LDKOutPoint funding_txo_conv;
5619         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5620         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5621         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5622         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5623         LDKChannelMonitor monitor_conv;
5624         monitor_conv.inner = (void*)(monitor & (~1));
5625         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5626         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5627         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5628         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5629         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5630         return (int64_t)ret_conv;
5631 }
5632
5633 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) {
5634         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5635         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5636         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5637         LDKOutPoint funding_txo_conv;
5638         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5639         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5640         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5641         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5642         LDKChannelMonitorUpdate update_conv;
5643         update_conv.inner = (void*)(update & (~1));
5644         update_conv.is_owned = (update & 1) || (update == 0);
5645         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5646         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5647         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5648         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5649         return (int64_t)ret_conv;
5650 }
5651
5652 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
5653         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5654         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5655         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5656         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5657         int64_tArray ret_arr = NULL;
5658         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5659         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5660         for (size_t o = 0; o < ret_var.datalen; o++) {
5661                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
5662                 *ret_conv_14_copy = ret_var.data[o];
5663                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
5664                 ret_arr_ptr[o] = ret_conv_14_ref;
5665         }
5666         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5667         FREE(ret_var.data);
5668         return ret_arr;
5669 }
5670
5671 typedef struct LDKBroadcasterInterface_JCalls {
5672         atomic_size_t refcnt;
5673         JavaVM *vm;
5674         jweak o;
5675         jmethodID broadcast_transaction_meth;
5676 } LDKBroadcasterInterface_JCalls;
5677 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5678         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5679         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5680                 JNIEnv *env;
5681                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5682                 if (get_jenv_res == JNI_EDETACHED) {
5683                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5684                 } else {
5685                         DO_ASSERT(get_jenv_res == JNI_OK);
5686                 }
5687                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5688                 if (get_jenv_res == JNI_EDETACHED) {
5689                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5690                 }
5691                 FREE(j_calls);
5692         }
5693 }
5694 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5695         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5696         JNIEnv *env;
5697         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5698         if (get_jenv_res == JNI_EDETACHED) {
5699                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5700         } else {
5701                 DO_ASSERT(get_jenv_res == JNI_OK);
5702         }
5703         LDKTransaction tx_var = tx;
5704         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
5705         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
5706         Transaction_free(tx_var);
5707         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5708         CHECK(obj != NULL);
5709         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
5710         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5711                 (*env)->ExceptionDescribe(env);
5712                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
5713         }
5714         if (get_jenv_res == JNI_EDETACHED) {
5715                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5716         }
5717 }
5718 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5719         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5720         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5721 }
5722 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
5723         jclass c = (*env)->GetObjectClass(env, o);
5724         CHECK(c != NULL);
5725         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5726         atomic_init(&calls->refcnt, 1);
5727         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5728         calls->o = (*env)->NewWeakGlobalRef(env, o);
5729         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
5730         CHECK(calls->broadcast_transaction_meth != NULL);
5731
5732         LDKBroadcasterInterface ret = {
5733                 .this_arg = (void*) calls,
5734                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5735                 .free = LDKBroadcasterInterface_JCalls_free,
5736         };
5737         return ret;
5738 }
5739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
5740         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5741         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
5742         return (uint64_t)res_ptr;
5743 }
5744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
5745         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5746         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5747         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5748         LDKTransaction tx_ref;
5749         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
5750         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5751         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
5752         tx_ref.data_is_owned = true;
5753         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5754 }
5755
5756 typedef struct LDKKeysInterface_JCalls {
5757         atomic_size_t refcnt;
5758         JavaVM *vm;
5759         jweak o;
5760         jmethodID get_node_secret_meth;
5761         jmethodID get_destination_script_meth;
5762         jmethodID get_shutdown_scriptpubkey_meth;
5763         jmethodID get_channel_signer_meth;
5764         jmethodID get_secure_random_bytes_meth;
5765         jmethodID read_chan_signer_meth;
5766         jmethodID sign_invoice_meth;
5767         jmethodID get_inbound_payment_key_material_meth;
5768 } LDKKeysInterface_JCalls;
5769 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5770         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5771         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5772                 JNIEnv *env;
5773                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5774                 if (get_jenv_res == JNI_EDETACHED) {
5775                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5776                 } else {
5777                         DO_ASSERT(get_jenv_res == JNI_OK);
5778                 }
5779                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5780                 if (get_jenv_res == JNI_EDETACHED) {
5781                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5782                 }
5783                 FREE(j_calls);
5784         }
5785 }
5786 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5787         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5788         JNIEnv *env;
5789         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5790         if (get_jenv_res == JNI_EDETACHED) {
5791                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5792         } else {
5793                 DO_ASSERT(get_jenv_res == JNI_OK);
5794         }
5795         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
5796         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5797         CHECK(obj != NULL);
5798         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
5799         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5800                 (*env)->ExceptionDescribe(env);
5801                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
5802         }
5803         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5804         CHECK_ACCESS(ret_ptr);
5805         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5806         FREE((void*)ret);
5807         if (get_jenv_res == JNI_EDETACHED) {
5808                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5809         }
5810         return ret_conv;
5811 }
5812 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5813         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5814         JNIEnv *env;
5815         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5816         if (get_jenv_res == JNI_EDETACHED) {
5817                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5818         } else {
5819                 DO_ASSERT(get_jenv_res == JNI_OK);
5820         }
5821         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5822         CHECK(obj != NULL);
5823         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
5824         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5825                 (*env)->ExceptionDescribe(env);
5826                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
5827         }
5828         LDKCVec_u8Z ret_ref;
5829         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5830         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5831         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5832         if (get_jenv_res == JNI_EDETACHED) {
5833                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5834         }
5835         return ret_ref;
5836 }
5837 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5838         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5839         JNIEnv *env;
5840         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5841         if (get_jenv_res == JNI_EDETACHED) {
5842                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5843         } else {
5844                 DO_ASSERT(get_jenv_res == JNI_OK);
5845         }
5846         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5847         CHECK(obj != NULL);
5848         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
5849         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5850                 (*env)->ExceptionDescribe(env);
5851                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
5852         }
5853         LDKShutdownScript ret_conv;
5854         ret_conv.inner = (void*)(ret & (~1));
5855         ret_conv.is_owned = (ret & 1) || (ret == 0);
5856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5857         if (get_jenv_res == JNI_EDETACHED) {
5858                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5859         }
5860         return ret_conv;
5861 }
5862 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5863         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5864         JNIEnv *env;
5865         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5866         if (get_jenv_res == JNI_EDETACHED) {
5867                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5868         } else {
5869                 DO_ASSERT(get_jenv_res == JNI_OK);
5870         }
5871         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5872         CHECK(obj != NULL);
5873         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
5874         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5875                 (*env)->ExceptionDescribe(env);
5876                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
5877         }
5878         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5879         CHECK_ACCESS(ret_ptr);
5880         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5881         FREE((void*)ret);
5882         if (get_jenv_res == JNI_EDETACHED) {
5883                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5884         }
5885         return ret_conv;
5886 }
5887 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5888         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5889         JNIEnv *env;
5890         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5891         if (get_jenv_res == JNI_EDETACHED) {
5892                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5893         } else {
5894                 DO_ASSERT(get_jenv_res == JNI_OK);
5895         }
5896         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5897         CHECK(obj != NULL);
5898         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
5899         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5900                 (*env)->ExceptionDescribe(env);
5901                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
5902         }
5903         LDKThirtyTwoBytes ret_ref;
5904         CHECK((*env)->GetArrayLength(env, ret) == 32);
5905         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5906         if (get_jenv_res == JNI_EDETACHED) {
5907                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5908         }
5909         return ret_ref;
5910 }
5911 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5912         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5913         JNIEnv *env;
5914         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5915         if (get_jenv_res == JNI_EDETACHED) {
5916                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5917         } else {
5918                 DO_ASSERT(get_jenv_res == JNI_OK);
5919         }
5920         LDKu8slice reader_var = reader;
5921         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
5922         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
5923         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5924         CHECK(obj != NULL);
5925         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
5926         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5927                 (*env)->ExceptionDescribe(env);
5928                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
5929         }
5930         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5931         CHECK_ACCESS(ret_ptr);
5932         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5933         FREE((void*)ret);
5934         if (get_jenv_res == JNI_EDETACHED) {
5935                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5936         }
5937         return ret_conv;
5938 }
5939 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5940         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5941         JNIEnv *env;
5942         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5943         if (get_jenv_res == JNI_EDETACHED) {
5944                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5945         } else {
5946                 DO_ASSERT(get_jenv_res == JNI_OK);
5947         }
5948         LDKu8slice hrp_bytes_var = hrp_bytes;
5949         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
5950         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
5951         LDKCVec_u5Z invoice_data_var = invoice_data;
5952         jobjectArray invoice_data_arr = NULL;
5953         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
5954         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
5955         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5956                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5957                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5958         }
5959         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
5960         FREE(invoice_data_var.data);
5961         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
5962         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5963         CHECK(obj != NULL);
5964         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
5965         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5966                 (*env)->ExceptionDescribe(env);
5967                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
5968         }
5969         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5970         CHECK_ACCESS(ret_ptr);
5971         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5972         FREE((void*)ret);
5973         if (get_jenv_res == JNI_EDETACHED) {
5974                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5975         }
5976         return ret_conv;
5977 }
5978 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5979         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5980         JNIEnv *env;
5981         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5982         if (get_jenv_res == JNI_EDETACHED) {
5983                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5984         } else {
5985                 DO_ASSERT(get_jenv_res == JNI_OK);
5986         }
5987         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5988         CHECK(obj != NULL);
5989         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
5990         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5991                 (*env)->ExceptionDescribe(env);
5992                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
5993         }
5994         LDKThirtyTwoBytes ret_ref;
5995         CHECK((*env)->GetArrayLength(env, ret) == 32);
5996         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5997         if (get_jenv_res == JNI_EDETACHED) {
5998                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5999         }
6000         return ret_ref;
6001 }
6002 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6003         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6004         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6005 }
6006 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
6007         jclass c = (*env)->GetObjectClass(env, o);
6008         CHECK(c != NULL);
6009         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6010         atomic_init(&calls->refcnt, 1);
6011         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6012         calls->o = (*env)->NewWeakGlobalRef(env, o);
6013         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
6014         CHECK(calls->get_node_secret_meth != NULL);
6015         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
6016         CHECK(calls->get_destination_script_meth != NULL);
6017         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
6018         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
6019         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
6020         CHECK(calls->get_channel_signer_meth != NULL);
6021         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
6022         CHECK(calls->get_secure_random_bytes_meth != NULL);
6023         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
6024         CHECK(calls->read_chan_signer_meth != NULL);
6025         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
6026         CHECK(calls->sign_invoice_meth != NULL);
6027         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
6028         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
6029
6030         LDKKeysInterface ret = {
6031                 .this_arg = (void*) calls,
6032                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6033                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6034                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6035                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6036                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6037                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6038                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6039                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6040                 .free = LDKKeysInterface_JCalls_free,
6041         };
6042         return ret;
6043 }
6044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6045         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6046         *res_ptr = LDKKeysInterface_init(env, clz, o);
6047         return (uint64_t)res_ptr;
6048 }
6049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
6050         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6051         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6052         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6053         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
6054         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
6055         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
6056         return (int64_t)ret_conv;
6057 }
6058
6059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
6060         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6061         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6062         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6063         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6064         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6065         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6066         CVec_u8Z_free(ret_var);
6067         return ret_arr;
6068 }
6069
6070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
6071         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6072         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6073         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6074         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6075         int64_t ret_ref = 0;
6076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6079         ret_ref = (uintptr_t)ret_var.inner;
6080         if (ret_var.is_owned) {
6081                 ret_ref |= 1;
6082         }
6083         return ret_ref;
6084 }
6085
6086 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) {
6087         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6088         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6089         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6090         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6091         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6092         return (int64_t)ret_ret;
6093 }
6094
6095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
6096         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6097         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6098         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6099         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6100         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
6101         return ret_arr;
6102 }
6103
6104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
6105         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6106         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6107         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6108         LDKu8slice reader_ref;
6109         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
6110         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
6111         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6112         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6113         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
6114         return (int64_t)ret_conv;
6115 }
6116
6117 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) {
6118         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6119         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6120         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6121         LDKu8slice hrp_bytes_ref;
6122         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
6123         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
6124         LDKCVec_u5Z invoice_data_constr;
6125         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
6126         if (invoice_data_constr.datalen > 0)
6127                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
6128         else
6129                 invoice_data_constr.data = NULL;
6130         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
6131         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6132                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6133                 
6134                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
6135         }
6136         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
6137         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
6138         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6139         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
6140         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
6141         return (int64_t)ret_conv;
6142 }
6143
6144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
6145         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6146         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6147         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6148         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6149         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
6150         return ret_arr;
6151 }
6152
6153 typedef struct LDKFeeEstimator_JCalls {
6154         atomic_size_t refcnt;
6155         JavaVM *vm;
6156         jweak o;
6157         jmethodID get_est_sat_per_1000_weight_meth;
6158 } LDKFeeEstimator_JCalls;
6159 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6160         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6161         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6162                 JNIEnv *env;
6163                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6164                 if (get_jenv_res == JNI_EDETACHED) {
6165                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6166                 } else {
6167                         DO_ASSERT(get_jenv_res == JNI_OK);
6168                 }
6169                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6170                 if (get_jenv_res == JNI_EDETACHED) {
6171                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6172                 }
6173                 FREE(j_calls);
6174         }
6175 }
6176 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6177         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6178         JNIEnv *env;
6179         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6180         if (get_jenv_res == JNI_EDETACHED) {
6181                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6182         } else {
6183                 DO_ASSERT(get_jenv_res == JNI_OK);
6184         }
6185         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
6186         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6187         CHECK(obj != NULL);
6188         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
6189         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6190                 (*env)->ExceptionDescribe(env);
6191                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
6192         }
6193         if (get_jenv_res == JNI_EDETACHED) {
6194                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6195         }
6196         return ret;
6197 }
6198 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6199         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6200         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6201 }
6202 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
6203         jclass c = (*env)->GetObjectClass(env, o);
6204         CHECK(c != NULL);
6205         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6206         atomic_init(&calls->refcnt, 1);
6207         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6208         calls->o = (*env)->NewWeakGlobalRef(env, o);
6209         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
6210         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
6211
6212         LDKFeeEstimator ret = {
6213                 .this_arg = (void*) calls,
6214                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6215                 .free = LDKFeeEstimator_JCalls_free,
6216         };
6217         return ret;
6218 }
6219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
6220         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6221         *res_ptr = LDKFeeEstimator_init(env, clz, o);
6222         return (uint64_t)res_ptr;
6223 }
6224 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) {
6225         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6226         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6227         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6228         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
6229         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6230         return ret_val;
6231 }
6232
6233 typedef struct LDKLogger_JCalls {
6234         atomic_size_t refcnt;
6235         JavaVM *vm;
6236         jweak o;
6237         jmethodID log_meth;
6238 } LDKLogger_JCalls;
6239 static void LDKLogger_JCalls_free(void* this_arg) {
6240         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6241         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6242                 JNIEnv *env;
6243                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6244                 if (get_jenv_res == JNI_EDETACHED) {
6245                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6246                 } else {
6247                         DO_ASSERT(get_jenv_res == JNI_OK);
6248                 }
6249                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6250                 if (get_jenv_res == JNI_EDETACHED) {
6251                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6252                 }
6253                 FREE(j_calls);
6254         }
6255 }
6256 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
6257         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6258         JNIEnv *env;
6259         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6260         if (get_jenv_res == JNI_EDETACHED) {
6261                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6262         } else {
6263                 DO_ASSERT(get_jenv_res == JNI_OK);
6264         }
6265         LDKRecord record_var = *record;
6266         int64_t record_ref = 0;
6267         record_var = Record_clone(&record_var);
6268         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6269         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6270         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
6271         record_ref = (uintptr_t)record_var.inner;
6272         if (record_var.is_owned) {
6273                 record_ref |= 1;
6274         }
6275         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6276         CHECK(obj != NULL);
6277         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
6278         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6279                 (*env)->ExceptionDescribe(env);
6280                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
6281         }
6282         if (get_jenv_res == JNI_EDETACHED) {
6283                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6284         }
6285 }
6286 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
6287         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
6288         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6289 }
6290 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
6291         jclass c = (*env)->GetObjectClass(env, o);
6292         CHECK(c != NULL);
6293         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
6294         atomic_init(&calls->refcnt, 1);
6295         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6296         calls->o = (*env)->NewWeakGlobalRef(env, o);
6297         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
6298         CHECK(calls->log_meth != NULL);
6299
6300         LDKLogger ret = {
6301                 .this_arg = (void*) calls,
6302                 .log = log_LDKLogger_jcall,
6303                 .free = LDKLogger_JCalls_free,
6304         };
6305         return ret;
6306 }
6307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
6308         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
6309         *res_ptr = LDKLogger_init(env, clz, o);
6310         return (uint64_t)res_ptr;
6311 }
6312 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6313         return ThirtyTwoBytes_clone(&owner->a);
6314 }
6315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6316         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6317         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6318         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
6319         return ret_arr;
6320 }
6321
6322 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6323         return &owner->b;
6324 }
6325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6326         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6327         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6328         int64_t ret_ref = 0;
6329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6332         ret_ref = (uintptr_t)ret_var.inner & ~1;
6333         return ret_ref;
6334 }
6335
6336 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6337 CHECK(owner->result_ok);
6338         return &*owner->contents.result;
6339 }
6340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6341         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6342         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
6343         return ret_ret;
6344 }
6345
6346 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6347 CHECK(!owner->result_ok);
6348         return DecodeError_clone(&*owner->contents.err);
6349 }
6350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6351         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6352         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
6353         int64_t ret_ref = 0;
6354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6357         ret_ref = (uintptr_t)ret_var.inner;
6358         if (ret_var.is_owned) {
6359                 ret_ref |= 1;
6360         }
6361         return ret_ref;
6362 }
6363
6364 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6365 CHECK(owner->result_ok);
6366         return ChannelConfig_clone(&*owner->contents.result);
6367 }
6368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6369         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6370         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
6371         int64_t ret_ref = 0;
6372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6375         ret_ref = (uintptr_t)ret_var.inner;
6376         if (ret_var.is_owned) {
6377                 ret_ref |= 1;
6378         }
6379         return ret_ref;
6380 }
6381
6382 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6383 CHECK(!owner->result_ok);
6384         return DecodeError_clone(&*owner->contents.err);
6385 }
6386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6387         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6388         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
6389         int64_t ret_ref = 0;
6390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6393         ret_ref = (uintptr_t)ret_var.inner;
6394         if (ret_var.is_owned) {
6395                 ret_ref |= 1;
6396         }
6397         return ret_ref;
6398 }
6399
6400 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6401 CHECK(owner->result_ok);
6402         return OutPoint_clone(&*owner->contents.result);
6403 }
6404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6405         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6406         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
6407         int64_t ret_ref = 0;
6408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6411         ret_ref = (uintptr_t)ret_var.inner;
6412         if (ret_var.is_owned) {
6413                 ret_ref |= 1;
6414         }
6415         return ret_ref;
6416 }
6417
6418 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6419 CHECK(!owner->result_ok);
6420         return DecodeError_clone(&*owner->contents.err);
6421 }
6422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6423         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6424         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
6425         int64_t ret_ref = 0;
6426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6429         ret_ref = (uintptr_t)ret_var.inner;
6430         if (ret_var.is_owned) {
6431                 ret_ref |= 1;
6432         }
6433         return ret_ref;
6434 }
6435
6436 typedef struct LDKType_JCalls {
6437         atomic_size_t refcnt;
6438         JavaVM *vm;
6439         jweak o;
6440         jmethodID type_id_meth;
6441         jmethodID debug_str_meth;
6442         jmethodID write_meth;
6443 } LDKType_JCalls;
6444 static void LDKType_JCalls_free(void* this_arg) {
6445         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6446         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6447                 JNIEnv *env;
6448                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6449                 if (get_jenv_res == JNI_EDETACHED) {
6450                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6451                 } else {
6452                         DO_ASSERT(get_jenv_res == JNI_OK);
6453                 }
6454                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6455                 if (get_jenv_res == JNI_EDETACHED) {
6456                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6457                 }
6458                 FREE(j_calls);
6459         }
6460 }
6461 uint16_t type_id_LDKType_jcall(const void* this_arg) {
6462         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6463         JNIEnv *env;
6464         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6465         if (get_jenv_res == JNI_EDETACHED) {
6466                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6467         } else {
6468                 DO_ASSERT(get_jenv_res == JNI_OK);
6469         }
6470         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6471         CHECK(obj != NULL);
6472         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
6473         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6474                 (*env)->ExceptionDescribe(env);
6475                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
6476         }
6477         if (get_jenv_res == JNI_EDETACHED) {
6478                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6479         }
6480         return ret;
6481 }
6482 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
6483         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6484         JNIEnv *env;
6485         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6486         if (get_jenv_res == JNI_EDETACHED) {
6487                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6488         } else {
6489                 DO_ASSERT(get_jenv_res == JNI_OK);
6490         }
6491         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6492         CHECK(obj != NULL);
6493         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
6494         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6495                 (*env)->ExceptionDescribe(env);
6496                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
6497         }
6498         LDKStr ret_conv = java_to_owned_str(env, ret);
6499         if (get_jenv_res == JNI_EDETACHED) {
6500                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6501         }
6502         return ret_conv;
6503 }
6504 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
6505         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6506         JNIEnv *env;
6507         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6508         if (get_jenv_res == JNI_EDETACHED) {
6509                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6510         } else {
6511                 DO_ASSERT(get_jenv_res == JNI_OK);
6512         }
6513         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6514         CHECK(obj != NULL);
6515         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6516         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6517                 (*env)->ExceptionDescribe(env);
6518                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
6519         }
6520         LDKCVec_u8Z ret_ref;
6521         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6522         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6523         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6524         if (get_jenv_res == JNI_EDETACHED) {
6525                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6526         }
6527         return ret_ref;
6528 }
6529 static void LDKType_JCalls_cloned(LDKType* new_obj) {
6530         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
6531         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6532 }
6533 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
6534         jclass c = (*env)->GetObjectClass(env, o);
6535         CHECK(c != NULL);
6536         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
6537         atomic_init(&calls->refcnt, 1);
6538         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6539         calls->o = (*env)->NewWeakGlobalRef(env, o);
6540         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
6541         CHECK(calls->type_id_meth != NULL);
6542         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
6543         CHECK(calls->debug_str_meth != NULL);
6544         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6545         CHECK(calls->write_meth != NULL);
6546
6547         LDKType ret = {
6548                 .this_arg = (void*) calls,
6549                 .type_id = type_id_LDKType_jcall,
6550                 .debug_str = debug_str_LDKType_jcall,
6551                 .write = write_LDKType_jcall,
6552                 .cloned = LDKType_JCalls_cloned,
6553                 .free = LDKType_JCalls_free,
6554         };
6555         return ret;
6556 }
6557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
6558         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
6559         *res_ptr = LDKType_init(env, clz, o);
6560         return (uint64_t)res_ptr;
6561 }
6562 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
6563         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6564         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6565         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6566         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
6567         return ret_val;
6568 }
6569
6570 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
6571         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6572         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6573         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6574         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
6575         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
6576         Str_free(ret_str);
6577         return ret_conv;
6578 }
6579
6580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6581         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6582         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6583         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6584         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6585         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6586         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6587         CVec_u8Z_free(ret_var);
6588         return ret_arr;
6589 }
6590
6591 static jclass LDKCOption_TypeZ_Some_class = NULL;
6592 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
6593 static jclass LDKCOption_TypeZ_None_class = NULL;
6594 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
6595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
6596         LDKCOption_TypeZ_Some_class =
6597                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
6598         CHECK(LDKCOption_TypeZ_Some_class != NULL);
6599         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
6600         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
6601         LDKCOption_TypeZ_None_class =
6602                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
6603         CHECK(LDKCOption_TypeZ_None_class != NULL);
6604         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
6605         CHECK(LDKCOption_TypeZ_None_meth != NULL);
6606 }
6607 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6608         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
6609         switch(obj->tag) {
6610                 case LDKCOption_TypeZ_Some: {
6611                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
6612                         *some_ret = Type_clone(&obj->some);
6613                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
6614                 }
6615                 case LDKCOption_TypeZ_None: {
6616                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
6617                 }
6618                 default: abort();
6619         }
6620 }
6621 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6622 CHECK(owner->result_ok);
6623         return COption_TypeZ_clone(&*owner->contents.result);
6624 }
6625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6626         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6627         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
6628         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
6629         int64_t ret_ref = (uintptr_t)ret_copy;
6630         return ret_ref;
6631 }
6632
6633 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6634 CHECK(!owner->result_ok);
6635         return DecodeError_clone(&*owner->contents.err);
6636 }
6637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6638         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6639         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
6640         int64_t ret_ref = 0;
6641         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6642         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6644         ret_ref = (uintptr_t)ret_var.inner;
6645         if (ret_var.is_owned) {
6646                 ret_ref |= 1;
6647         }
6648         return ret_ref;
6649 }
6650
6651 static jclass LDKPaymentError_Invoice_class = NULL;
6652 static jmethodID LDKPaymentError_Invoice_meth = NULL;
6653 static jclass LDKPaymentError_Routing_class = NULL;
6654 static jmethodID LDKPaymentError_Routing_meth = NULL;
6655 static jclass LDKPaymentError_Sending_class = NULL;
6656 static jmethodID LDKPaymentError_Sending_meth = NULL;
6657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
6658         LDKPaymentError_Invoice_class =
6659                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
6660         CHECK(LDKPaymentError_Invoice_class != NULL);
6661         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
6662         CHECK(LDKPaymentError_Invoice_meth != NULL);
6663         LDKPaymentError_Routing_class =
6664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
6665         CHECK(LDKPaymentError_Routing_class != NULL);
6666         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
6667         CHECK(LDKPaymentError_Routing_meth != NULL);
6668         LDKPaymentError_Sending_class =
6669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
6670         CHECK(LDKPaymentError_Sending_class != NULL);
6671         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
6672         CHECK(LDKPaymentError_Sending_meth != NULL);
6673 }
6674 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6675         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6676         switch(obj->tag) {
6677                 case LDKPaymentError_Invoice: {
6678                         LDKStr invoice_str = obj->invoice;
6679                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
6680                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
6681                 }
6682                 case LDKPaymentError_Routing: {
6683                         LDKLightningError routing_var = obj->routing;
6684                         int64_t routing_ref = 0;
6685                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6686                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6687                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
6688                         routing_ref = (uintptr_t)routing_var.inner & ~1;
6689                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
6690                 }
6691                 case LDKPaymentError_Sending: {
6692                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
6693                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
6694                 }
6695                 default: abort();
6696         }
6697 }
6698 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6699 CHECK(owner->result_ok);
6700         return ThirtyTwoBytes_clone(&*owner->contents.result);
6701 }
6702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6703         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6704         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6705         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
6706         return ret_arr;
6707 }
6708
6709 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6710 CHECK(!owner->result_ok);
6711         return PaymentError_clone(&*owner->contents.err);
6712 }
6713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6714         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6715         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
6716         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
6717         int64_t ret_ref = (uintptr_t)ret_copy;
6718         return ret_ref;
6719 }
6720
6721 static inline enum LDKSiPrefix CResult_SiPrefixNoneZ_get_ok(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
6722 CHECK(owner->result_ok);
6723         return SiPrefix_clone(&*owner->contents.result);
6724 }
6725 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6726         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
6727         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixNoneZ_get_ok(owner_conv));
6728         return ret_conv;
6729 }
6730
6731 static inline void CResult_SiPrefixNoneZ_get_err(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
6732 CHECK(!owner->result_ok);
6733         return *owner->contents.err;
6734 }
6735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6736         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
6737         CResult_SiPrefixNoneZ_get_err(owner_conv);
6738 }
6739
6740 static inline struct LDKInvoice CResult_InvoiceNoneZ_get_ok(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
6741 CHECK(owner->result_ok);
6742         return Invoice_clone(&*owner->contents.result);
6743 }
6744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6745         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
6746         LDKInvoice ret_var = CResult_InvoiceNoneZ_get_ok(owner_conv);
6747         int64_t ret_ref = 0;
6748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6751         ret_ref = (uintptr_t)ret_var.inner;
6752         if (ret_var.is_owned) {
6753                 ret_ref |= 1;
6754         }
6755         return ret_ref;
6756 }
6757
6758 static inline void CResult_InvoiceNoneZ_get_err(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
6759 CHECK(!owner->result_ok);
6760         return *owner->contents.err;
6761 }
6762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6763         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
6764         CResult_InvoiceNoneZ_get_err(owner_conv);
6765 }
6766
6767 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceNoneZ_get_ok(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
6768 CHECK(owner->result_ok);
6769         return SignedRawInvoice_clone(&*owner->contents.result);
6770 }
6771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6772         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
6773         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceNoneZ_get_ok(owner_conv);
6774         int64_t ret_ref = 0;
6775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6778         ret_ref = (uintptr_t)ret_var.inner;
6779         if (ret_var.is_owned) {
6780                 ret_ref |= 1;
6781         }
6782         return ret_ref;
6783 }
6784
6785 static inline void CResult_SignedRawInvoiceNoneZ_get_err(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
6786 CHECK(!owner->result_ok);
6787         return *owner->contents.err;
6788 }
6789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6790         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
6791         CResult_SignedRawInvoiceNoneZ_get_err(owner_conv);
6792 }
6793
6794 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6795         return RawInvoice_clone(&owner->a);
6796 }
6797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6798         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6799         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
6800         int64_t ret_ref = 0;
6801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6804         ret_ref = (uintptr_t)ret_var.inner;
6805         if (ret_var.is_owned) {
6806                 ret_ref |= 1;
6807         }
6808         return ret_ref;
6809 }
6810
6811 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6812         return ThirtyTwoBytes_clone(&owner->b);
6813 }
6814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6815         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6816         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6817         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
6818         return ret_arr;
6819 }
6820
6821 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6822         return InvoiceSignature_clone(&owner->c);
6823 }
6824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
6825         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6826         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
6827         int64_t ret_ref = 0;
6828         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6829         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6831         ret_ref = (uintptr_t)ret_var.inner;
6832         if (ret_var.is_owned) {
6833                 ret_ref |= 1;
6834         }
6835         return ret_ref;
6836 }
6837
6838 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6839 CHECK(owner->result_ok);
6840         return PayeePubKey_clone(&*owner->contents.result);
6841 }
6842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6843         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6844         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
6845         int64_t ret_ref = 0;
6846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6849         ret_ref = (uintptr_t)ret_var.inner;
6850         if (ret_var.is_owned) {
6851                 ret_ref |= 1;
6852         }
6853         return ret_ref;
6854 }
6855
6856 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6857 CHECK(!owner->result_ok);
6858         return *owner->contents.err;
6859 }
6860 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6861         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6862         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
6863         return ret_conv;
6864 }
6865
6866 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
6867         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
6868         for (size_t i = 0; i < ret.datalen; i++) {
6869                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
6870         }
6871         return ret;
6872 }
6873 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6874 CHECK(owner->result_ok);
6875         return PositiveTimestamp_clone(&*owner->contents.result);
6876 }
6877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6878         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6879         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6880         int64_t ret_ref = 0;
6881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6884         ret_ref = (uintptr_t)ret_var.inner;
6885         if (ret_var.is_owned) {
6886                 ret_ref |= 1;
6887         }
6888         return ret_ref;
6889 }
6890
6891 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6892 CHECK(!owner->result_ok);
6893         return CreationError_clone(&*owner->contents.err);
6894 }
6895 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6896         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6897         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6898         return ret_conv;
6899 }
6900
6901 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6902 CHECK(owner->result_ok);
6903         return *owner->contents.result;
6904 }
6905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6906         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6907         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6908 }
6909
6910 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6911 CHECK(!owner->result_ok);
6912         return SemanticError_clone(&*owner->contents.err);
6913 }
6914 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6915         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6916         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
6917         return ret_conv;
6918 }
6919
6920 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6921 CHECK(owner->result_ok);
6922         return Invoice_clone(&*owner->contents.result);
6923 }
6924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6925         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6926         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6927         int64_t ret_ref = 0;
6928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6931         ret_ref = (uintptr_t)ret_var.inner;
6932         if (ret_var.is_owned) {
6933                 ret_ref |= 1;
6934         }
6935         return ret_ref;
6936 }
6937
6938 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6939 CHECK(!owner->result_ok);
6940         return SemanticError_clone(&*owner->contents.err);
6941 }
6942 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6943         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6944         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6945         return ret_conv;
6946 }
6947
6948 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6949 CHECK(owner->result_ok);
6950         return Description_clone(&*owner->contents.result);
6951 }
6952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6953         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6954         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6955         int64_t ret_ref = 0;
6956         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6957         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6959         ret_ref = (uintptr_t)ret_var.inner;
6960         if (ret_var.is_owned) {
6961                 ret_ref |= 1;
6962         }
6963         return ret_ref;
6964 }
6965
6966 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6967 CHECK(!owner->result_ok);
6968         return CreationError_clone(&*owner->contents.err);
6969 }
6970 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6971         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6972         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6973         return ret_conv;
6974 }
6975
6976 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6977 CHECK(owner->result_ok);
6978         return PrivateRoute_clone(&*owner->contents.result);
6979 }
6980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6981         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6982         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6983         int64_t ret_ref = 0;
6984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6987         ret_ref = (uintptr_t)ret_var.inner;
6988         if (ret_var.is_owned) {
6989                 ret_ref |= 1;
6990         }
6991         return ret_ref;
6992 }
6993
6994 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6995 CHECK(!owner->result_ok);
6996         return CreationError_clone(&*owner->contents.err);
6997 }
6998 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6999         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7000         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
7001         return ret_conv;
7002 }
7003
7004 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7005 CHECK(owner->result_ok);
7006         return *owner->contents.result;
7007 }
7008 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7009         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7010         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
7011         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7012         return ret_conv;
7013 }
7014
7015 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7016 CHECK(!owner->result_ok);
7017         return *owner->contents.err;
7018 }
7019 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7020         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7021         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
7022         return ret_conv;
7023 }
7024
7025 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7026 CHECK(owner->result_ok);
7027         return ChannelMonitorUpdate_clone(&*owner->contents.result);
7028 }
7029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7030         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7031         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
7032         int64_t ret_ref = 0;
7033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7036         ret_ref = (uintptr_t)ret_var.inner;
7037         if (ret_var.is_owned) {
7038                 ret_ref |= 1;
7039         }
7040         return ret_ref;
7041 }
7042
7043 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7044 CHECK(!owner->result_ok);
7045         return DecodeError_clone(&*owner->contents.err);
7046 }
7047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7048         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7049         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
7050         int64_t ret_ref = 0;
7051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7054         ret_ref = (uintptr_t)ret_var.inner;
7055         if (ret_var.is_owned) {
7056                 ret_ref |= 1;
7057         }
7058         return ret_ref;
7059 }
7060
7061 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
7062 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
7063 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
7064 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
7065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
7066         LDKCOption_MonitorEventZ_Some_class =
7067                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
7068         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
7069         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
7070         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
7071         LDKCOption_MonitorEventZ_None_class =
7072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
7073         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
7074         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
7075         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
7076 }
7077 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7078         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
7079         switch(obj->tag) {
7080                 case LDKCOption_MonitorEventZ_Some: {
7081                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
7082                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
7083                 }
7084                 case LDKCOption_MonitorEventZ_None: {
7085                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
7086                 }
7087                 default: abort();
7088         }
7089 }
7090 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7091 CHECK(owner->result_ok);
7092         return COption_MonitorEventZ_clone(&*owner->contents.result);
7093 }
7094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7095         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7096         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
7097         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
7098         int64_t ret_ref = (uintptr_t)ret_copy;
7099         return ret_ref;
7100 }
7101
7102 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7103 CHECK(!owner->result_ok);
7104         return DecodeError_clone(&*owner->contents.err);
7105 }
7106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7107         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7108         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
7109         int64_t ret_ref = 0;
7110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7113         ret_ref = (uintptr_t)ret_var.inner;
7114         if (ret_var.is_owned) {
7115                 ret_ref |= 1;
7116         }
7117         return ret_ref;
7118 }
7119
7120 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7121 CHECK(owner->result_ok);
7122         return HTLCUpdate_clone(&*owner->contents.result);
7123 }
7124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7125         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7126         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
7127         int64_t ret_ref = 0;
7128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7131         ret_ref = (uintptr_t)ret_var.inner;
7132         if (ret_var.is_owned) {
7133                 ret_ref |= 1;
7134         }
7135         return ret_ref;
7136 }
7137
7138 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7139 CHECK(!owner->result_ok);
7140         return DecodeError_clone(&*owner->contents.err);
7141 }
7142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7143         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7144         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
7145         int64_t ret_ref = 0;
7146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7149         ret_ref = (uintptr_t)ret_var.inner;
7150         if (ret_var.is_owned) {
7151                 ret_ref |= 1;
7152         }
7153         return ret_ref;
7154 }
7155
7156 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7157         return OutPoint_clone(&owner->a);
7158 }
7159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7160         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7161         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
7162         int64_t ret_ref = 0;
7163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7166         ret_ref = (uintptr_t)ret_var.inner;
7167         if (ret_var.is_owned) {
7168                 ret_ref |= 1;
7169         }
7170         return ret_ref;
7171 }
7172
7173 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7174         return CVec_u8Z_clone(&owner->b);
7175 }
7176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7177         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7178         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
7179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7181         CVec_u8Z_free(ret_var);
7182         return ret_arr;
7183 }
7184
7185 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7186         return owner->a;
7187 }
7188 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7189         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7190         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
7191         return ret_val;
7192 }
7193
7194 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7195         return CVec_u8Z_clone(&owner->b);
7196 }
7197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7198         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7199         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
7200         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7201         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7202         CVec_u8Z_free(ret_var);
7203         return ret_arr;
7204 }
7205
7206 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
7207         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
7208         for (size_t i = 0; i < ret.datalen; i++) {
7209                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
7210         }
7211         return ret;
7212 }
7213 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7214         return ThirtyTwoBytes_clone(&owner->a);
7215 }
7216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7217         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7218         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
7220         return ret_arr;
7221 }
7222
7223 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7224         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
7225 }
7226 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7227         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7228         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
7229         int64_tArray ret_arr = NULL;
7230         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7231         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7232         for (size_t v = 0; v < ret_var.datalen; v++) {
7233                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7234                 *ret_conv_21_conv = ret_var.data[v];
7235                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
7236         }
7237         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7238         FREE(ret_var.data);
7239         return ret_arr;
7240 }
7241
7242 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
7243         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 };
7244         for (size_t i = 0; i < ret.datalen; i++) {
7245                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
7246         }
7247         return ret;
7248 }
7249 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
7250         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
7251         for (size_t i = 0; i < ret.datalen; i++) {
7252                 ret.data[i] = Event_clone(&orig->data[i]);
7253         }
7254         return ret;
7255 }
7256 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7257         return owner->a;
7258 }
7259 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7260         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7261         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
7262         return ret_val;
7263 }
7264
7265 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7266         return TxOut_clone(&owner->b);
7267 }
7268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7269         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7270         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7271         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
7272         return (int64_t)ret_ref;
7273 }
7274
7275 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
7276         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
7277         for (size_t i = 0; i < ret.datalen; i++) {
7278                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
7279         }
7280         return ret;
7281 }
7282 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7283         return ThirtyTwoBytes_clone(&owner->a);
7284 }
7285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7286         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
7289         return ret_arr;
7290 }
7291
7292 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7293         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
7294 }
7295 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7296         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7297         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
7298         int64_tArray ret_arr = NULL;
7299         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7300         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7301         for (size_t u = 0; u < ret_var.datalen; u++) {
7302                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7303                 *ret_conv_20_conv = ret_var.data[u];
7304                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
7305         }
7306         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7307         FREE(ret_var.data);
7308         return ret_arr;
7309 }
7310
7311 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
7312         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 };
7313         for (size_t i = 0; i < ret.datalen; i++) {
7314                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
7315         }
7316         return ret;
7317 }
7318 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
7319 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
7320 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
7321 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
7322 static jclass LDKBalance_ContentiousClaimable_class = NULL;
7323 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
7324 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
7325 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
7326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
7327         LDKBalance_ClaimableOnChannelClose_class =
7328                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
7329         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
7330         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
7331         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
7332         LDKBalance_ClaimableAwaitingConfirmations_class =
7333                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
7334         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
7335         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
7336         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
7337         LDKBalance_ContentiousClaimable_class =
7338                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
7339         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
7340         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
7341         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
7342         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
7343                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
7344         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
7345         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
7346         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
7347 }
7348 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7349         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
7350         switch(obj->tag) {
7351                 case LDKBalance_ClaimableOnChannelClose: {
7352                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
7353                 }
7354                 case LDKBalance_ClaimableAwaitingConfirmations: {
7355                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
7356                 }
7357                 case LDKBalance_ContentiousClaimable: {
7358                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
7359                 }
7360                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
7361                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height);
7362                 }
7363                 default: abort();
7364         }
7365 }
7366 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
7367         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
7368         for (size_t i = 0; i < ret.datalen; i++) {
7369                 ret.data[i] = Balance_clone(&orig->data[i]);
7370         }
7371         return ret;
7372 }
7373 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7374 CHECK(owner->result_ok);
7375         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
7376 }
7377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7378         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7379         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7380         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
7381         return ((int64_t)ret_conv);
7382 }
7383
7384 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7385 CHECK(!owner->result_ok);
7386         return DecodeError_clone(&*owner->contents.err);
7387 }
7388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7389         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7390         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
7391         int64_t ret_ref = 0;
7392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7395         ret_ref = (uintptr_t)ret_var.inner;
7396         if (ret_var.is_owned) {
7397                 ret_ref |= 1;
7398         }
7399         return ret_ref;
7400 }
7401
7402 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7403 CHECK(owner->result_ok);
7404         return *owner->contents.result;
7405 }
7406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7407         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7408         CResult_NoneLightningErrorZ_get_ok(owner_conv);
7409 }
7410
7411 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7412 CHECK(!owner->result_ok);
7413         return LightningError_clone(&*owner->contents.err);
7414 }
7415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7416         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7417         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
7418         int64_t ret_ref = 0;
7419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7422         ret_ref = (uintptr_t)ret_var.inner;
7423         if (ret_var.is_owned) {
7424                 ret_ref |= 1;
7425         }
7426         return ret_ref;
7427 }
7428
7429 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7430         return owner->a;
7431 }
7432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7433         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7434         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
7435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
7436         return ret_arr;
7437 }
7438
7439 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7440         return Type_clone(&owner->b);
7441 }
7442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7443         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7444         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
7445         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
7446         return (int64_t)ret_ret;
7447 }
7448
7449 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
7450         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
7451         for (size_t i = 0; i < ret.datalen; i++) {
7452                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
7453         }
7454         return ret;
7455 }
7456 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7457 CHECK(owner->result_ok);
7458         return *owner->contents.result;
7459 }
7460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7461         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7462         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
7463         return ret_val;
7464 }
7465
7466 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7467 CHECK(!owner->result_ok);
7468         return LightningError_clone(&*owner->contents.err);
7469 }
7470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7471         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7472         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
7473         int64_t ret_ref = 0;
7474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7477         ret_ref = (uintptr_t)ret_var.inner;
7478         if (ret_var.is_owned) {
7479                 ret_ref |= 1;
7480         }
7481         return ret_ref;
7482 }
7483
7484 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7485         return ChannelAnnouncement_clone(&owner->a);
7486 }
7487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7488         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7489         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
7490         int64_t ret_ref = 0;
7491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7494         ret_ref = (uintptr_t)ret_var.inner;
7495         if (ret_var.is_owned) {
7496                 ret_ref |= 1;
7497         }
7498         return ret_ref;
7499 }
7500
7501 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7502         return ChannelUpdate_clone(&owner->b);
7503 }
7504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7505         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7506         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
7507         int64_t ret_ref = 0;
7508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7511         ret_ref = (uintptr_t)ret_var.inner;
7512         if (ret_var.is_owned) {
7513                 ret_ref |= 1;
7514         }
7515         return ret_ref;
7516 }
7517
7518 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7519         return ChannelUpdate_clone(&owner->c);
7520 }
7521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7522         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7523         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
7524         int64_t ret_ref = 0;
7525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7528         ret_ref = (uintptr_t)ret_var.inner;
7529         if (ret_var.is_owned) {
7530                 ret_ref |= 1;
7531         }
7532         return ret_ref;
7533 }
7534
7535 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
7536         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
7537         for (size_t i = 0; i < ret.datalen; i++) {
7538                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
7539         }
7540         return ret;
7541 }
7542 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
7543         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
7544         for (size_t i = 0; i < ret.datalen; i++) {
7545                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
7546         }
7547         return ret;
7548 }
7549 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7550 CHECK(owner->result_ok);
7551         return CVec_u8Z_clone(&*owner->contents.result);
7552 }
7553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7554         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7555         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
7556         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7557         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7558         CVec_u8Z_free(ret_var);
7559         return ret_arr;
7560 }
7561
7562 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7563 CHECK(!owner->result_ok);
7564         return PeerHandleError_clone(&*owner->contents.err);
7565 }
7566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7567         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7568         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
7569         int64_t ret_ref = 0;
7570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7573         ret_ref = (uintptr_t)ret_var.inner;
7574         if (ret_var.is_owned) {
7575                 ret_ref |= 1;
7576         }
7577         return ret_ref;
7578 }
7579
7580 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7581 CHECK(owner->result_ok);
7582         return *owner->contents.result;
7583 }
7584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7585         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7586         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
7587 }
7588
7589 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7590 CHECK(!owner->result_ok);
7591         return PeerHandleError_clone(&*owner->contents.err);
7592 }
7593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7594         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7595         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
7596         int64_t ret_ref = 0;
7597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7600         ret_ref = (uintptr_t)ret_var.inner;
7601         if (ret_var.is_owned) {
7602                 ret_ref |= 1;
7603         }
7604         return ret_ref;
7605 }
7606
7607 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7608 CHECK(owner->result_ok);
7609         return *owner->contents.result;
7610 }
7611 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7612         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7613         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
7614         return ret_val;
7615 }
7616
7617 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7618 CHECK(!owner->result_ok);
7619         return PeerHandleError_clone(&*owner->contents.err);
7620 }
7621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7622         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7623         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
7624         int64_t ret_ref = 0;
7625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7628         ret_ref = (uintptr_t)ret_var.inner;
7629         if (ret_var.is_owned) {
7630                 ret_ref |= 1;
7631         }
7632         return ret_ref;
7633 }
7634
7635 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7636 CHECK(owner->result_ok);
7637         return NodeId_clone(&*owner->contents.result);
7638 }
7639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7640         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7641         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
7642         int64_t ret_ref = 0;
7643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7646         ret_ref = (uintptr_t)ret_var.inner;
7647         if (ret_var.is_owned) {
7648                 ret_ref |= 1;
7649         }
7650         return ret_ref;
7651 }
7652
7653 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7654 CHECK(!owner->result_ok);
7655         return DecodeError_clone(&*owner->contents.err);
7656 }
7657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7658         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7659         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
7660         int64_t ret_ref = 0;
7661         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7662         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7664         ret_ref = (uintptr_t)ret_var.inner;
7665         if (ret_var.is_owned) {
7666                 ret_ref |= 1;
7667         }
7668         return ret_ref;
7669 }
7670
7671 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
7672 CHECK(owner->result_ok);
7673         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
7674 }
7675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7676         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
7677         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
7678         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
7679         int64_t ret_ref = (uintptr_t)ret_copy;
7680         return ret_ref;
7681 }
7682
7683 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
7684 CHECK(!owner->result_ok);
7685         return DecodeError_clone(&*owner->contents.err);
7686 }
7687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7688         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
7689         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
7690         int64_t ret_ref = 0;
7691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7694         ret_ref = (uintptr_t)ret_var.inner;
7695         if (ret_var.is_owned) {
7696                 ret_ref |= 1;
7697         }
7698         return ret_ref;
7699 }
7700
7701 typedef struct LDKAccess_JCalls {
7702         atomic_size_t refcnt;
7703         JavaVM *vm;
7704         jweak o;
7705         jmethodID get_utxo_meth;
7706 } LDKAccess_JCalls;
7707 static void LDKAccess_JCalls_free(void* this_arg) {
7708         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
7709         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7710                 JNIEnv *env;
7711                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7712                 if (get_jenv_res == JNI_EDETACHED) {
7713                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7714                 } else {
7715                         DO_ASSERT(get_jenv_res == JNI_OK);
7716                 }
7717                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7718                 if (get_jenv_res == JNI_EDETACHED) {
7719                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7720                 }
7721                 FREE(j_calls);
7722         }
7723 }
7724 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
7725         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
7726         JNIEnv *env;
7727         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7728         if (get_jenv_res == JNI_EDETACHED) {
7729                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7730         } else {
7731                 DO_ASSERT(get_jenv_res == JNI_OK);
7732         }
7733         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
7734         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
7735         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7736         CHECK(obj != NULL);
7737         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
7738         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7739                 (*env)->ExceptionDescribe(env);
7740                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
7741         }
7742         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7743         CHECK_ACCESS(ret_ptr);
7744         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
7745         FREE((void*)ret);
7746         if (get_jenv_res == JNI_EDETACHED) {
7747                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7748         }
7749         return ret_conv;
7750 }
7751 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
7752         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
7753         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7754 }
7755 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
7756         jclass c = (*env)->GetObjectClass(env, o);
7757         CHECK(c != NULL);
7758         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
7759         atomic_init(&calls->refcnt, 1);
7760         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7761         calls->o = (*env)->NewWeakGlobalRef(env, o);
7762         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
7763         CHECK(calls->get_utxo_meth != NULL);
7764
7765         LDKAccess ret = {
7766                 .this_arg = (void*) calls,
7767                 .get_utxo = get_utxo_LDKAccess_jcall,
7768                 .free = LDKAccess_JCalls_free,
7769         };
7770         return ret;
7771 }
7772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
7773         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
7774         *res_ptr = LDKAccess_init(env, clz, o);
7775         return (uint64_t)res_ptr;
7776 }
7777 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) {
7778         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7779         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7780         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
7781         unsigned char genesis_hash_arr[32];
7782         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
7783         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
7784         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
7785         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7786         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
7787         return (int64_t)ret_conv;
7788 }
7789
7790 static jclass LDKCOption_AccessZ_Some_class = NULL;
7791 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
7792 static jclass LDKCOption_AccessZ_None_class = NULL;
7793 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
7794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
7795         LDKCOption_AccessZ_Some_class =
7796                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
7797         CHECK(LDKCOption_AccessZ_Some_class != NULL);
7798         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
7799         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
7800         LDKCOption_AccessZ_None_class =
7801                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
7802         CHECK(LDKCOption_AccessZ_None_class != NULL);
7803         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
7804         CHECK(LDKCOption_AccessZ_None_meth != NULL);
7805 }
7806 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7807         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
7808         switch(obj->tag) {
7809                 case LDKCOption_AccessZ_Some: {
7810                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
7811                         *some_ret = obj->some;
7812                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7813                         if ((*some_ret).free == LDKAccess_JCalls_free) {
7814                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7815                                 LDKAccess_JCalls_cloned(&(*some_ret));
7816                         }
7817                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
7818                 }
7819                 case LDKCOption_AccessZ_None: {
7820                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
7821                 }
7822                 default: abort();
7823         }
7824 }
7825 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
7826 CHECK(owner->result_ok);
7827         return ChannelUpdateInfo_clone(&*owner->contents.result);
7828 }
7829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7830         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
7831         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
7832         int64_t ret_ref = 0;
7833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7836         ret_ref = (uintptr_t)ret_var.inner;
7837         if (ret_var.is_owned) {
7838                 ret_ref |= 1;
7839         }
7840         return ret_ref;
7841 }
7842
7843 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
7844 CHECK(!owner->result_ok);
7845         return DecodeError_clone(&*owner->contents.err);
7846 }
7847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7848         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
7849         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
7850         int64_t ret_ref = 0;
7851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7854         ret_ref = (uintptr_t)ret_var.inner;
7855         if (ret_var.is_owned) {
7856                 ret_ref |= 1;
7857         }
7858         return ret_ref;
7859 }
7860
7861 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
7862 CHECK(owner->result_ok);
7863         return ChannelInfo_clone(&*owner->contents.result);
7864 }
7865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7866         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
7867         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
7868         int64_t ret_ref = 0;
7869         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7870         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7872         ret_ref = (uintptr_t)ret_var.inner;
7873         if (ret_var.is_owned) {
7874                 ret_ref |= 1;
7875         }
7876         return ret_ref;
7877 }
7878
7879 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
7880 CHECK(!owner->result_ok);
7881         return DecodeError_clone(&*owner->contents.err);
7882 }
7883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7884         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
7885         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
7886         int64_t ret_ref = 0;
7887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7890         ret_ref = (uintptr_t)ret_var.inner;
7891         if (ret_var.is_owned) {
7892                 ret_ref |= 1;
7893         }
7894         return ret_ref;
7895 }
7896
7897 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
7898 CHECK(owner->result_ok);
7899         return RoutingFees_clone(&*owner->contents.result);
7900 }
7901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7902         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
7903         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
7904         int64_t ret_ref = 0;
7905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7908         ret_ref = (uintptr_t)ret_var.inner;
7909         if (ret_var.is_owned) {
7910                 ret_ref |= 1;
7911         }
7912         return ret_ref;
7913 }
7914
7915 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
7916 CHECK(!owner->result_ok);
7917         return DecodeError_clone(&*owner->contents.err);
7918 }
7919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7920         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
7921         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
7922         int64_t ret_ref = 0;
7923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7926         ret_ref = (uintptr_t)ret_var.inner;
7927         if (ret_var.is_owned) {
7928                 ret_ref |= 1;
7929         }
7930         return ret_ref;
7931 }
7932
7933 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
7934 CHECK(owner->result_ok);
7935         return NodeAnnouncementInfo_clone(&*owner->contents.result);
7936 }
7937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7938         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
7939         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
7940         int64_t ret_ref = 0;
7941         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7942         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7944         ret_ref = (uintptr_t)ret_var.inner;
7945         if (ret_var.is_owned) {
7946                 ret_ref |= 1;
7947         }
7948         return ret_ref;
7949 }
7950
7951 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
7952 CHECK(!owner->result_ok);
7953         return DecodeError_clone(&*owner->contents.err);
7954 }
7955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7956         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
7957         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
7958         int64_t ret_ref = 0;
7959         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7960         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7962         ret_ref = (uintptr_t)ret_var.inner;
7963         if (ret_var.is_owned) {
7964                 ret_ref |= 1;
7965         }
7966         return ret_ref;
7967 }
7968
7969 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
7970         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
7971         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
7972         return ret;
7973 }
7974 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
7975 CHECK(owner->result_ok);
7976         return NodeInfo_clone(&*owner->contents.result);
7977 }
7978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7979         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
7980         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
7981         int64_t ret_ref = 0;
7982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7985         ret_ref = (uintptr_t)ret_var.inner;
7986         if (ret_var.is_owned) {
7987                 ret_ref |= 1;
7988         }
7989         return ret_ref;
7990 }
7991
7992 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
7993 CHECK(!owner->result_ok);
7994         return DecodeError_clone(&*owner->contents.err);
7995 }
7996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7997         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
7998         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
7999         int64_t ret_ref = 0;
8000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8003         ret_ref = (uintptr_t)ret_var.inner;
8004         if (ret_var.is_owned) {
8005                 ret_ref |= 1;
8006         }
8007         return ret_ref;
8008 }
8009
8010 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
8011 CHECK(owner->result_ok);
8012         return NetworkGraph_clone(&*owner->contents.result);
8013 }
8014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8015         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
8016         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
8017         int64_t ret_ref = 0;
8018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8021         ret_ref = (uintptr_t)ret_var.inner;
8022         if (ret_var.is_owned) {
8023                 ret_ref |= 1;
8024         }
8025         return ret_ref;
8026 }
8027
8028 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
8029 CHECK(!owner->result_ok);
8030         return DecodeError_clone(&*owner->contents.err);
8031 }
8032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8033         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
8034         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
8035         int64_t ret_ref = 0;
8036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8039         ret_ref = (uintptr_t)ret_var.inner;
8040         if (ret_var.is_owned) {
8041                 ret_ref |= 1;
8042         }
8043         return ret_ref;
8044 }
8045
8046 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
8047 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
8048 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
8049 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
8050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
8051         LDKCOption_CVec_NetAddressZZ_Some_class =
8052                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
8053         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
8054         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
8055         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
8056         LDKCOption_CVec_NetAddressZZ_None_class =
8057                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
8058         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
8059         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
8060         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
8061 }
8062 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8063         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
8064         switch(obj->tag) {
8065                 case LDKCOption_CVec_NetAddressZZ_Some: {
8066                         LDKCVec_NetAddressZ some_var = obj->some;
8067                         int64_tArray some_arr = NULL;
8068                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
8069                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
8070                         for (size_t m = 0; m < some_var.datalen; m++) {
8071                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
8072                                 some_arr_ptr[m] = some_conv_12_ref;
8073                         }
8074                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
8075                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
8076                 }
8077                 case LDKCOption_CVec_NetAddressZZ_None: {
8078                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
8079                 }
8080                 default: abort();
8081         }
8082 }
8083 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8084 CHECK(owner->result_ok);
8085         return NetAddress_clone(&*owner->contents.result);
8086 }
8087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8088         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8089         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8090         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8091         int64_t ret_ref = (uintptr_t)ret_copy;
8092         return ret_ref;
8093 }
8094
8095 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8096 CHECK(!owner->result_ok);
8097         return DecodeError_clone(&*owner->contents.err);
8098 }
8099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8100         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8101         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8102         int64_t ret_ref = 0;
8103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8106         ret_ref = (uintptr_t)ret_var.inner;
8107         if (ret_var.is_owned) {
8108                 ret_ref |= 1;
8109         }
8110         return ret_ref;
8111 }
8112
8113 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8114         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8115         for (size_t i = 0; i < ret.datalen; i++) {
8116                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8117         }
8118         return ret;
8119 }
8120 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8121         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8122         for (size_t i = 0; i < ret.datalen; i++) {
8123                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8124         }
8125         return ret;
8126 }
8127 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8128         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8129         for (size_t i = 0; i < ret.datalen; i++) {
8130                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8131         }
8132         return ret;
8133 }
8134 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8135         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8136         for (size_t i = 0; i < ret.datalen; i++) {
8137                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8138         }
8139         return ret;
8140 }
8141 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8142 CHECK(owner->result_ok);
8143         return AcceptChannel_clone(&*owner->contents.result);
8144 }
8145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8146         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8147         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8148         int64_t ret_ref = 0;
8149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8152         ret_ref = (uintptr_t)ret_var.inner;
8153         if (ret_var.is_owned) {
8154                 ret_ref |= 1;
8155         }
8156         return ret_ref;
8157 }
8158
8159 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8160 CHECK(!owner->result_ok);
8161         return DecodeError_clone(&*owner->contents.err);
8162 }
8163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8164         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8165         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8166         int64_t ret_ref = 0;
8167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8170         ret_ref = (uintptr_t)ret_var.inner;
8171         if (ret_var.is_owned) {
8172                 ret_ref |= 1;
8173         }
8174         return ret_ref;
8175 }
8176
8177 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8178 CHECK(owner->result_ok);
8179         return AnnouncementSignatures_clone(&*owner->contents.result);
8180 }
8181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8182         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8183         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8184         int64_t ret_ref = 0;
8185         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8186         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8188         ret_ref = (uintptr_t)ret_var.inner;
8189         if (ret_var.is_owned) {
8190                 ret_ref |= 1;
8191         }
8192         return ret_ref;
8193 }
8194
8195 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8196 CHECK(!owner->result_ok);
8197         return DecodeError_clone(&*owner->contents.err);
8198 }
8199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8200         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8201         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8202         int64_t ret_ref = 0;
8203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8206         ret_ref = (uintptr_t)ret_var.inner;
8207         if (ret_var.is_owned) {
8208                 ret_ref |= 1;
8209         }
8210         return ret_ref;
8211 }
8212
8213 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8214 CHECK(owner->result_ok);
8215         return ChannelReestablish_clone(&*owner->contents.result);
8216 }
8217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8218         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8219         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8220         int64_t ret_ref = 0;
8221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8224         ret_ref = (uintptr_t)ret_var.inner;
8225         if (ret_var.is_owned) {
8226                 ret_ref |= 1;
8227         }
8228         return ret_ref;
8229 }
8230
8231 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8232 CHECK(!owner->result_ok);
8233         return DecodeError_clone(&*owner->contents.err);
8234 }
8235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8236         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8237         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8238         int64_t ret_ref = 0;
8239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8242         ret_ref = (uintptr_t)ret_var.inner;
8243         if (ret_var.is_owned) {
8244                 ret_ref |= 1;
8245         }
8246         return ret_ref;
8247 }
8248
8249 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8250 CHECK(owner->result_ok);
8251         return ClosingSigned_clone(&*owner->contents.result);
8252 }
8253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8254         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8255         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8256         int64_t ret_ref = 0;
8257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8260         ret_ref = (uintptr_t)ret_var.inner;
8261         if (ret_var.is_owned) {
8262                 ret_ref |= 1;
8263         }
8264         return ret_ref;
8265 }
8266
8267 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8268 CHECK(!owner->result_ok);
8269         return DecodeError_clone(&*owner->contents.err);
8270 }
8271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8272         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8273         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8274         int64_t ret_ref = 0;
8275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8278         ret_ref = (uintptr_t)ret_var.inner;
8279         if (ret_var.is_owned) {
8280                 ret_ref |= 1;
8281         }
8282         return ret_ref;
8283 }
8284
8285 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8286 CHECK(owner->result_ok);
8287         return ClosingSignedFeeRange_clone(&*owner->contents.result);
8288 }
8289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8290         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8291         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8292         int64_t ret_ref = 0;
8293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8296         ret_ref = (uintptr_t)ret_var.inner;
8297         if (ret_var.is_owned) {
8298                 ret_ref |= 1;
8299         }
8300         return ret_ref;
8301 }
8302
8303 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8304 CHECK(!owner->result_ok);
8305         return DecodeError_clone(&*owner->contents.err);
8306 }
8307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8308         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8309         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8310         int64_t ret_ref = 0;
8311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8314         ret_ref = (uintptr_t)ret_var.inner;
8315         if (ret_var.is_owned) {
8316                 ret_ref |= 1;
8317         }
8318         return ret_ref;
8319 }
8320
8321 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8322 CHECK(owner->result_ok);
8323         return CommitmentSigned_clone(&*owner->contents.result);
8324 }
8325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8326         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8327         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8328         int64_t ret_ref = 0;
8329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8332         ret_ref = (uintptr_t)ret_var.inner;
8333         if (ret_var.is_owned) {
8334                 ret_ref |= 1;
8335         }
8336         return ret_ref;
8337 }
8338
8339 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8340 CHECK(!owner->result_ok);
8341         return DecodeError_clone(&*owner->contents.err);
8342 }
8343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8344         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8345         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8346         int64_t ret_ref = 0;
8347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8350         ret_ref = (uintptr_t)ret_var.inner;
8351         if (ret_var.is_owned) {
8352                 ret_ref |= 1;
8353         }
8354         return ret_ref;
8355 }
8356
8357 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8358 CHECK(owner->result_ok);
8359         return FundingCreated_clone(&*owner->contents.result);
8360 }
8361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8362         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8363         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8364         int64_t ret_ref = 0;
8365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8368         ret_ref = (uintptr_t)ret_var.inner;
8369         if (ret_var.is_owned) {
8370                 ret_ref |= 1;
8371         }
8372         return ret_ref;
8373 }
8374
8375 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8376 CHECK(!owner->result_ok);
8377         return DecodeError_clone(&*owner->contents.err);
8378 }
8379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8380         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8381         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8382         int64_t ret_ref = 0;
8383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8386         ret_ref = (uintptr_t)ret_var.inner;
8387         if (ret_var.is_owned) {
8388                 ret_ref |= 1;
8389         }
8390         return ret_ref;
8391 }
8392
8393 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8394 CHECK(owner->result_ok);
8395         return FundingSigned_clone(&*owner->contents.result);
8396 }
8397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8398         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8399         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8400         int64_t ret_ref = 0;
8401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8404         ret_ref = (uintptr_t)ret_var.inner;
8405         if (ret_var.is_owned) {
8406                 ret_ref |= 1;
8407         }
8408         return ret_ref;
8409 }
8410
8411 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8412 CHECK(!owner->result_ok);
8413         return DecodeError_clone(&*owner->contents.err);
8414 }
8415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8416         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8417         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8418         int64_t ret_ref = 0;
8419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8422         ret_ref = (uintptr_t)ret_var.inner;
8423         if (ret_var.is_owned) {
8424                 ret_ref |= 1;
8425         }
8426         return ret_ref;
8427 }
8428
8429 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8430 CHECK(owner->result_ok);
8431         return FundingLocked_clone(&*owner->contents.result);
8432 }
8433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8434         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8435         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
8436         int64_t ret_ref = 0;
8437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8440         ret_ref = (uintptr_t)ret_var.inner;
8441         if (ret_var.is_owned) {
8442                 ret_ref |= 1;
8443         }
8444         return ret_ref;
8445 }
8446
8447 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8448 CHECK(!owner->result_ok);
8449         return DecodeError_clone(&*owner->contents.err);
8450 }
8451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8452         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8453         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
8454         int64_t ret_ref = 0;
8455         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8456         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8458         ret_ref = (uintptr_t)ret_var.inner;
8459         if (ret_var.is_owned) {
8460                 ret_ref |= 1;
8461         }
8462         return ret_ref;
8463 }
8464
8465 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8466 CHECK(owner->result_ok);
8467         return Init_clone(&*owner->contents.result);
8468 }
8469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8470         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8471         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
8472         int64_t ret_ref = 0;
8473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8476         ret_ref = (uintptr_t)ret_var.inner;
8477         if (ret_var.is_owned) {
8478                 ret_ref |= 1;
8479         }
8480         return ret_ref;
8481 }
8482
8483 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8484 CHECK(!owner->result_ok);
8485         return DecodeError_clone(&*owner->contents.err);
8486 }
8487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8488         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8489         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
8490         int64_t ret_ref = 0;
8491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8494         ret_ref = (uintptr_t)ret_var.inner;
8495         if (ret_var.is_owned) {
8496                 ret_ref |= 1;
8497         }
8498         return ret_ref;
8499 }
8500
8501 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8502 CHECK(owner->result_ok);
8503         return OpenChannel_clone(&*owner->contents.result);
8504 }
8505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8506         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8507         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8508         int64_t ret_ref = 0;
8509         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8510         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8512         ret_ref = (uintptr_t)ret_var.inner;
8513         if (ret_var.is_owned) {
8514                 ret_ref |= 1;
8515         }
8516         return ret_ref;
8517 }
8518
8519 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8520 CHECK(!owner->result_ok);
8521         return DecodeError_clone(&*owner->contents.err);
8522 }
8523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8524         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8525         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8526         int64_t ret_ref = 0;
8527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8530         ret_ref = (uintptr_t)ret_var.inner;
8531         if (ret_var.is_owned) {
8532                 ret_ref |= 1;
8533         }
8534         return ret_ref;
8535 }
8536
8537 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8538 CHECK(owner->result_ok);
8539         return RevokeAndACK_clone(&*owner->contents.result);
8540 }
8541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8542         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8543         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8544         int64_t ret_ref = 0;
8545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8548         ret_ref = (uintptr_t)ret_var.inner;
8549         if (ret_var.is_owned) {
8550                 ret_ref |= 1;
8551         }
8552         return ret_ref;
8553 }
8554
8555 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8556 CHECK(!owner->result_ok);
8557         return DecodeError_clone(&*owner->contents.err);
8558 }
8559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8560         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8561         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8562         int64_t ret_ref = 0;
8563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8566         ret_ref = (uintptr_t)ret_var.inner;
8567         if (ret_var.is_owned) {
8568                 ret_ref |= 1;
8569         }
8570         return ret_ref;
8571 }
8572
8573 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8574 CHECK(owner->result_ok);
8575         return Shutdown_clone(&*owner->contents.result);
8576 }
8577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8578         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8579         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
8580         int64_t ret_ref = 0;
8581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8584         ret_ref = (uintptr_t)ret_var.inner;
8585         if (ret_var.is_owned) {
8586                 ret_ref |= 1;
8587         }
8588         return ret_ref;
8589 }
8590
8591 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8592 CHECK(!owner->result_ok);
8593         return DecodeError_clone(&*owner->contents.err);
8594 }
8595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8596         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8597         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
8598         int64_t ret_ref = 0;
8599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8602         ret_ref = (uintptr_t)ret_var.inner;
8603         if (ret_var.is_owned) {
8604                 ret_ref |= 1;
8605         }
8606         return ret_ref;
8607 }
8608
8609 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8610 CHECK(owner->result_ok);
8611         return UpdateFailHTLC_clone(&*owner->contents.result);
8612 }
8613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8614         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8615         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
8616         int64_t ret_ref = 0;
8617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8620         ret_ref = (uintptr_t)ret_var.inner;
8621         if (ret_var.is_owned) {
8622                 ret_ref |= 1;
8623         }
8624         return ret_ref;
8625 }
8626
8627 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8628 CHECK(!owner->result_ok);
8629         return DecodeError_clone(&*owner->contents.err);
8630 }
8631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8632         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8633         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
8634         int64_t ret_ref = 0;
8635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8638         ret_ref = (uintptr_t)ret_var.inner;
8639         if (ret_var.is_owned) {
8640                 ret_ref |= 1;
8641         }
8642         return ret_ref;
8643 }
8644
8645 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8646 CHECK(owner->result_ok);
8647         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
8648 }
8649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8650         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8651         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
8652         int64_t ret_ref = 0;
8653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8656         ret_ref = (uintptr_t)ret_var.inner;
8657         if (ret_var.is_owned) {
8658                 ret_ref |= 1;
8659         }
8660         return ret_ref;
8661 }
8662
8663 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8664 CHECK(!owner->result_ok);
8665         return DecodeError_clone(&*owner->contents.err);
8666 }
8667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8668         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8669         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
8670         int64_t ret_ref = 0;
8671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8674         ret_ref = (uintptr_t)ret_var.inner;
8675         if (ret_var.is_owned) {
8676                 ret_ref |= 1;
8677         }
8678         return ret_ref;
8679 }
8680
8681 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8682 CHECK(owner->result_ok);
8683         return UpdateFee_clone(&*owner->contents.result);
8684 }
8685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8686         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
8687         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(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 struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8700 CHECK(!owner->result_ok);
8701         return DecodeError_clone(&*owner->contents.err);
8702 }
8703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8704         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
8705         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
8706         int64_t ret_ref = 0;
8707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8710         ret_ref = (uintptr_t)ret_var.inner;
8711         if (ret_var.is_owned) {
8712                 ret_ref |= 1;
8713         }
8714         return ret_ref;
8715 }
8716
8717 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8718 CHECK(owner->result_ok);
8719         return UpdateFulfillHTLC_clone(&*owner->contents.result);
8720 }
8721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8722         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
8723         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
8724         int64_t ret_ref = 0;
8725         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8726         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8728         ret_ref = (uintptr_t)ret_var.inner;
8729         if (ret_var.is_owned) {
8730                 ret_ref |= 1;
8731         }
8732         return ret_ref;
8733 }
8734
8735 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8736 CHECK(!owner->result_ok);
8737         return DecodeError_clone(&*owner->contents.err);
8738 }
8739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8740         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
8741         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
8742         int64_t ret_ref = 0;
8743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8746         ret_ref = (uintptr_t)ret_var.inner;
8747         if (ret_var.is_owned) {
8748                 ret_ref |= 1;
8749         }
8750         return ret_ref;
8751 }
8752
8753 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8754 CHECK(owner->result_ok);
8755         return UpdateAddHTLC_clone(&*owner->contents.result);
8756 }
8757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8758         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
8759         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
8760         int64_t ret_ref = 0;
8761         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8762         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8764         ret_ref = (uintptr_t)ret_var.inner;
8765         if (ret_var.is_owned) {
8766                 ret_ref |= 1;
8767         }
8768         return ret_ref;
8769 }
8770
8771 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8772 CHECK(!owner->result_ok);
8773         return DecodeError_clone(&*owner->contents.err);
8774 }
8775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8776         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
8777         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
8778         int64_t ret_ref = 0;
8779         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8780         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8782         ret_ref = (uintptr_t)ret_var.inner;
8783         if (ret_var.is_owned) {
8784                 ret_ref |= 1;
8785         }
8786         return ret_ref;
8787 }
8788
8789 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8790 CHECK(owner->result_ok);
8791         return Ping_clone(&*owner->contents.result);
8792 }
8793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8794         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
8795         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
8796         int64_t ret_ref = 0;
8797         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8798         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8800         ret_ref = (uintptr_t)ret_var.inner;
8801         if (ret_var.is_owned) {
8802                 ret_ref |= 1;
8803         }
8804         return ret_ref;
8805 }
8806
8807 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8808 CHECK(!owner->result_ok);
8809         return DecodeError_clone(&*owner->contents.err);
8810 }
8811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8812         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
8813         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
8814         int64_t ret_ref = 0;
8815         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8816         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8818         ret_ref = (uintptr_t)ret_var.inner;
8819         if (ret_var.is_owned) {
8820                 ret_ref |= 1;
8821         }
8822         return ret_ref;
8823 }
8824
8825 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8826 CHECK(owner->result_ok);
8827         return Pong_clone(&*owner->contents.result);
8828 }
8829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8830         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
8831         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
8832         int64_t ret_ref = 0;
8833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8836         ret_ref = (uintptr_t)ret_var.inner;
8837         if (ret_var.is_owned) {
8838                 ret_ref |= 1;
8839         }
8840         return ret_ref;
8841 }
8842
8843 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8844 CHECK(!owner->result_ok);
8845         return DecodeError_clone(&*owner->contents.err);
8846 }
8847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8848         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
8849         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
8850         int64_t ret_ref = 0;
8851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8854         ret_ref = (uintptr_t)ret_var.inner;
8855         if (ret_var.is_owned) {
8856                 ret_ref |= 1;
8857         }
8858         return ret_ref;
8859 }
8860
8861 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8862 CHECK(owner->result_ok);
8863         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
8864 }
8865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8866         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8867         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8868         int64_t ret_ref = 0;
8869         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8870         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8872         ret_ref = (uintptr_t)ret_var.inner;
8873         if (ret_var.is_owned) {
8874                 ret_ref |= 1;
8875         }
8876         return ret_ref;
8877 }
8878
8879 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8880 CHECK(!owner->result_ok);
8881         return DecodeError_clone(&*owner->contents.err);
8882 }
8883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8884         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8885         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8886         int64_t ret_ref = 0;
8887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8890         ret_ref = (uintptr_t)ret_var.inner;
8891         if (ret_var.is_owned) {
8892                 ret_ref |= 1;
8893         }
8894         return ret_ref;
8895 }
8896
8897 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8898 CHECK(owner->result_ok);
8899         return ChannelAnnouncement_clone(&*owner->contents.result);
8900 }
8901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8902         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8903         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8904         int64_t ret_ref = 0;
8905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8908         ret_ref = (uintptr_t)ret_var.inner;
8909         if (ret_var.is_owned) {
8910                 ret_ref |= 1;
8911         }
8912         return ret_ref;
8913 }
8914
8915 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8916 CHECK(!owner->result_ok);
8917         return DecodeError_clone(&*owner->contents.err);
8918 }
8919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8920         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8921         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8922         int64_t ret_ref = 0;
8923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8926         ret_ref = (uintptr_t)ret_var.inner;
8927         if (ret_var.is_owned) {
8928                 ret_ref |= 1;
8929         }
8930         return ret_ref;
8931 }
8932
8933 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8934 CHECK(owner->result_ok);
8935         return UnsignedChannelUpdate_clone(&*owner->contents.result);
8936 }
8937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8938         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
8939         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8940         int64_t ret_ref = 0;
8941         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8942         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8944         ret_ref = (uintptr_t)ret_var.inner;
8945         if (ret_var.is_owned) {
8946                 ret_ref |= 1;
8947         }
8948         return ret_ref;
8949 }
8950
8951 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8952 CHECK(!owner->result_ok);
8953         return DecodeError_clone(&*owner->contents.err);
8954 }
8955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8956         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
8957         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
8958         int64_t ret_ref = 0;
8959         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8960         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8962         ret_ref = (uintptr_t)ret_var.inner;
8963         if (ret_var.is_owned) {
8964                 ret_ref |= 1;
8965         }
8966         return ret_ref;
8967 }
8968
8969 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8970 CHECK(owner->result_ok);
8971         return ChannelUpdate_clone(&*owner->contents.result);
8972 }
8973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8974         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
8975         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8976         int64_t ret_ref = 0;
8977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8980         ret_ref = (uintptr_t)ret_var.inner;
8981         if (ret_var.is_owned) {
8982                 ret_ref |= 1;
8983         }
8984         return ret_ref;
8985 }
8986
8987 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8988 CHECK(!owner->result_ok);
8989         return DecodeError_clone(&*owner->contents.err);
8990 }
8991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8992         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
8993         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
8994         int64_t ret_ref = 0;
8995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8998         ret_ref = (uintptr_t)ret_var.inner;
8999         if (ret_var.is_owned) {
9000                 ret_ref |= 1;
9001         }
9002         return ret_ref;
9003 }
9004
9005 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9006 CHECK(owner->result_ok);
9007         return ErrorMessage_clone(&*owner->contents.result);
9008 }
9009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9010         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9011         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9012         int64_t ret_ref = 0;
9013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9016         ret_ref = (uintptr_t)ret_var.inner;
9017         if (ret_var.is_owned) {
9018                 ret_ref |= 1;
9019         }
9020         return ret_ref;
9021 }
9022
9023 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9024 CHECK(!owner->result_ok);
9025         return DecodeError_clone(&*owner->contents.err);
9026 }
9027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9028         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9029         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9030         int64_t ret_ref = 0;
9031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9034         ret_ref = (uintptr_t)ret_var.inner;
9035         if (ret_var.is_owned) {
9036                 ret_ref |= 1;
9037         }
9038         return ret_ref;
9039 }
9040
9041 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9042 CHECK(owner->result_ok);
9043         return WarningMessage_clone(&*owner->contents.result);
9044 }
9045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9046         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9047         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9048         int64_t ret_ref = 0;
9049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9052         ret_ref = (uintptr_t)ret_var.inner;
9053         if (ret_var.is_owned) {
9054                 ret_ref |= 1;
9055         }
9056         return ret_ref;
9057 }
9058
9059 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9060 CHECK(!owner->result_ok);
9061         return DecodeError_clone(&*owner->contents.err);
9062 }
9063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9064         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9065         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9066         int64_t ret_ref = 0;
9067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9070         ret_ref = (uintptr_t)ret_var.inner;
9071         if (ret_var.is_owned) {
9072                 ret_ref |= 1;
9073         }
9074         return ret_ref;
9075 }
9076
9077 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9078 CHECK(owner->result_ok);
9079         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9080 }
9081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9082         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9083         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9084         int64_t ret_ref = 0;
9085         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9086         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9088         ret_ref = (uintptr_t)ret_var.inner;
9089         if (ret_var.is_owned) {
9090                 ret_ref |= 1;
9091         }
9092         return ret_ref;
9093 }
9094
9095 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9096 CHECK(!owner->result_ok);
9097         return DecodeError_clone(&*owner->contents.err);
9098 }
9099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9100         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9101         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9102         int64_t ret_ref = 0;
9103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9106         ret_ref = (uintptr_t)ret_var.inner;
9107         if (ret_var.is_owned) {
9108                 ret_ref |= 1;
9109         }
9110         return ret_ref;
9111 }
9112
9113 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9114 CHECK(owner->result_ok);
9115         return NodeAnnouncement_clone(&*owner->contents.result);
9116 }
9117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9118         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9119         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9120         int64_t ret_ref = 0;
9121         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9122         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9124         ret_ref = (uintptr_t)ret_var.inner;
9125         if (ret_var.is_owned) {
9126                 ret_ref |= 1;
9127         }
9128         return ret_ref;
9129 }
9130
9131 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9132 CHECK(!owner->result_ok);
9133         return DecodeError_clone(&*owner->contents.err);
9134 }
9135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9136         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9137         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9138         int64_t ret_ref = 0;
9139         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9140         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9142         ret_ref = (uintptr_t)ret_var.inner;
9143         if (ret_var.is_owned) {
9144                 ret_ref |= 1;
9145         }
9146         return ret_ref;
9147 }
9148
9149 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9150 CHECK(owner->result_ok);
9151         return QueryShortChannelIds_clone(&*owner->contents.result);
9152 }
9153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9154         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9155         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9156         int64_t ret_ref = 0;
9157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9160         ret_ref = (uintptr_t)ret_var.inner;
9161         if (ret_var.is_owned) {
9162                 ret_ref |= 1;
9163         }
9164         return ret_ref;
9165 }
9166
9167 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9168 CHECK(!owner->result_ok);
9169         return DecodeError_clone(&*owner->contents.err);
9170 }
9171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9172         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9173         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9174         int64_t ret_ref = 0;
9175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9178         ret_ref = (uintptr_t)ret_var.inner;
9179         if (ret_var.is_owned) {
9180                 ret_ref |= 1;
9181         }
9182         return ret_ref;
9183 }
9184
9185 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9186 CHECK(owner->result_ok);
9187         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9188 }
9189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9190         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9191         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9192         int64_t ret_ref = 0;
9193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9196         ret_ref = (uintptr_t)ret_var.inner;
9197         if (ret_var.is_owned) {
9198                 ret_ref |= 1;
9199         }
9200         return ret_ref;
9201 }
9202
9203 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9204 CHECK(!owner->result_ok);
9205         return DecodeError_clone(&*owner->contents.err);
9206 }
9207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9208         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9209         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9210         int64_t ret_ref = 0;
9211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9214         ret_ref = (uintptr_t)ret_var.inner;
9215         if (ret_var.is_owned) {
9216                 ret_ref |= 1;
9217         }
9218         return ret_ref;
9219 }
9220
9221 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9222 CHECK(owner->result_ok);
9223         return QueryChannelRange_clone(&*owner->contents.result);
9224 }
9225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9226         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9227         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9228         int64_t ret_ref = 0;
9229         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9230         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9232         ret_ref = (uintptr_t)ret_var.inner;
9233         if (ret_var.is_owned) {
9234                 ret_ref |= 1;
9235         }
9236         return ret_ref;
9237 }
9238
9239 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9240 CHECK(!owner->result_ok);
9241         return DecodeError_clone(&*owner->contents.err);
9242 }
9243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9244         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9245         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9246         int64_t ret_ref = 0;
9247         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9248         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9250         ret_ref = (uintptr_t)ret_var.inner;
9251         if (ret_var.is_owned) {
9252                 ret_ref |= 1;
9253         }
9254         return ret_ref;
9255 }
9256
9257 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9258 CHECK(owner->result_ok);
9259         return ReplyChannelRange_clone(&*owner->contents.result);
9260 }
9261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9262         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9263         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9264         int64_t ret_ref = 0;
9265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9268         ret_ref = (uintptr_t)ret_var.inner;
9269         if (ret_var.is_owned) {
9270                 ret_ref |= 1;
9271         }
9272         return ret_ref;
9273 }
9274
9275 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9276 CHECK(!owner->result_ok);
9277         return DecodeError_clone(&*owner->contents.err);
9278 }
9279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9280         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9281         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9282         int64_t ret_ref = 0;
9283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9286         ret_ref = (uintptr_t)ret_var.inner;
9287         if (ret_var.is_owned) {
9288                 ret_ref |= 1;
9289         }
9290         return ret_ref;
9291 }
9292
9293 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9294 CHECK(owner->result_ok);
9295         return GossipTimestampFilter_clone(&*owner->contents.result);
9296 }
9297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9298         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9299         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9300         int64_t ret_ref = 0;
9301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9304         ret_ref = (uintptr_t)ret_var.inner;
9305         if (ret_var.is_owned) {
9306                 ret_ref |= 1;
9307         }
9308         return ret_ref;
9309 }
9310
9311 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9312 CHECK(!owner->result_ok);
9313         return DecodeError_clone(&*owner->contents.err);
9314 }
9315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9316         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9317         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9318         int64_t ret_ref = 0;
9319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9322         ret_ref = (uintptr_t)ret_var.inner;
9323         if (ret_var.is_owned) {
9324                 ret_ref |= 1;
9325         }
9326         return ret_ref;
9327 }
9328
9329 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9330         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9331         for (size_t i = 0; i < ret.datalen; i++) {
9332                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9333         }
9334         return ret;
9335 }
9336 static jclass LDKSignOrCreationError_SignError_class = NULL;
9337 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
9338 static jclass LDKSignOrCreationError_CreationError_class = NULL;
9339 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
9340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
9341         LDKSignOrCreationError_SignError_class =
9342                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
9343         CHECK(LDKSignOrCreationError_SignError_class != NULL);
9344         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
9345         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
9346         LDKSignOrCreationError_CreationError_class =
9347                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
9348         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
9349         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
9350         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
9351 }
9352 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9353         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
9354         switch(obj->tag) {
9355                 case LDKSignOrCreationError_SignError: {
9356                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
9357                 }
9358                 case LDKSignOrCreationError_CreationError: {
9359                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
9360                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
9361                 }
9362                 default: abort();
9363         }
9364 }
9365 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9366 CHECK(owner->result_ok);
9367         return Invoice_clone(&*owner->contents.result);
9368 }
9369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9370         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9371         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9372         int64_t ret_ref = 0;
9373         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9374         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9376         ret_ref = (uintptr_t)ret_var.inner;
9377         if (ret_var.is_owned) {
9378                 ret_ref |= 1;
9379         }
9380         return ret_ref;
9381 }
9382
9383 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9384 CHECK(!owner->result_ok);
9385         return SignOrCreationError_clone(&*owner->contents.err);
9386 }
9387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9388         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9389         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9390         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9391         int64_t ret_ref = (uintptr_t)ret_copy;
9392         return ret_ref;
9393 }
9394
9395 typedef struct LDKFilter_JCalls {
9396         atomic_size_t refcnt;
9397         JavaVM *vm;
9398         jweak o;
9399         jmethodID register_tx_meth;
9400         jmethodID register_output_meth;
9401 } LDKFilter_JCalls;
9402 static void LDKFilter_JCalls_free(void* this_arg) {
9403         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9404         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9405                 JNIEnv *env;
9406                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9407                 if (get_jenv_res == JNI_EDETACHED) {
9408                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9409                 } else {
9410                         DO_ASSERT(get_jenv_res == JNI_OK);
9411                 }
9412                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9413                 if (get_jenv_res == JNI_EDETACHED) {
9414                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9415                 }
9416                 FREE(j_calls);
9417         }
9418 }
9419 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
9420         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9421         JNIEnv *env;
9422         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9423         if (get_jenv_res == JNI_EDETACHED) {
9424                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9425         } else {
9426                 DO_ASSERT(get_jenv_res == JNI_OK);
9427         }
9428         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9429         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9430         LDKu8slice script_pubkey_var = script_pubkey;
9431         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
9432         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
9433         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9434         CHECK(obj != NULL);
9435         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
9436         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9437                 (*env)->ExceptionDescribe(env);
9438                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
9439         }
9440         if (get_jenv_res == JNI_EDETACHED) {
9441                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9442         }
9443 }
9444 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
9445         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9446         JNIEnv *env;
9447         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9448         if (get_jenv_res == JNI_EDETACHED) {
9449                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9450         } else {
9451                 DO_ASSERT(get_jenv_res == JNI_OK);
9452         }
9453         LDKWatchedOutput output_var = output;
9454         int64_t output_ref = 0;
9455         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9456         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9457         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
9458         output_ref = (uintptr_t)output_var.inner;
9459         if (output_var.is_owned) {
9460                 output_ref |= 1;
9461         }
9462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9463         CHECK(obj != NULL);
9464         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
9465         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9466                 (*env)->ExceptionDescribe(env);
9467                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
9468         }
9469         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9470         CHECK_ACCESS(ret_ptr);
9471         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
9472         FREE((void*)ret);
9473         if (get_jenv_res == JNI_EDETACHED) {
9474                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9475         }
9476         return ret_conv;
9477 }
9478 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
9479         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
9480         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9481 }
9482 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
9483         jclass c = (*env)->GetObjectClass(env, o);
9484         CHECK(c != NULL);
9485         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
9486         atomic_init(&calls->refcnt, 1);
9487         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9488         calls->o = (*env)->NewWeakGlobalRef(env, o);
9489         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
9490         CHECK(calls->register_tx_meth != NULL);
9491         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
9492         CHECK(calls->register_output_meth != NULL);
9493
9494         LDKFilter ret = {
9495                 .this_arg = (void*) calls,
9496                 .register_tx = register_tx_LDKFilter_jcall,
9497                 .register_output = register_output_LDKFilter_jcall,
9498                 .free = LDKFilter_JCalls_free,
9499         };
9500         return ret;
9501 }
9502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
9503         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9504         *res_ptr = LDKFilter_init(env, clz, o);
9505         return (uint64_t)res_ptr;
9506 }
9507 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) {
9508         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9509         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9510         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9511         unsigned char txid_arr[32];
9512         CHECK((*env)->GetArrayLength(env, txid) == 32);
9513         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
9514         unsigned char (*txid_ref)[32] = &txid_arr;
9515         LDKu8slice script_pubkey_ref;
9516         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
9517         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
9518         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
9519         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
9520 }
9521
9522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
9523         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9524         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9525         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9526         LDKWatchedOutput output_conv;
9527         output_conv.inner = (void*)(output & (~1));
9528         output_conv.is_owned = (output & 1) || (output == 0);
9529         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
9530         output_conv = WatchedOutput_clone(&output_conv);
9531         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9532         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
9533         int64_t ret_ref = (uintptr_t)ret_copy;
9534         return ret_ref;
9535 }
9536
9537 static jclass LDKCOption_FilterZ_Some_class = NULL;
9538 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
9539 static jclass LDKCOption_FilterZ_None_class = NULL;
9540 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
9541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
9542         LDKCOption_FilterZ_Some_class =
9543                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
9544         CHECK(LDKCOption_FilterZ_Some_class != NULL);
9545         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
9546         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
9547         LDKCOption_FilterZ_None_class =
9548                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
9549         CHECK(LDKCOption_FilterZ_None_class != NULL);
9550         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
9551         CHECK(LDKCOption_FilterZ_None_meth != NULL);
9552 }
9553 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9554         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
9555         switch(obj->tag) {
9556                 case LDKCOption_FilterZ_Some: {
9557                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
9558                         *some_ret = obj->some;
9559                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
9560                         if ((*some_ret).free == LDKFilter_JCalls_free) {
9561                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9562                                 LDKFilter_JCalls_cloned(&(*some_ret));
9563                         }
9564                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
9565                 }
9566                 case LDKCOption_FilterZ_None: {
9567                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
9568                 }
9569                 default: abort();
9570         }
9571 }
9572 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9573 CHECK(owner->result_ok);
9574         return &*owner->contents.result;
9575 }
9576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9577         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9578         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
9579         int64_t ret_ref = 0;
9580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9583         ret_ref = (uintptr_t)ret_var.inner & ~1;
9584         return ret_ref;
9585 }
9586
9587 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9588 CHECK(!owner->result_ok);
9589         return *owner->contents.err;
9590 }
9591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9592         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9593         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
9594 }
9595
9596 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
9597         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
9598         for (size_t i = 0; i < ret.datalen; i++) {
9599                 ret.data[i] = OutPoint_clone(&orig->data[i]);
9600         }
9601         return ret;
9602 }
9603 typedef struct LDKMessageSendEventsProvider_JCalls {
9604         atomic_size_t refcnt;
9605         JavaVM *vm;
9606         jweak o;
9607         jmethodID get_and_clear_pending_msg_events_meth;
9608 } LDKMessageSendEventsProvider_JCalls;
9609 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
9610         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9611         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9612                 JNIEnv *env;
9613                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9614                 if (get_jenv_res == JNI_EDETACHED) {
9615                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9616                 } else {
9617                         DO_ASSERT(get_jenv_res == JNI_OK);
9618                 }
9619                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9620                 if (get_jenv_res == JNI_EDETACHED) {
9621                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9622                 }
9623                 FREE(j_calls);
9624         }
9625 }
9626 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
9627         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9628         JNIEnv *env;
9629         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9630         if (get_jenv_res == JNI_EDETACHED) {
9631                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9632         } else {
9633                 DO_ASSERT(get_jenv_res == JNI_OK);
9634         }
9635         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9636         CHECK(obj != NULL);
9637         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
9638         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9639                 (*env)->ExceptionDescribe(env);
9640                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
9641         }
9642         LDKCVec_MessageSendEventZ ret_constr;
9643         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9644         if (ret_constr.datalen > 0)
9645                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9646         else
9647                 ret_constr.data = NULL;
9648         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9649         for (size_t s = 0; s < ret_constr.datalen; s++) {
9650                 int64_t ret_conv_18 = ret_vals[s];
9651                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
9652                 CHECK_ACCESS(ret_conv_18_ptr);
9653                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
9654                 FREE((void*)ret_conv_18);
9655                 ret_constr.data[s] = ret_conv_18_conv;
9656         }
9657         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9658         if (get_jenv_res == JNI_EDETACHED) {
9659                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9660         }
9661         return ret_constr;
9662 }
9663 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
9664         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
9665         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9666 }
9667 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
9668         jclass c = (*env)->GetObjectClass(env, o);
9669         CHECK(c != NULL);
9670         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
9671         atomic_init(&calls->refcnt, 1);
9672         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9673         calls->o = (*env)->NewWeakGlobalRef(env, o);
9674         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
9675         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
9676
9677         LDKMessageSendEventsProvider ret = {
9678                 .this_arg = (void*) calls,
9679                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
9680                 .free = LDKMessageSendEventsProvider_JCalls_free,
9681         };
9682         return ret;
9683 }
9684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
9685         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
9686         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
9687         return (uint64_t)res_ptr;
9688 }
9689 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
9690         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9691         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9692         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
9693         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
9694         int64_tArray ret_arr = NULL;
9695         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9696         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9697         for (size_t s = 0; s < ret_var.datalen; s++) {
9698                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
9699                 *ret_conv_18_copy = ret_var.data[s];
9700                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
9701                 ret_arr_ptr[s] = ret_conv_18_ref;
9702         }
9703         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9704         FREE(ret_var.data);
9705         return ret_arr;
9706 }
9707
9708 typedef struct LDKEventHandler_JCalls {
9709         atomic_size_t refcnt;
9710         JavaVM *vm;
9711         jweak o;
9712         jmethodID handle_event_meth;
9713 } LDKEventHandler_JCalls;
9714 static void LDKEventHandler_JCalls_free(void* this_arg) {
9715         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
9716         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9717                 JNIEnv *env;
9718                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9719                 if (get_jenv_res == JNI_EDETACHED) {
9720                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9721                 } else {
9722                         DO_ASSERT(get_jenv_res == JNI_OK);
9723                 }
9724                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9725                 if (get_jenv_res == JNI_EDETACHED) {
9726                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9727                 }
9728                 FREE(j_calls);
9729         }
9730 }
9731 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
9732         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
9733         JNIEnv *env;
9734         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9735         if (get_jenv_res == JNI_EDETACHED) {
9736                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9737         } else {
9738                 DO_ASSERT(get_jenv_res == JNI_OK);
9739         }
9740         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
9741         *ret_event = Event_clone(event);
9742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9743         CHECK(obj != NULL);
9744         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
9745         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9746                 (*env)->ExceptionDescribe(env);
9747                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
9748         }
9749         if (get_jenv_res == JNI_EDETACHED) {
9750                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9751         }
9752 }
9753 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
9754         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
9755         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9756 }
9757 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
9758         jclass c = (*env)->GetObjectClass(env, o);
9759         CHECK(c != NULL);
9760         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
9761         atomic_init(&calls->refcnt, 1);
9762         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9763         calls->o = (*env)->NewWeakGlobalRef(env, o);
9764         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
9765         CHECK(calls->handle_event_meth != NULL);
9766
9767         LDKEventHandler ret = {
9768                 .this_arg = (void*) calls,
9769                 .handle_event = handle_event_LDKEventHandler_jcall,
9770                 .free = LDKEventHandler_JCalls_free,
9771         };
9772         return ret;
9773 }
9774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
9775         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
9776         *res_ptr = LDKEventHandler_init(env, clz, o);
9777         return (uint64_t)res_ptr;
9778 }
9779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
9780         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9781         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9782         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
9783         LDKEvent* event_conv = (LDKEvent*)event;
9784         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
9785 }
9786
9787 typedef struct LDKEventsProvider_JCalls {
9788         atomic_size_t refcnt;
9789         JavaVM *vm;
9790         jweak o;
9791         jmethodID process_pending_events_meth;
9792 } LDKEventsProvider_JCalls;
9793 static void LDKEventsProvider_JCalls_free(void* this_arg) {
9794         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
9795         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9796                 JNIEnv *env;
9797                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9798                 if (get_jenv_res == JNI_EDETACHED) {
9799                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9800                 } else {
9801                         DO_ASSERT(get_jenv_res == JNI_OK);
9802                 }
9803                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9804                 if (get_jenv_res == JNI_EDETACHED) {
9805                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9806                 }
9807                 FREE(j_calls);
9808         }
9809 }
9810 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
9811         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
9812         JNIEnv *env;
9813         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9814         if (get_jenv_res == JNI_EDETACHED) {
9815                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9816         } else {
9817                 DO_ASSERT(get_jenv_res == JNI_OK);
9818         }
9819         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
9820         *handler_ret = handler;
9821         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9822         CHECK(obj != NULL);
9823         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
9824         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9825                 (*env)->ExceptionDescribe(env);
9826                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
9827         }
9828         if (get_jenv_res == JNI_EDETACHED) {
9829                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9830         }
9831 }
9832 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
9833         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
9834         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9835 }
9836 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
9837         jclass c = (*env)->GetObjectClass(env, o);
9838         CHECK(c != NULL);
9839         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
9840         atomic_init(&calls->refcnt, 1);
9841         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9842         calls->o = (*env)->NewWeakGlobalRef(env, o);
9843         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
9844         CHECK(calls->process_pending_events_meth != NULL);
9845
9846         LDKEventsProvider ret = {
9847                 .this_arg = (void*) calls,
9848                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
9849                 .free = LDKEventsProvider_JCalls_free,
9850         };
9851         return ret;
9852 }
9853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
9854         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
9855         *res_ptr = LDKEventsProvider_init(env, clz, o);
9856         return (uint64_t)res_ptr;
9857 }
9858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
9859         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9860         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9861         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
9862         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
9863         CHECK_ACCESS(handler_ptr);
9864         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
9865         if (handler_conv.free == LDKEventHandler_JCalls_free) {
9866                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9867                 LDKEventHandler_JCalls_cloned(&handler_conv);
9868         }
9869         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
9870 }
9871
9872 typedef struct LDKListen_JCalls {
9873         atomic_size_t refcnt;
9874         JavaVM *vm;
9875         jweak o;
9876         jmethodID block_connected_meth;
9877         jmethodID block_disconnected_meth;
9878 } LDKListen_JCalls;
9879 static void LDKListen_JCalls_free(void* this_arg) {
9880         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9881         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9882                 JNIEnv *env;
9883                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9884                 if (get_jenv_res == JNI_EDETACHED) {
9885                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9886                 } else {
9887                         DO_ASSERT(get_jenv_res == JNI_OK);
9888                 }
9889                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9890                 if (get_jenv_res == JNI_EDETACHED) {
9891                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9892                 }
9893                 FREE(j_calls);
9894         }
9895 }
9896 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
9897         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9898         JNIEnv *env;
9899         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9900         if (get_jenv_res == JNI_EDETACHED) {
9901                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9902         } else {
9903                 DO_ASSERT(get_jenv_res == JNI_OK);
9904         }
9905         LDKu8slice block_var = block;
9906         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
9907         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
9908         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9909         CHECK(obj != NULL);
9910         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
9911         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9912                 (*env)->ExceptionDescribe(env);
9913                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
9914         }
9915         if (get_jenv_res == JNI_EDETACHED) {
9916                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9917         }
9918 }
9919 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9920         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9921         JNIEnv *env;
9922         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9923         if (get_jenv_res == JNI_EDETACHED) {
9924                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9925         } else {
9926                 DO_ASSERT(get_jenv_res == JNI_OK);
9927         }
9928         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
9929         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
9930         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9931         CHECK(obj != NULL);
9932         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
9933         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9934                 (*env)->ExceptionDescribe(env);
9935                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
9936         }
9937         if (get_jenv_res == JNI_EDETACHED) {
9938                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9939         }
9940 }
9941 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
9942         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
9943         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9944 }
9945 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
9946         jclass c = (*env)->GetObjectClass(env, o);
9947         CHECK(c != NULL);
9948         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
9949         atomic_init(&calls->refcnt, 1);
9950         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9951         calls->o = (*env)->NewWeakGlobalRef(env, o);
9952         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
9953         CHECK(calls->block_connected_meth != NULL);
9954         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
9955         CHECK(calls->block_disconnected_meth != NULL);
9956
9957         LDKListen ret = {
9958                 .this_arg = (void*) calls,
9959                 .block_connected = block_connected_LDKListen_jcall,
9960                 .block_disconnected = block_disconnected_LDKListen_jcall,
9961                 .free = LDKListen_JCalls_free,
9962         };
9963         return ret;
9964 }
9965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
9966         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
9967         *res_ptr = LDKListen_init(env, clz, o);
9968         return (uint64_t)res_ptr;
9969 }
9970 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) {
9971         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9972         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9973         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9974         LDKu8slice block_ref;
9975         block_ref.datalen = (*env)->GetArrayLength(env, block);
9976         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
9977         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
9978         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
9979 }
9980
9981 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) {
9982         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9983         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9984         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9985         unsigned char header_arr[80];
9986         CHECK((*env)->GetArrayLength(env, header) == 80);
9987         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
9988         unsigned char (*header_ref)[80] = &header_arr;
9989         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
9990 }
9991
9992 typedef struct LDKConfirm_JCalls {
9993         atomic_size_t refcnt;
9994         JavaVM *vm;
9995         jweak o;
9996         jmethodID transactions_confirmed_meth;
9997         jmethodID transaction_unconfirmed_meth;
9998         jmethodID best_block_updated_meth;
9999         jmethodID get_relevant_txids_meth;
10000 } LDKConfirm_JCalls;
10001 static void LDKConfirm_JCalls_free(void* this_arg) {
10002         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10003         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10004                 JNIEnv *env;
10005                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10006                 if (get_jenv_res == JNI_EDETACHED) {
10007                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10008                 } else {
10009                         DO_ASSERT(get_jenv_res == JNI_OK);
10010                 }
10011                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10012                 if (get_jenv_res == JNI_EDETACHED) {
10013                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10014                 }
10015                 FREE(j_calls);
10016         }
10017 }
10018 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
10019         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10020         JNIEnv *env;
10021         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10022         if (get_jenv_res == JNI_EDETACHED) {
10023                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10024         } else {
10025                 DO_ASSERT(get_jenv_res == JNI_OK);
10026         }
10027         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10028         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10029         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
10030         int64_tArray txdata_arr = NULL;
10031         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
10032         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
10033         for (size_t c = 0; c < txdata_var.datalen; c++) {
10034                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10035                 *txdata_conv_28_conv = txdata_var.data[c];
10036                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
10037         }
10038         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
10039         FREE(txdata_var.data);
10040         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10041         CHECK(obj != NULL);
10042         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
10043         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10044                 (*env)->ExceptionDescribe(env);
10045                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
10046         }
10047         if (get_jenv_res == JNI_EDETACHED) {
10048                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10049         }
10050 }
10051 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
10052         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10053         JNIEnv *env;
10054         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10055         if (get_jenv_res == JNI_EDETACHED) {
10056                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10057         } else {
10058                 DO_ASSERT(get_jenv_res == JNI_OK);
10059         }
10060         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10061         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10062         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10063         CHECK(obj != NULL);
10064         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
10065         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10066                 (*env)->ExceptionDescribe(env);
10067                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
10068         }
10069         if (get_jenv_res == JNI_EDETACHED) {
10070                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10071         }
10072 }
10073 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10074         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10075         JNIEnv *env;
10076         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10077         if (get_jenv_res == JNI_EDETACHED) {
10078                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10079         } else {
10080                 DO_ASSERT(get_jenv_res == JNI_OK);
10081         }
10082         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10083         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10084         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10085         CHECK(obj != NULL);
10086         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
10087         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10088                 (*env)->ExceptionDescribe(env);
10089                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
10090         }
10091         if (get_jenv_res == JNI_EDETACHED) {
10092                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10093         }
10094 }
10095 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
10096         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10097         JNIEnv *env;
10098         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10099         if (get_jenv_res == JNI_EDETACHED) {
10100                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10101         } else {
10102                 DO_ASSERT(get_jenv_res == JNI_OK);
10103         }
10104         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10105         CHECK(obj != NULL);
10106         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
10107         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10108                 (*env)->ExceptionDescribe(env);
10109                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
10110         }
10111         LDKCVec_TxidZ ret_constr;
10112         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10113         if (ret_constr.datalen > 0)
10114                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
10115         else
10116                 ret_constr.data = NULL;
10117         for (size_t i = 0; i < ret_constr.datalen; i++) {
10118                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
10119                 LDKThirtyTwoBytes ret_conv_8_ref;
10120                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
10121                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
10122                 ret_constr.data[i] = ret_conv_8_ref;
10123         }
10124         if (get_jenv_res == JNI_EDETACHED) {
10125                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10126         }
10127         return ret_constr;
10128 }
10129 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
10130         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
10131         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10132 }
10133 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
10134         jclass c = (*env)->GetObjectClass(env, o);
10135         CHECK(c != NULL);
10136         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
10137         atomic_init(&calls->refcnt, 1);
10138         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10139         calls->o = (*env)->NewWeakGlobalRef(env, o);
10140         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
10141         CHECK(calls->transactions_confirmed_meth != NULL);
10142         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
10143         CHECK(calls->transaction_unconfirmed_meth != NULL);
10144         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
10145         CHECK(calls->best_block_updated_meth != NULL);
10146         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
10147         CHECK(calls->get_relevant_txids_meth != NULL);
10148
10149         LDKConfirm ret = {
10150                 .this_arg = (void*) calls,
10151                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
10152                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
10153                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
10154                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
10155                 .free = LDKConfirm_JCalls_free,
10156         };
10157         return ret;
10158 }
10159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
10160         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
10161         *res_ptr = LDKConfirm_init(env, clz, o);
10162         return (uint64_t)res_ptr;
10163 }
10164 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) {
10165         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10166         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10167         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10168         unsigned char header_arr[80];
10169         CHECK((*env)->GetArrayLength(env, header) == 80);
10170         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10171         unsigned char (*header_ref)[80] = &header_arr;
10172         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10173         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10174         if (txdata_constr.datalen > 0)
10175                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10176         else
10177                 txdata_constr.data = NULL;
10178         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10179         for (size_t c = 0; c < txdata_constr.datalen; c++) {
10180                 int64_t txdata_conv_28 = txdata_vals[c];
10181                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
10182                 CHECK_ACCESS(txdata_conv_28_ptr);
10183                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
10184                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
10185                 txdata_constr.data[c] = txdata_conv_28_conv;
10186         }
10187         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10188         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
10189 }
10190
10191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
10192         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10193         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10194         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10195         unsigned char txid_arr[32];
10196         CHECK((*env)->GetArrayLength(env, txid) == 32);
10197         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10198         unsigned char (*txid_ref)[32] = &txid_arr;
10199         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
10200 }
10201
10202 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) {
10203         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10204         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10205         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10206         unsigned char header_arr[80];
10207         CHECK((*env)->GetArrayLength(env, header) == 80);
10208         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10209         unsigned char (*header_ref)[80] = &header_arr;
10210         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
10211 }
10212
10213 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
10214         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10215         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10216         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10217         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
10218         jobjectArray ret_arr = NULL;
10219         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
10220         ;
10221         for (size_t i = 0; i < ret_var.datalen; i++) {
10222                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
10223                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
10224                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
10225         }
10226         
10227         FREE(ret_var.data);
10228         return ret_arr;
10229 }
10230
10231 typedef struct LDKPersist_JCalls {
10232         atomic_size_t refcnt;
10233         JavaVM *vm;
10234         jweak o;
10235         jmethodID persist_new_channel_meth;
10236         jmethodID update_persisted_channel_meth;
10237 } LDKPersist_JCalls;
10238 static void LDKPersist_JCalls_free(void* this_arg) {
10239         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10240         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10241                 JNIEnv *env;
10242                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10243                 if (get_jenv_res == JNI_EDETACHED) {
10244                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10245                 } else {
10246                         DO_ASSERT(get_jenv_res == JNI_OK);
10247                 }
10248                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10249                 if (get_jenv_res == JNI_EDETACHED) {
10250                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10251                 }
10252                 FREE(j_calls);
10253         }
10254 }
10255 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10256         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10257         JNIEnv *env;
10258         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10259         if (get_jenv_res == JNI_EDETACHED) {
10260                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10261         } else {
10262                 DO_ASSERT(get_jenv_res == JNI_OK);
10263         }
10264         LDKOutPoint channel_id_var = channel_id;
10265         int64_t channel_id_ref = 0;
10266         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10267         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10268         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10269         channel_id_ref = (uintptr_t)channel_id_var.inner;
10270         if (channel_id_var.is_owned) {
10271                 channel_id_ref |= 1;
10272         }
10273         LDKChannelMonitor data_var = *data;
10274         int64_t data_ref = 0;
10275         data_var = ChannelMonitor_clone(&data_var);
10276         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10277         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10278         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10279         data_ref = (uintptr_t)data_var.inner;
10280         if (data_var.is_owned) {
10281                 data_ref |= 1;
10282         }
10283         LDKMonitorUpdateId update_id_var = update_id;
10284         int64_t update_id_ref = 0;
10285         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10286         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10287         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10288         update_id_ref = (uintptr_t)update_id_var.inner;
10289         if (update_id_var.is_owned) {
10290                 update_id_ref |= 1;
10291         }
10292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10293         CHECK(obj != NULL);
10294         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
10295         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10296                 (*env)->ExceptionDescribe(env);
10297                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
10298         }
10299         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10300         CHECK_ACCESS(ret_ptr);
10301         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10302         FREE((void*)ret);
10303         if (get_jenv_res == JNI_EDETACHED) {
10304                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10305         }
10306         return ret_conv;
10307 }
10308 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10309         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10310         JNIEnv *env;
10311         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10312         if (get_jenv_res == JNI_EDETACHED) {
10313                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10314         } else {
10315                 DO_ASSERT(get_jenv_res == JNI_OK);
10316         }
10317         LDKOutPoint channel_id_var = channel_id;
10318         int64_t channel_id_ref = 0;
10319         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10320         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10321         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10322         channel_id_ref = (uintptr_t)channel_id_var.inner;
10323         if (channel_id_var.is_owned) {
10324                 channel_id_ref |= 1;
10325         }
10326         LDKChannelMonitorUpdate update_var = *update;
10327         int64_t update_ref = 0;
10328         if ((uintptr_t)update_var.inner > 4096) {
10329                 update_var = ChannelMonitorUpdate_clone(&update_var);
10330                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10331                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10332         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
10333                 update_ref = (uintptr_t)update_var.inner;
10334                 if (update_var.is_owned) {
10335                         update_ref |= 1;
10336                 }
10337         }
10338         LDKChannelMonitor data_var = *data;
10339         int64_t data_ref = 0;
10340         data_var = ChannelMonitor_clone(&data_var);
10341         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10342         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10343         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10344         data_ref = (uintptr_t)data_var.inner;
10345         if (data_var.is_owned) {
10346                 data_ref |= 1;
10347         }
10348         LDKMonitorUpdateId update_id_var = update_id;
10349         int64_t update_id_ref = 0;
10350         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10351         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10352         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10353         update_id_ref = (uintptr_t)update_id_var.inner;
10354         if (update_id_var.is_owned) {
10355                 update_id_ref |= 1;
10356         }
10357         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10358         CHECK(obj != NULL);
10359         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
10360         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10361                 (*env)->ExceptionDescribe(env);
10362                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
10363         }
10364         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10365         CHECK_ACCESS(ret_ptr);
10366         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10367         FREE((void*)ret);
10368         if (get_jenv_res == JNI_EDETACHED) {
10369                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10370         }
10371         return ret_conv;
10372 }
10373 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
10374         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
10375         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10376 }
10377 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
10378         jclass c = (*env)->GetObjectClass(env, o);
10379         CHECK(c != NULL);
10380         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
10381         atomic_init(&calls->refcnt, 1);
10382         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10383         calls->o = (*env)->NewWeakGlobalRef(env, o);
10384         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
10385         CHECK(calls->persist_new_channel_meth != NULL);
10386         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
10387         CHECK(calls->update_persisted_channel_meth != NULL);
10388
10389         LDKPersist ret = {
10390                 .this_arg = (void*) calls,
10391                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
10392                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
10393                 .free = LDKPersist_JCalls_free,
10394         };
10395         return ret;
10396 }
10397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
10398         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
10399         *res_ptr = LDKPersist_init(env, clz, o);
10400         return (uint64_t)res_ptr;
10401 }
10402 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) {
10403         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10404         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10405         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10406         LDKOutPoint channel_id_conv;
10407         channel_id_conv.inner = (void*)(channel_id & (~1));
10408         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10409         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10410         channel_id_conv = OutPoint_clone(&channel_id_conv);
10411         LDKChannelMonitor data_conv;
10412         data_conv.inner = (void*)(data & (~1));
10413         data_conv.is_owned = false;
10414         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10415         LDKMonitorUpdateId update_id_conv;
10416         update_id_conv.inner = (void*)(update_id & (~1));
10417         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10418         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10419         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10420         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10421         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
10422         return (int64_t)ret_conv;
10423 }
10424
10425 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) {
10426         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10427         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10428         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10429         LDKOutPoint channel_id_conv;
10430         channel_id_conv.inner = (void*)(channel_id & (~1));
10431         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10432         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10433         channel_id_conv = OutPoint_clone(&channel_id_conv);
10434         LDKChannelMonitorUpdate update_conv;
10435         update_conv.inner = (void*)(update & (~1));
10436         update_conv.is_owned = false;
10437         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
10438         LDKChannelMonitor data_conv;
10439         data_conv.inner = (void*)(data & (~1));
10440         data_conv.is_owned = false;
10441         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10442         LDKMonitorUpdateId update_id_conv;
10443         update_id_conv.inner = (void*)(update_id & (~1));
10444         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10445         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10446         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10447         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10448         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
10449         return (int64_t)ret_conv;
10450 }
10451
10452 typedef struct LDKChannelMessageHandler_JCalls {
10453         atomic_size_t refcnt;
10454         JavaVM *vm;
10455         jweak o;
10456         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10457         jmethodID handle_open_channel_meth;
10458         jmethodID handle_accept_channel_meth;
10459         jmethodID handle_funding_created_meth;
10460         jmethodID handle_funding_signed_meth;
10461         jmethodID handle_funding_locked_meth;
10462         jmethodID handle_shutdown_meth;
10463         jmethodID handle_closing_signed_meth;
10464         jmethodID handle_update_add_htlc_meth;
10465         jmethodID handle_update_fulfill_htlc_meth;
10466         jmethodID handle_update_fail_htlc_meth;
10467         jmethodID handle_update_fail_malformed_htlc_meth;
10468         jmethodID handle_commitment_signed_meth;
10469         jmethodID handle_revoke_and_ack_meth;
10470         jmethodID handle_update_fee_meth;
10471         jmethodID handle_announcement_signatures_meth;
10472         jmethodID peer_disconnected_meth;
10473         jmethodID peer_connected_meth;
10474         jmethodID handle_channel_reestablish_meth;
10475         jmethodID handle_channel_update_meth;
10476         jmethodID handle_error_meth;
10477 } LDKChannelMessageHandler_JCalls;
10478 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
10479         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10480         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10481                 JNIEnv *env;
10482                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10483                 if (get_jenv_res == JNI_EDETACHED) {
10484                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10485                 } else {
10486                         DO_ASSERT(get_jenv_res == JNI_OK);
10487                 }
10488                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10489                 if (get_jenv_res == JNI_EDETACHED) {
10490                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10491                 }
10492                 FREE(j_calls);
10493         }
10494 }
10495 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
10496         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10497         JNIEnv *env;
10498         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10499         if (get_jenv_res == JNI_EDETACHED) {
10500                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10501         } else {
10502                 DO_ASSERT(get_jenv_res == JNI_OK);
10503         }
10504         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10505         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10506         LDKInitFeatures their_features_var = their_features;
10507         int64_t their_features_ref = 0;
10508         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10509         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10510         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10511         their_features_ref = (uintptr_t)their_features_var.inner;
10512         if (their_features_var.is_owned) {
10513                 their_features_ref |= 1;
10514         }
10515         LDKOpenChannel msg_var = *msg;
10516         int64_t msg_ref = 0;
10517         msg_var = OpenChannel_clone(&msg_var);
10518         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10519         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10520         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10521         msg_ref = (uintptr_t)msg_var.inner;
10522         if (msg_var.is_owned) {
10523                 msg_ref |= 1;
10524         }
10525         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10526         CHECK(obj != NULL);
10527         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10528         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10529                 (*env)->ExceptionDescribe(env);
10530                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
10531         }
10532         if (get_jenv_res == JNI_EDETACHED) {
10533                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10534         }
10535 }
10536 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
10537         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10538         JNIEnv *env;
10539         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10540         if (get_jenv_res == JNI_EDETACHED) {
10541                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10542         } else {
10543                 DO_ASSERT(get_jenv_res == JNI_OK);
10544         }
10545         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10546         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10547         LDKInitFeatures their_features_var = their_features;
10548         int64_t their_features_ref = 0;
10549         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10550         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10551         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10552         their_features_ref = (uintptr_t)their_features_var.inner;
10553         if (their_features_var.is_owned) {
10554                 their_features_ref |= 1;
10555         }
10556         LDKAcceptChannel msg_var = *msg;
10557         int64_t msg_ref = 0;
10558         msg_var = AcceptChannel_clone(&msg_var);
10559         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10560         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10561         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10562         msg_ref = (uintptr_t)msg_var.inner;
10563         if (msg_var.is_owned) {
10564                 msg_ref |= 1;
10565         }
10566         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10567         CHECK(obj != NULL);
10568         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10569         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10570                 (*env)->ExceptionDescribe(env);
10571                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
10572         }
10573         if (get_jenv_res == JNI_EDETACHED) {
10574                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10575         }
10576 }
10577 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
10578         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10579         JNIEnv *env;
10580         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10581         if (get_jenv_res == JNI_EDETACHED) {
10582                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10583         } else {
10584                 DO_ASSERT(get_jenv_res == JNI_OK);
10585         }
10586         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10587         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10588         LDKFundingCreated msg_var = *msg;
10589         int64_t msg_ref = 0;
10590         msg_var = FundingCreated_clone(&msg_var);
10591         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10592         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10593         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10594         msg_ref = (uintptr_t)msg_var.inner;
10595         if (msg_var.is_owned) {
10596                 msg_ref |= 1;
10597         }
10598         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10599         CHECK(obj != NULL);
10600         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
10601         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10602                 (*env)->ExceptionDescribe(env);
10603                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
10604         }
10605         if (get_jenv_res == JNI_EDETACHED) {
10606                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10607         }
10608 }
10609 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
10610         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10611         JNIEnv *env;
10612         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10613         if (get_jenv_res == JNI_EDETACHED) {
10614                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10615         } else {
10616                 DO_ASSERT(get_jenv_res == JNI_OK);
10617         }
10618         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10619         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10620         LDKFundingSigned msg_var = *msg;
10621         int64_t msg_ref = 0;
10622         msg_var = FundingSigned_clone(&msg_var);
10623         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10624         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10625         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10626         msg_ref = (uintptr_t)msg_var.inner;
10627         if (msg_var.is_owned) {
10628                 msg_ref |= 1;
10629         }
10630         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10631         CHECK(obj != NULL);
10632         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
10633         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10634                 (*env)->ExceptionDescribe(env);
10635                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
10636         }
10637         if (get_jenv_res == JNI_EDETACHED) {
10638                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10639         }
10640 }
10641 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
10642         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10643         JNIEnv *env;
10644         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10645         if (get_jenv_res == JNI_EDETACHED) {
10646                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10647         } else {
10648                 DO_ASSERT(get_jenv_res == JNI_OK);
10649         }
10650         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10651         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10652         LDKFundingLocked msg_var = *msg;
10653         int64_t msg_ref = 0;
10654         msg_var = FundingLocked_clone(&msg_var);
10655         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10656         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10657         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10658         msg_ref = (uintptr_t)msg_var.inner;
10659         if (msg_var.is_owned) {
10660                 msg_ref |= 1;
10661         }
10662         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10663         CHECK(obj != NULL);
10664         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
10665         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10666                 (*env)->ExceptionDescribe(env);
10667                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
10668         }
10669         if (get_jenv_res == JNI_EDETACHED) {
10670                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10671         }
10672 }
10673 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
10674         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10675         JNIEnv *env;
10676         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10677         if (get_jenv_res == JNI_EDETACHED) {
10678                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10679         } else {
10680                 DO_ASSERT(get_jenv_res == JNI_OK);
10681         }
10682         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10683         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10684         LDKInitFeatures their_features_var = *their_features;
10685         int64_t their_features_ref = 0;
10686         their_features_var = InitFeatures_clone(&their_features_var);
10687         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10688         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10689         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10690         their_features_ref = (uintptr_t)their_features_var.inner;
10691         if (their_features_var.is_owned) {
10692                 their_features_ref |= 1;
10693         }
10694         LDKShutdown msg_var = *msg;
10695         int64_t msg_ref = 0;
10696         msg_var = Shutdown_clone(&msg_var);
10697         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10698         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10699         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10700         msg_ref = (uintptr_t)msg_var.inner;
10701         if (msg_var.is_owned) {
10702                 msg_ref |= 1;
10703         }
10704         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10705         CHECK(obj != NULL);
10706         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
10707         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10708                 (*env)->ExceptionDescribe(env);
10709                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
10710         }
10711         if (get_jenv_res == JNI_EDETACHED) {
10712                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10713         }
10714 }
10715 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
10716         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10717         JNIEnv *env;
10718         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10719         if (get_jenv_res == JNI_EDETACHED) {
10720                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10721         } else {
10722                 DO_ASSERT(get_jenv_res == JNI_OK);
10723         }
10724         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10725         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10726         LDKClosingSigned msg_var = *msg;
10727         int64_t msg_ref = 0;
10728         msg_var = ClosingSigned_clone(&msg_var);
10729         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10730         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10731         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10732         msg_ref = (uintptr_t)msg_var.inner;
10733         if (msg_var.is_owned) {
10734                 msg_ref |= 1;
10735         }
10736         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10737         CHECK(obj != NULL);
10738         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
10739         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10740                 (*env)->ExceptionDescribe(env);
10741                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
10742         }
10743         if (get_jenv_res == JNI_EDETACHED) {
10744                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10745         }
10746 }
10747 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
10748         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10749         JNIEnv *env;
10750         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10751         if (get_jenv_res == JNI_EDETACHED) {
10752                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10753         } else {
10754                 DO_ASSERT(get_jenv_res == JNI_OK);
10755         }
10756         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10757         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10758         LDKUpdateAddHTLC msg_var = *msg;
10759         int64_t msg_ref = 0;
10760         msg_var = UpdateAddHTLC_clone(&msg_var);
10761         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10762         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10763         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10764         msg_ref = (uintptr_t)msg_var.inner;
10765         if (msg_var.is_owned) {
10766                 msg_ref |= 1;
10767         }
10768         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10769         CHECK(obj != NULL);
10770         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
10771         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10772                 (*env)->ExceptionDescribe(env);
10773                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
10774         }
10775         if (get_jenv_res == JNI_EDETACHED) {
10776                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10777         }
10778 }
10779 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
10780         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10781         JNIEnv *env;
10782         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10783         if (get_jenv_res == JNI_EDETACHED) {
10784                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10785         } else {
10786                 DO_ASSERT(get_jenv_res == JNI_OK);
10787         }
10788         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10789         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10790         LDKUpdateFulfillHTLC msg_var = *msg;
10791         int64_t msg_ref = 0;
10792         msg_var = UpdateFulfillHTLC_clone(&msg_var);
10793         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10794         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10795         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10796         msg_ref = (uintptr_t)msg_var.inner;
10797         if (msg_var.is_owned) {
10798                 msg_ref |= 1;
10799         }
10800         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10801         CHECK(obj != NULL);
10802         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
10803         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10804                 (*env)->ExceptionDescribe(env);
10805                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
10806         }
10807         if (get_jenv_res == JNI_EDETACHED) {
10808                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10809         }
10810 }
10811 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
10812         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10813         JNIEnv *env;
10814         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10815         if (get_jenv_res == JNI_EDETACHED) {
10816                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10817         } else {
10818                 DO_ASSERT(get_jenv_res == JNI_OK);
10819         }
10820         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10821         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10822         LDKUpdateFailHTLC msg_var = *msg;
10823         int64_t msg_ref = 0;
10824         msg_var = UpdateFailHTLC_clone(&msg_var);
10825         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10826         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10827         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10828         msg_ref = (uintptr_t)msg_var.inner;
10829         if (msg_var.is_owned) {
10830                 msg_ref |= 1;
10831         }
10832         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10833         CHECK(obj != NULL);
10834         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
10835         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10836                 (*env)->ExceptionDescribe(env);
10837                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
10838         }
10839         if (get_jenv_res == JNI_EDETACHED) {
10840                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10841         }
10842 }
10843 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
10844         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10845         JNIEnv *env;
10846         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10847         if (get_jenv_res == JNI_EDETACHED) {
10848                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10849         } else {
10850                 DO_ASSERT(get_jenv_res == JNI_OK);
10851         }
10852         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10853         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10854         LDKUpdateFailMalformedHTLC msg_var = *msg;
10855         int64_t msg_ref = 0;
10856         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
10857         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10858         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10859         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10860         msg_ref = (uintptr_t)msg_var.inner;
10861         if (msg_var.is_owned) {
10862                 msg_ref |= 1;
10863         }
10864         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10865         CHECK(obj != NULL);
10866         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
10867         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10868                 (*env)->ExceptionDescribe(env);
10869                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
10870         }
10871         if (get_jenv_res == JNI_EDETACHED) {
10872                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10873         }
10874 }
10875 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
10876         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10877         JNIEnv *env;
10878         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10879         if (get_jenv_res == JNI_EDETACHED) {
10880                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10881         } else {
10882                 DO_ASSERT(get_jenv_res == JNI_OK);
10883         }
10884         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10885         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10886         LDKCommitmentSigned msg_var = *msg;
10887         int64_t msg_ref = 0;
10888         msg_var = CommitmentSigned_clone(&msg_var);
10889         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10890         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10892         msg_ref = (uintptr_t)msg_var.inner;
10893         if (msg_var.is_owned) {
10894                 msg_ref |= 1;
10895         }
10896         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10897         CHECK(obj != NULL);
10898         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
10899         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10900                 (*env)->ExceptionDescribe(env);
10901                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
10902         }
10903         if (get_jenv_res == JNI_EDETACHED) {
10904                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10905         }
10906 }
10907 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
10908         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10909         JNIEnv *env;
10910         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10911         if (get_jenv_res == JNI_EDETACHED) {
10912                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10913         } else {
10914                 DO_ASSERT(get_jenv_res == JNI_OK);
10915         }
10916         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10917         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10918         LDKRevokeAndACK msg_var = *msg;
10919         int64_t msg_ref = 0;
10920         msg_var = RevokeAndACK_clone(&msg_var);
10921         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10922         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10924         msg_ref = (uintptr_t)msg_var.inner;
10925         if (msg_var.is_owned) {
10926                 msg_ref |= 1;
10927         }
10928         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10929         CHECK(obj != NULL);
10930         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
10931         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10932                 (*env)->ExceptionDescribe(env);
10933                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
10934         }
10935         if (get_jenv_res == JNI_EDETACHED) {
10936                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10937         }
10938 }
10939 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
10940         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10941         JNIEnv *env;
10942         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10943         if (get_jenv_res == JNI_EDETACHED) {
10944                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10945         } else {
10946                 DO_ASSERT(get_jenv_res == JNI_OK);
10947         }
10948         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10949         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10950         LDKUpdateFee msg_var = *msg;
10951         int64_t msg_ref = 0;
10952         msg_var = UpdateFee_clone(&msg_var);
10953         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10954         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10955         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10956         msg_ref = (uintptr_t)msg_var.inner;
10957         if (msg_var.is_owned) {
10958                 msg_ref |= 1;
10959         }
10960         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10961         CHECK(obj != NULL);
10962         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
10963         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10964                 (*env)->ExceptionDescribe(env);
10965                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
10966         }
10967         if (get_jenv_res == JNI_EDETACHED) {
10968                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10969         }
10970 }
10971 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
10972         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10973         JNIEnv *env;
10974         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10975         if (get_jenv_res == JNI_EDETACHED) {
10976                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10977         } else {
10978                 DO_ASSERT(get_jenv_res == JNI_OK);
10979         }
10980         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10981         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10982         LDKAnnouncementSignatures msg_var = *msg;
10983         int64_t msg_ref = 0;
10984         msg_var = AnnouncementSignatures_clone(&msg_var);
10985         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10986         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10987         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10988         msg_ref = (uintptr_t)msg_var.inner;
10989         if (msg_var.is_owned) {
10990                 msg_ref |= 1;
10991         }
10992         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10993         CHECK(obj != NULL);
10994         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
10995         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10996                 (*env)->ExceptionDescribe(env);
10997                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
10998         }
10999         if (get_jenv_res == JNI_EDETACHED) {
11000                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11001         }
11002 }
11003 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
11004         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11005         JNIEnv *env;
11006         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11007         if (get_jenv_res == JNI_EDETACHED) {
11008                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11009         } else {
11010                 DO_ASSERT(get_jenv_res == JNI_OK);
11011         }
11012         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11013         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11014         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11015         CHECK(obj != NULL);
11016         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
11017         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11018                 (*env)->ExceptionDescribe(env);
11019                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
11020         }
11021         if (get_jenv_res == JNI_EDETACHED) {
11022                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11023         }
11024 }
11025 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
11026         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11027         JNIEnv *env;
11028         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11029         if (get_jenv_res == JNI_EDETACHED) {
11030                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11031         } else {
11032                 DO_ASSERT(get_jenv_res == JNI_OK);
11033         }
11034         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11035         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11036         LDKInit msg_var = *msg;
11037         int64_t msg_ref = 0;
11038         msg_var = Init_clone(&msg_var);
11039         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11040         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11041         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11042         msg_ref = (uintptr_t)msg_var.inner;
11043         if (msg_var.is_owned) {
11044                 msg_ref |= 1;
11045         }
11046         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11047         CHECK(obj != NULL);
11048         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
11049         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11050                 (*env)->ExceptionDescribe(env);
11051                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
11052         }
11053         if (get_jenv_res == JNI_EDETACHED) {
11054                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11055         }
11056 }
11057 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
11058         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_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         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11067         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11068         LDKChannelReestablish msg_var = *msg;
11069         int64_t msg_ref = 0;
11070         msg_var = ChannelReestablish_clone(&msg_var);
11071         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11072         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11073         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11074         msg_ref = (uintptr_t)msg_var.inner;
11075         if (msg_var.is_owned) {
11076                 msg_ref |= 1;
11077         }
11078         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11079         CHECK(obj != NULL);
11080         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
11081         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11082                 (*env)->ExceptionDescribe(env);
11083                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
11084         }
11085         if (get_jenv_res == JNI_EDETACHED) {
11086                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11087         }
11088 }
11089 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
11090         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11091         JNIEnv *env;
11092         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11093         if (get_jenv_res == JNI_EDETACHED) {
11094                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11095         } else {
11096                 DO_ASSERT(get_jenv_res == JNI_OK);
11097         }
11098         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11099         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11100         LDKChannelUpdate msg_var = *msg;
11101         int64_t msg_ref = 0;
11102         msg_var = ChannelUpdate_clone(&msg_var);
11103         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11104         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11105         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11106         msg_ref = (uintptr_t)msg_var.inner;
11107         if (msg_var.is_owned) {
11108                 msg_ref |= 1;
11109         }
11110         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11111         CHECK(obj != NULL);
11112         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
11113         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11114                 (*env)->ExceptionDescribe(env);
11115                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
11116         }
11117         if (get_jenv_res == JNI_EDETACHED) {
11118                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11119         }
11120 }
11121 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
11122         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11123         JNIEnv *env;
11124         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11125         if (get_jenv_res == JNI_EDETACHED) {
11126                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11127         } else {
11128                 DO_ASSERT(get_jenv_res == JNI_OK);
11129         }
11130         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11131         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11132         LDKErrorMessage msg_var = *msg;
11133         int64_t msg_ref = 0;
11134         msg_var = ErrorMessage_clone(&msg_var);
11135         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11136         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11137         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11138         msg_ref = (uintptr_t)msg_var.inner;
11139         if (msg_var.is_owned) {
11140                 msg_ref |= 1;
11141         }
11142         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11143         CHECK(obj != NULL);
11144         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
11145         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11146                 (*env)->ExceptionDescribe(env);
11147                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
11148         }
11149         if (get_jenv_res == JNI_EDETACHED) {
11150                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11151         }
11152 }
11153 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
11154         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
11155         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11156         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
11157 }
11158 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11159         jclass c = (*env)->GetObjectClass(env, o);
11160         CHECK(c != NULL);
11161         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
11162         atomic_init(&calls->refcnt, 1);
11163         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11164         calls->o = (*env)->NewWeakGlobalRef(env, o);
11165         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
11166         CHECK(calls->handle_open_channel_meth != NULL);
11167         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
11168         CHECK(calls->handle_accept_channel_meth != NULL);
11169         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
11170         CHECK(calls->handle_funding_created_meth != NULL);
11171         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
11172         CHECK(calls->handle_funding_signed_meth != NULL);
11173         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
11174         CHECK(calls->handle_funding_locked_meth != NULL);
11175         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
11176         CHECK(calls->handle_shutdown_meth != NULL);
11177         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
11178         CHECK(calls->handle_closing_signed_meth != NULL);
11179         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
11180         CHECK(calls->handle_update_add_htlc_meth != NULL);
11181         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
11182         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
11183         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
11184         CHECK(calls->handle_update_fail_htlc_meth != NULL);
11185         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
11186         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
11187         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
11188         CHECK(calls->handle_commitment_signed_meth != NULL);
11189         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
11190         CHECK(calls->handle_revoke_and_ack_meth != NULL);
11191         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
11192         CHECK(calls->handle_update_fee_meth != NULL);
11193         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
11194         CHECK(calls->handle_announcement_signatures_meth != NULL);
11195         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
11196         CHECK(calls->peer_disconnected_meth != NULL);
11197         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
11198         CHECK(calls->peer_connected_meth != NULL);
11199         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
11200         CHECK(calls->handle_channel_reestablish_meth != NULL);
11201         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
11202         CHECK(calls->handle_channel_update_meth != NULL);
11203         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
11204         CHECK(calls->handle_error_meth != NULL);
11205
11206         LDKChannelMessageHandler ret = {
11207                 .this_arg = (void*) calls,
11208                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
11209                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
11210                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
11211                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
11212                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
11213                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
11214                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
11215                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
11216                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
11217                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
11218                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
11219                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
11220                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
11221                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
11222                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
11223                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
11224                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
11225                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
11226                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
11227                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
11228                 .free = LDKChannelMessageHandler_JCalls_free,
11229                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
11230         };
11231         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
11232         return ret;
11233 }
11234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11235         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11236         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
11237         return (uint64_t)res_ptr;
11238 }
11239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
11240         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
11241         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
11242         DO_ASSERT((res_ptr & 1) == 0);
11243         return (int64_t)(res_ptr | 1);
11244 }
11245 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) {
11246         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11247         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11248         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11249         LDKPublicKey their_node_id_ref;
11250         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11251         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11252         LDKInitFeatures their_features_conv;
11253         their_features_conv.inner = (void*)(their_features & (~1));
11254         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11255         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11256         their_features_conv = InitFeatures_clone(&their_features_conv);
11257         LDKOpenChannel msg_conv;
11258         msg_conv.inner = (void*)(msg & (~1));
11259         msg_conv.is_owned = false;
11260         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11261         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11262 }
11263
11264 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) {
11265         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11266         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11267         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11268         LDKPublicKey their_node_id_ref;
11269         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11270         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11271         LDKInitFeatures their_features_conv;
11272         their_features_conv.inner = (void*)(their_features & (~1));
11273         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11274         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11275         their_features_conv = InitFeatures_clone(&their_features_conv);
11276         LDKAcceptChannel msg_conv;
11277         msg_conv.inner = (void*)(msg & (~1));
11278         msg_conv.is_owned = false;
11279         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11280         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11281 }
11282
11283 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) {
11284         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11285         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11286         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11287         LDKPublicKey their_node_id_ref;
11288         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11289         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11290         LDKFundingCreated msg_conv;
11291         msg_conv.inner = (void*)(msg & (~1));
11292         msg_conv.is_owned = false;
11293         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11294         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11295 }
11296
11297 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) {
11298         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11299         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11300         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11301         LDKPublicKey their_node_id_ref;
11302         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11303         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11304         LDKFundingSigned msg_conv;
11305         msg_conv.inner = (void*)(msg & (~1));
11306         msg_conv.is_owned = false;
11307         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11308         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11309 }
11310
11311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
11312         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11313         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11314         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11315         LDKPublicKey their_node_id_ref;
11316         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11317         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11318         LDKFundingLocked msg_conv;
11319         msg_conv.inner = (void*)(msg & (~1));
11320         msg_conv.is_owned = false;
11321         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11322         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11323 }
11324
11325 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) {
11326         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11327         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11328         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11329         LDKPublicKey their_node_id_ref;
11330         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11331         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11332         LDKInitFeatures their_features_conv;
11333         their_features_conv.inner = (void*)(their_features & (~1));
11334         their_features_conv.is_owned = false;
11335         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11336         LDKShutdown msg_conv;
11337         msg_conv.inner = (void*)(msg & (~1));
11338         msg_conv.is_owned = false;
11339         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11340         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
11341 }
11342
11343 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) {
11344         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11345         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11346         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11347         LDKPublicKey their_node_id_ref;
11348         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11349         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11350         LDKClosingSigned msg_conv;
11351         msg_conv.inner = (void*)(msg & (~1));
11352         msg_conv.is_owned = false;
11353         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11354         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11355 }
11356
11357 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) {
11358         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11359         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11360         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11361         LDKPublicKey their_node_id_ref;
11362         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11363         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11364         LDKUpdateAddHTLC msg_conv;
11365         msg_conv.inner = (void*)(msg & (~1));
11366         msg_conv.is_owned = false;
11367         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11368         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11369 }
11370
11371 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) {
11372         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11373         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11374         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11375         LDKPublicKey their_node_id_ref;
11376         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11377         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11378         LDKUpdateFulfillHTLC msg_conv;
11379         msg_conv.inner = (void*)(msg & (~1));
11380         msg_conv.is_owned = false;
11381         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11382         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11383 }
11384
11385 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) {
11386         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11387         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11388         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11389         LDKPublicKey their_node_id_ref;
11390         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11391         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11392         LDKUpdateFailHTLC msg_conv;
11393         msg_conv.inner = (void*)(msg & (~1));
11394         msg_conv.is_owned = false;
11395         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11396         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11397 }
11398
11399 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) {
11400         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11401         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11402         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11403         LDKPublicKey their_node_id_ref;
11404         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11405         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11406         LDKUpdateFailMalformedHTLC msg_conv;
11407         msg_conv.inner = (void*)(msg & (~1));
11408         msg_conv.is_owned = false;
11409         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11410         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11411 }
11412
11413 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) {
11414         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11415         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11416         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11417         LDKPublicKey their_node_id_ref;
11418         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11419         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11420         LDKCommitmentSigned msg_conv;
11421         msg_conv.inner = (void*)(msg & (~1));
11422         msg_conv.is_owned = false;
11423         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11424         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11425 }
11426
11427 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) {
11428         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11429         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11430         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11431         LDKPublicKey their_node_id_ref;
11432         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11433         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11434         LDKRevokeAndACK msg_conv;
11435         msg_conv.inner = (void*)(msg & (~1));
11436         msg_conv.is_owned = false;
11437         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11438         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11439 }
11440
11441 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) {
11442         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11443         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11444         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11445         LDKPublicKey their_node_id_ref;
11446         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11447         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11448         LDKUpdateFee msg_conv;
11449         msg_conv.inner = (void*)(msg & (~1));
11450         msg_conv.is_owned = false;
11451         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11452         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11453 }
11454
11455 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) {
11456         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11457         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11458         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11459         LDKPublicKey their_node_id_ref;
11460         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11461         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11462         LDKAnnouncementSignatures msg_conv;
11463         msg_conv.inner = (void*)(msg & (~1));
11464         msg_conv.is_owned = false;
11465         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11466         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11467 }
11468
11469 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) {
11470         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11471         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11472         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11473         LDKPublicKey their_node_id_ref;
11474         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11475         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11476         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
11477 }
11478
11479 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) {
11480         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11481         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11482         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11483         LDKPublicKey their_node_id_ref;
11484         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11485         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11486         LDKInit msg_conv;
11487         msg_conv.inner = (void*)(msg & (~1));
11488         msg_conv.is_owned = false;
11489         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11490         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11491 }
11492
11493 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) {
11494         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11495         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11496         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11497         LDKPublicKey their_node_id_ref;
11498         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11499         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11500         LDKChannelReestablish msg_conv;
11501         msg_conv.inner = (void*)(msg & (~1));
11502         msg_conv.is_owned = false;
11503         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11504         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11505 }
11506
11507 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) {
11508         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11509         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11510         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11511         LDKPublicKey their_node_id_ref;
11512         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11513         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11514         LDKChannelUpdate msg_conv;
11515         msg_conv.inner = (void*)(msg & (~1));
11516         msg_conv.is_owned = false;
11517         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11518         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11519 }
11520
11521 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) {
11522         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11523         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11524         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11525         LDKPublicKey their_node_id_ref;
11526         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11527         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11528         LDKErrorMessage msg_conv;
11529         msg_conv.inner = (void*)(msg & (~1));
11530         msg_conv.is_owned = false;
11531         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11532         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11533 }
11534
11535 typedef struct LDKRoutingMessageHandler_JCalls {
11536         atomic_size_t refcnt;
11537         JavaVM *vm;
11538         jweak o;
11539         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11540         jmethodID handle_node_announcement_meth;
11541         jmethodID handle_channel_announcement_meth;
11542         jmethodID handle_channel_update_meth;
11543         jmethodID get_next_channel_announcements_meth;
11544         jmethodID get_next_node_announcements_meth;
11545         jmethodID sync_routing_table_meth;
11546         jmethodID handle_reply_channel_range_meth;
11547         jmethodID handle_reply_short_channel_ids_end_meth;
11548         jmethodID handle_query_channel_range_meth;
11549         jmethodID handle_query_short_channel_ids_meth;
11550 } LDKRoutingMessageHandler_JCalls;
11551 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
11552         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11553         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11554                 JNIEnv *env;
11555                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11556                 if (get_jenv_res == JNI_EDETACHED) {
11557                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11558                 } else {
11559                         DO_ASSERT(get_jenv_res == JNI_OK);
11560                 }
11561                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11562                 if (get_jenv_res == JNI_EDETACHED) {
11563                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11564                 }
11565                 FREE(j_calls);
11566         }
11567 }
11568 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
11569         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11570         JNIEnv *env;
11571         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11572         if (get_jenv_res == JNI_EDETACHED) {
11573                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11574         } else {
11575                 DO_ASSERT(get_jenv_res == JNI_OK);
11576         }
11577         LDKNodeAnnouncement msg_var = *msg;
11578         int64_t msg_ref = 0;
11579         msg_var = NodeAnnouncement_clone(&msg_var);
11580         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11581         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11582         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11583         msg_ref = (uintptr_t)msg_var.inner;
11584         if (msg_var.is_owned) {
11585                 msg_ref |= 1;
11586         }
11587         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11588         CHECK(obj != NULL);
11589         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
11590         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11591                 (*env)->ExceptionDescribe(env);
11592                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11593         }
11594         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11595         CHECK_ACCESS(ret_ptr);
11596         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11597         FREE((void*)ret);
11598         if (get_jenv_res == JNI_EDETACHED) {
11599                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11600         }
11601         return ret_conv;
11602 }
11603 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
11604         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11605         JNIEnv *env;
11606         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11607         if (get_jenv_res == JNI_EDETACHED) {
11608                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11609         } else {
11610                 DO_ASSERT(get_jenv_res == JNI_OK);
11611         }
11612         LDKChannelAnnouncement msg_var = *msg;
11613         int64_t msg_ref = 0;
11614         msg_var = ChannelAnnouncement_clone(&msg_var);
11615         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11616         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11617         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11618         msg_ref = (uintptr_t)msg_var.inner;
11619         if (msg_var.is_owned) {
11620                 msg_ref |= 1;
11621         }
11622         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11623         CHECK(obj != NULL);
11624         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
11625         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11626                 (*env)->ExceptionDescribe(env);
11627                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11628         }
11629         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11630         CHECK_ACCESS(ret_ptr);
11631         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11632         FREE((void*)ret);
11633         if (get_jenv_res == JNI_EDETACHED) {
11634                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11635         }
11636         return ret_conv;
11637 }
11638 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
11639         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11640         JNIEnv *env;
11641         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11642         if (get_jenv_res == JNI_EDETACHED) {
11643                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11644         } else {
11645                 DO_ASSERT(get_jenv_res == JNI_OK);
11646         }
11647         LDKChannelUpdate msg_var = *msg;
11648         int64_t msg_ref = 0;
11649         msg_var = ChannelUpdate_clone(&msg_var);
11650         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11651         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11652         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11653         msg_ref = (uintptr_t)msg_var.inner;
11654         if (msg_var.is_owned) {
11655                 msg_ref |= 1;
11656         }
11657         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11658         CHECK(obj != NULL);
11659         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
11660         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11661                 (*env)->ExceptionDescribe(env);
11662                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
11663         }
11664         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11665         CHECK_ACCESS(ret_ptr);
11666         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11667         FREE((void*)ret);
11668         if (get_jenv_res == JNI_EDETACHED) {
11669                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11670         }
11671         return ret_conv;
11672 }
11673 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
11674         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11675         JNIEnv *env;
11676         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11677         if (get_jenv_res == JNI_EDETACHED) {
11678                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11679         } else {
11680                 DO_ASSERT(get_jenv_res == JNI_OK);
11681         }
11682         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11683         CHECK(obj != NULL);
11684         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
11685         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11686                 (*env)->ExceptionDescribe(env);
11687                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
11688         }
11689         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
11690         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11691         if (ret_constr.datalen > 0)
11692                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11693         else
11694                 ret_constr.data = NULL;
11695         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11696         for (size_t h = 0; h < ret_constr.datalen; h++) {
11697                 int64_t ret_conv_59 = ret_vals[h];
11698                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
11699                 CHECK_ACCESS(ret_conv_59_ptr);
11700                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
11701                 FREE((void*)ret_conv_59);
11702                 ret_constr.data[h] = ret_conv_59_conv;
11703         }
11704         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11705         if (get_jenv_res == JNI_EDETACHED) {
11706                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11707         }
11708         return ret_constr;
11709 }
11710 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
11711         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11712         JNIEnv *env;
11713         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11714         if (get_jenv_res == JNI_EDETACHED) {
11715                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11716         } else {
11717                 DO_ASSERT(get_jenv_res == JNI_OK);
11718         }
11719         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
11720         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
11721         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11722         CHECK(obj != NULL);
11723         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
11724         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11725                 (*env)->ExceptionDescribe(env);
11726                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
11727         }
11728         LDKCVec_NodeAnnouncementZ ret_constr;
11729         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11730         if (ret_constr.datalen > 0)
11731                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11732         else
11733                 ret_constr.data = NULL;
11734         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11735         for (size_t s = 0; s < ret_constr.datalen; s++) {
11736                 int64_t ret_conv_18 = ret_vals[s];
11737                 LDKNodeAnnouncement ret_conv_18_conv;
11738                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
11739                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
11740                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
11741                 ret_constr.data[s] = ret_conv_18_conv;
11742         }
11743         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11744         if (get_jenv_res == JNI_EDETACHED) {
11745                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11746         }
11747         return ret_constr;
11748 }
11749 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
11750         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11751         JNIEnv *env;
11752         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11753         if (get_jenv_res == JNI_EDETACHED) {
11754                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11755         } else {
11756                 DO_ASSERT(get_jenv_res == JNI_OK);
11757         }
11758         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11759         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11760         LDKInit init_var = *init;
11761         int64_t init_ref = 0;
11762         init_var = Init_clone(&init_var);
11763         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11764         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11765         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
11766         init_ref = (uintptr_t)init_var.inner;
11767         if (init_var.is_owned) {
11768                 init_ref |= 1;
11769         }
11770         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11771         CHECK(obj != NULL);
11772         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
11773         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11774                 (*env)->ExceptionDescribe(env);
11775                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
11776         }
11777         if (get_jenv_res == JNI_EDETACHED) {
11778                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11779         }
11780 }
11781 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
11782         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11783         JNIEnv *env;
11784         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11785         if (get_jenv_res == JNI_EDETACHED) {
11786                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11787         } else {
11788                 DO_ASSERT(get_jenv_res == JNI_OK);
11789         }
11790         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11791         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11792         LDKReplyChannelRange msg_var = msg;
11793         int64_t msg_ref = 0;
11794         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11795         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11796         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11797         msg_ref = (uintptr_t)msg_var.inner;
11798         if (msg_var.is_owned) {
11799                 msg_ref |= 1;
11800         }
11801         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11802         CHECK(obj != NULL);
11803         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
11804         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11805                 (*env)->ExceptionDescribe(env);
11806                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
11807         }
11808         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11809         CHECK_ACCESS(ret_ptr);
11810         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11811         FREE((void*)ret);
11812         if (get_jenv_res == JNI_EDETACHED) {
11813                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11814         }
11815         return ret_conv;
11816 }
11817 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
11818         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11819         JNIEnv *env;
11820         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11821         if (get_jenv_res == JNI_EDETACHED) {
11822                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11823         } else {
11824                 DO_ASSERT(get_jenv_res == JNI_OK);
11825         }
11826         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11827         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11828         LDKReplyShortChannelIdsEnd msg_var = msg;
11829         int64_t msg_ref = 0;
11830         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11831         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11832         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11833         msg_ref = (uintptr_t)msg_var.inner;
11834         if (msg_var.is_owned) {
11835                 msg_ref |= 1;
11836         }
11837         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11838         CHECK(obj != NULL);
11839         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
11840         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11841                 (*env)->ExceptionDescribe(env);
11842                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
11843         }
11844         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11845         CHECK_ACCESS(ret_ptr);
11846         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11847         FREE((void*)ret);
11848         if (get_jenv_res == JNI_EDETACHED) {
11849                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11850         }
11851         return ret_conv;
11852 }
11853 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
11854         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11855         JNIEnv *env;
11856         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11857         if (get_jenv_res == JNI_EDETACHED) {
11858                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11859         } else {
11860                 DO_ASSERT(get_jenv_res == JNI_OK);
11861         }
11862         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11863         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11864         LDKQueryChannelRange msg_var = msg;
11865         int64_t msg_ref = 0;
11866         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11867         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11868         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11869         msg_ref = (uintptr_t)msg_var.inner;
11870         if (msg_var.is_owned) {
11871                 msg_ref |= 1;
11872         }
11873         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11874         CHECK(obj != NULL);
11875         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
11876         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11877                 (*env)->ExceptionDescribe(env);
11878                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
11879         }
11880         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11881         CHECK_ACCESS(ret_ptr);
11882         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11883         FREE((void*)ret);
11884         if (get_jenv_res == JNI_EDETACHED) {
11885                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11886         }
11887         return ret_conv;
11888 }
11889 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
11890         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11891         JNIEnv *env;
11892         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11893         if (get_jenv_res == JNI_EDETACHED) {
11894                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11895         } else {
11896                 DO_ASSERT(get_jenv_res == JNI_OK);
11897         }
11898         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11899         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11900         LDKQueryShortChannelIds msg_var = msg;
11901         int64_t msg_ref = 0;
11902         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11903         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11904         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11905         msg_ref = (uintptr_t)msg_var.inner;
11906         if (msg_var.is_owned) {
11907                 msg_ref |= 1;
11908         }
11909         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11910         CHECK(obj != NULL);
11911         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
11912         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11913                 (*env)->ExceptionDescribe(env);
11914                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
11915         }
11916         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11917         CHECK_ACCESS(ret_ptr);
11918         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11919         FREE((void*)ret);
11920         if (get_jenv_res == JNI_EDETACHED) {
11921                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11922         }
11923         return ret_conv;
11924 }
11925 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
11926         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
11927         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11928         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
11929 }
11930 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11931         jclass c = (*env)->GetObjectClass(env, o);
11932         CHECK(c != NULL);
11933         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
11934         atomic_init(&calls->refcnt, 1);
11935         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11936         calls->o = (*env)->NewWeakGlobalRef(env, o);
11937         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
11938         CHECK(calls->handle_node_announcement_meth != NULL);
11939         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
11940         CHECK(calls->handle_channel_announcement_meth != NULL);
11941         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
11942         CHECK(calls->handle_channel_update_meth != NULL);
11943         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
11944         CHECK(calls->get_next_channel_announcements_meth != NULL);
11945         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
11946         CHECK(calls->get_next_node_announcements_meth != NULL);
11947         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
11948         CHECK(calls->sync_routing_table_meth != NULL);
11949         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
11950         CHECK(calls->handle_reply_channel_range_meth != NULL);
11951         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
11952         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
11953         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
11954         CHECK(calls->handle_query_channel_range_meth != NULL);
11955         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
11956         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
11957
11958         LDKRoutingMessageHandler ret = {
11959                 .this_arg = (void*) calls,
11960                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
11961                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
11962                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
11963                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
11964                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
11965                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
11966                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
11967                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
11968                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
11969                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
11970                 .free = LDKRoutingMessageHandler_JCalls_free,
11971                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
11972         };
11973         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
11974         return ret;
11975 }
11976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11977         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
11978         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
11979         return (uint64_t)res_ptr;
11980 }
11981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
11982         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
11983         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
11984         DO_ASSERT((res_ptr & 1) == 0);
11985         return (int64_t)(res_ptr | 1);
11986 }
11987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
11988         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11989         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11990         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11991         LDKNodeAnnouncement msg_conv;
11992         msg_conv.inner = (void*)(msg & (~1));
11993         msg_conv.is_owned = false;
11994         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11995         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11996         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
11997         return (int64_t)ret_conv;
11998 }
11999
12000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12001         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12002         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12003         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12004         LDKChannelAnnouncement msg_conv;
12005         msg_conv.inner = (void*)(msg & (~1));
12006         msg_conv.is_owned = false;
12007         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12008         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12009         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
12010         return (int64_t)ret_conv;
12011 }
12012
12013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12014         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12015         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12016         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12017         LDKChannelUpdate msg_conv;
12018         msg_conv.inner = (void*)(msg & (~1));
12019         msg_conv.is_owned = false;
12020         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12021         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12022         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
12023         return (int64_t)ret_conv;
12024 }
12025
12026 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) {
12027         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12028         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12029         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12030         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
12031         int64_tArray ret_arr = NULL;
12032         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12033         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12034         for (size_t h = 0; h < ret_var.datalen; h++) {
12035                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
12036                 *ret_conv_59_conv = ret_var.data[h];
12037                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
12038         }
12039         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12040         FREE(ret_var.data);
12041         return ret_arr;
12042 }
12043
12044 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) {
12045         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12046         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12047         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12048         LDKPublicKey starting_point_ref;
12049         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
12050         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
12051         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
12052         int64_tArray ret_arr = NULL;
12053         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12054         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12055         for (size_t s = 0; s < ret_var.datalen; s++) {
12056                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
12057                 int64_t ret_conv_18_ref = 0;
12058                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12059                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12060                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
12061                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
12062                 if (ret_conv_18_var.is_owned) {
12063                         ret_conv_18_ref |= 1;
12064                 }
12065                 ret_arr_ptr[s] = ret_conv_18_ref;
12066         }
12067         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12068         FREE(ret_var.data);
12069         return ret_arr;
12070 }
12071
12072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
12073         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12074         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12075         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12076         LDKPublicKey their_node_id_ref;
12077         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12078         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12079         LDKInit init_conv;
12080         init_conv.inner = (void*)(init & (~1));
12081         init_conv.is_owned = false;
12082         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
12083         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
12084 }
12085
12086 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) {
12087         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12088         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12089         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12090         LDKPublicKey their_node_id_ref;
12091         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12092         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12093         LDKReplyChannelRange msg_conv;
12094         msg_conv.inner = (void*)(msg & (~1));
12095         msg_conv.is_owned = (msg & 1) || (msg == 0);
12096         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12097         msg_conv = ReplyChannelRange_clone(&msg_conv);
12098         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12099         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12100         return (int64_t)ret_conv;
12101 }
12102
12103 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) {
12104         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12105         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12106         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12107         LDKPublicKey their_node_id_ref;
12108         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12109         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12110         LDKReplyShortChannelIdsEnd msg_conv;
12111         msg_conv.inner = (void*)(msg & (~1));
12112         msg_conv.is_owned = (msg & 1) || (msg == 0);
12113         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12114         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
12115         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12116         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12117         return (int64_t)ret_conv;
12118 }
12119
12120 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) {
12121         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12122         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12123         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12124         LDKPublicKey their_node_id_ref;
12125         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12126         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12127         LDKQueryChannelRange msg_conv;
12128         msg_conv.inner = (void*)(msg & (~1));
12129         msg_conv.is_owned = (msg & 1) || (msg == 0);
12130         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12131         msg_conv = QueryChannelRange_clone(&msg_conv);
12132         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12133         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12134         return (int64_t)ret_conv;
12135 }
12136
12137 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) {
12138         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12139         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12140         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12141         LDKPublicKey their_node_id_ref;
12142         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12143         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12144         LDKQueryShortChannelIds msg_conv;
12145         msg_conv.inner = (void*)(msg & (~1));
12146         msg_conv.is_owned = (msg & 1) || (msg == 0);
12147         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12148         msg_conv = QueryShortChannelIds_clone(&msg_conv);
12149         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12150         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12151         return (int64_t)ret_conv;
12152 }
12153
12154 typedef struct LDKCustomMessageReader_JCalls {
12155         atomic_size_t refcnt;
12156         JavaVM *vm;
12157         jweak o;
12158         jmethodID read_meth;
12159 } LDKCustomMessageReader_JCalls;
12160 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
12161         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12162         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12163                 JNIEnv *env;
12164                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12165                 if (get_jenv_res == JNI_EDETACHED) {
12166                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12167                 } else {
12168                         DO_ASSERT(get_jenv_res == JNI_OK);
12169                 }
12170                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12171                 if (get_jenv_res == JNI_EDETACHED) {
12172                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12173                 }
12174                 FREE(j_calls);
12175         }
12176 }
12177 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
12178         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_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         LDKu8slice buffer_var = buffer;
12187         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
12188         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
12189         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12190         CHECK(obj != NULL);
12191         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
12192         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12193                 (*env)->ExceptionDescribe(env);
12194                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
12195         }
12196         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12197         CHECK_ACCESS(ret_ptr);
12198         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
12199         FREE((void*)ret);
12200         if (get_jenv_res == JNI_EDETACHED) {
12201                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12202         }
12203         return ret_conv;
12204 }
12205 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
12206         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
12207         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12208 }
12209 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
12210         jclass c = (*env)->GetObjectClass(env, o);
12211         CHECK(c != NULL);
12212         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
12213         atomic_init(&calls->refcnt, 1);
12214         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12215         calls->o = (*env)->NewWeakGlobalRef(env, o);
12216         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
12217         CHECK(calls->read_meth != NULL);
12218
12219         LDKCustomMessageReader ret = {
12220                 .this_arg = (void*) calls,
12221                 .read = read_LDKCustomMessageReader_jcall,
12222                 .free = LDKCustomMessageReader_JCalls_free,
12223         };
12224         return ret;
12225 }
12226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
12227         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
12228         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
12229         return (uint64_t)res_ptr;
12230 }
12231 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) {
12232         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12233         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12234         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
12235         LDKu8slice buffer_ref;
12236         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
12237         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
12238         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12239         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
12240         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
12241         return (int64_t)ret_conv;
12242 }
12243
12244 typedef struct LDKCustomMessageHandler_JCalls {
12245         atomic_size_t refcnt;
12246         JavaVM *vm;
12247         jweak o;
12248         LDKCustomMessageReader_JCalls* CustomMessageReader;
12249         jmethodID handle_custom_message_meth;
12250         jmethodID get_and_clear_pending_msg_meth;
12251 } LDKCustomMessageHandler_JCalls;
12252 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
12253         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12254         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12255                 JNIEnv *env;
12256                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12257                 if (get_jenv_res == JNI_EDETACHED) {
12258                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12259                 } else {
12260                         DO_ASSERT(get_jenv_res == JNI_OK);
12261                 }
12262                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12263                 if (get_jenv_res == JNI_EDETACHED) {
12264                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12265                 }
12266                 FREE(j_calls);
12267         }
12268 }
12269 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
12270         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12271         JNIEnv *env;
12272         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12273         if (get_jenv_res == JNI_EDETACHED) {
12274                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12275         } else {
12276                 DO_ASSERT(get_jenv_res == JNI_OK);
12277         }
12278         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
12279         *msg_ret = msg;
12280         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
12281         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
12282         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12283         CHECK(obj != NULL);
12284         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
12285         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12286                 (*env)->ExceptionDescribe(env);
12287                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
12288         }
12289         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12290         CHECK_ACCESS(ret_ptr);
12291         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12292         FREE((void*)ret);
12293         if (get_jenv_res == JNI_EDETACHED) {
12294                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12295         }
12296         return ret_conv;
12297 }
12298 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
12299         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12300         JNIEnv *env;
12301         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12302         if (get_jenv_res == JNI_EDETACHED) {
12303                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12304         } else {
12305                 DO_ASSERT(get_jenv_res == JNI_OK);
12306         }
12307         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12308         CHECK(obj != NULL);
12309         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
12310         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12311                 (*env)->ExceptionDescribe(env);
12312                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
12313         }
12314         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
12315         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12316         if (ret_constr.datalen > 0)
12317                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
12318         else
12319                 ret_constr.data = NULL;
12320         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12321         for (size_t z = 0; z < ret_constr.datalen; z++) {
12322                 int64_t ret_conv_25 = ret_vals[z];
12323                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
12324                 CHECK_ACCESS(ret_conv_25_ptr);
12325                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
12326                 FREE((void*)ret_conv_25);
12327                 ret_constr.data[z] = ret_conv_25_conv;
12328         }
12329         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12330         if (get_jenv_res == JNI_EDETACHED) {
12331                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12332         }
12333         return ret_constr;
12334 }
12335 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
12336         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
12337         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12338         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
12339 }
12340 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12341         jclass c = (*env)->GetObjectClass(env, o);
12342         CHECK(c != NULL);
12343         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
12344         atomic_init(&calls->refcnt, 1);
12345         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12346         calls->o = (*env)->NewWeakGlobalRef(env, o);
12347         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
12348         CHECK(calls->handle_custom_message_meth != NULL);
12349         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
12350         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
12351
12352         LDKCustomMessageHandler ret = {
12353                 .this_arg = (void*) calls,
12354                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
12355                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
12356                 .free = LDKCustomMessageHandler_JCalls_free,
12357                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
12358         };
12359         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
12360         return ret;
12361 }
12362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12363         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
12364         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
12365         return (uint64_t)res_ptr;
12366 }
12367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
12368         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
12369         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
12370         DO_ASSERT((res_ptr & 1) == 0);
12371         return (int64_t)(res_ptr | 1);
12372 }
12373 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) {
12374         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12375         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12376         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12377         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
12378         CHECK_ACCESS(msg_ptr);
12379         LDKType msg_conv = *(LDKType*)(msg_ptr);
12380         if (msg_conv.free == LDKType_JCalls_free) {
12381                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12382                 LDKType_JCalls_cloned(&msg_conv);
12383         }
12384         LDKPublicKey sender_node_id_ref;
12385         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
12386         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
12387         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12388         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
12389         return (int64_t)ret_conv;
12390 }
12391
12392 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
12393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12395         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12396         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
12397         int64_tArray ret_arr = NULL;
12398         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12399         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12400         for (size_t z = 0; z < ret_var.datalen; z++) {
12401                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
12402                 *ret_conv_25_conv = ret_var.data[z];
12403                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
12404         }
12405         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12406         FREE(ret_var.data);
12407         return ret_arr;
12408 }
12409
12410 typedef struct LDKSocketDescriptor_JCalls {
12411         atomic_size_t refcnt;
12412         JavaVM *vm;
12413         jweak o;
12414         jmethodID send_data_meth;
12415         jmethodID disconnect_socket_meth;
12416         jmethodID eq_meth;
12417         jmethodID hash_meth;
12418 } LDKSocketDescriptor_JCalls;
12419 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
12420         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12421         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12422                 JNIEnv *env;
12423                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12424                 if (get_jenv_res == JNI_EDETACHED) {
12425                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12426                 } else {
12427                         DO_ASSERT(get_jenv_res == JNI_OK);
12428                 }
12429                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12430                 if (get_jenv_res == JNI_EDETACHED) {
12431                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12432                 }
12433                 FREE(j_calls);
12434         }
12435 }
12436 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
12437         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12438         JNIEnv *env;
12439         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12440         if (get_jenv_res == JNI_EDETACHED) {
12441                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12442         } else {
12443                 DO_ASSERT(get_jenv_res == JNI_OK);
12444         }
12445         LDKu8slice data_var = data;
12446         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
12447         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
12448         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12449         CHECK(obj != NULL);
12450         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
12451         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12452                 (*env)->ExceptionDescribe(env);
12453                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
12454         }
12455         if (get_jenv_res == JNI_EDETACHED) {
12456                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12457         }
12458         return ret;
12459 }
12460 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
12461         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12462         JNIEnv *env;
12463         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12464         if (get_jenv_res == JNI_EDETACHED) {
12465                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12466         } else {
12467                 DO_ASSERT(get_jenv_res == JNI_OK);
12468         }
12469         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12470         CHECK(obj != NULL);
12471         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
12472         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12473                 (*env)->ExceptionDescribe(env);
12474                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
12475         }
12476         if (get_jenv_res == JNI_EDETACHED) {
12477                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12478         }
12479 }
12480 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
12481         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12482         JNIEnv *env;
12483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12484         if (get_jenv_res == JNI_EDETACHED) {
12485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12486         } else {
12487                 DO_ASSERT(get_jenv_res == JNI_OK);
12488         }
12489         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12490         *other_arg_clone = SocketDescriptor_clone(other_arg);
12491         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12492         CHECK(obj != NULL);
12493         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
12494         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12495                 (*env)->ExceptionDescribe(env);
12496                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
12497         }
12498         if (get_jenv_res == JNI_EDETACHED) {
12499                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12500         }
12501         return ret;
12502 }
12503 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
12504         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12505         JNIEnv *env;
12506         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12507         if (get_jenv_res == JNI_EDETACHED) {
12508                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12509         } else {
12510                 DO_ASSERT(get_jenv_res == JNI_OK);
12511         }
12512         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12513         CHECK(obj != NULL);
12514         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
12515         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12516                 (*env)->ExceptionDescribe(env);
12517                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
12518         }
12519         if (get_jenv_res == JNI_EDETACHED) {
12520                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12521         }
12522         return ret;
12523 }
12524 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
12525         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
12526         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12527 }
12528 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
12529         jclass c = (*env)->GetObjectClass(env, o);
12530         CHECK(c != NULL);
12531         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
12532         atomic_init(&calls->refcnt, 1);
12533         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12534         calls->o = (*env)->NewWeakGlobalRef(env, o);
12535         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
12536         CHECK(calls->send_data_meth != NULL);
12537         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
12538         CHECK(calls->disconnect_socket_meth != NULL);
12539         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
12540         CHECK(calls->eq_meth != NULL);
12541         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
12542         CHECK(calls->hash_meth != NULL);
12543
12544         LDKSocketDescriptor ret = {
12545                 .this_arg = (void*) calls,
12546                 .send_data = send_data_LDKSocketDescriptor_jcall,
12547                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
12548                 .eq = eq_LDKSocketDescriptor_jcall,
12549                 .hash = hash_LDKSocketDescriptor_jcall,
12550                 .cloned = LDKSocketDescriptor_JCalls_cloned,
12551                 .free = LDKSocketDescriptor_JCalls_free,
12552         };
12553         return ret;
12554 }
12555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
12556         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12557         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
12558         return (uint64_t)res_ptr;
12559 }
12560 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) {
12561         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12562         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12563         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12564         LDKu8slice data_ref;
12565         data_ref.datalen = (*env)->GetArrayLength(env, data);
12566         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
12567         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
12568         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
12569         return ret_val;
12570 }
12571
12572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
12573         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12574         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12575         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12576         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
12577 }
12578
12579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
12580         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12581         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12582         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12583         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
12584         return ret_val;
12585 }
12586
12587 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
12588 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
12589 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
12590 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
12591 static jclass LDKEffectiveCapacity_Total_class = NULL;
12592 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
12593 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
12594 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
12595 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
12596 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
12597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
12598         LDKEffectiveCapacity_ExactLiquidity_class =
12599                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
12600         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
12601         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
12602         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
12603         LDKEffectiveCapacity_MaximumHTLC_class =
12604                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
12605         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
12606         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
12607         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
12608         LDKEffectiveCapacity_Total_class =
12609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
12610         CHECK(LDKEffectiveCapacity_Total_class != NULL);
12611         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(J)V");
12612         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
12613         LDKEffectiveCapacity_Infinite_class =
12614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
12615         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
12616         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
12617         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
12618         LDKEffectiveCapacity_Unknown_class =
12619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
12620         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
12621         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
12622         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
12623 }
12624 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12625         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
12626         switch(obj->tag) {
12627                 case LDKEffectiveCapacity_ExactLiquidity: {
12628                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, obj->exact_liquidity.liquidity_msat);
12629                 }
12630                 case LDKEffectiveCapacity_MaximumHTLC: {
12631                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, obj->maximum_htlc.amount_msat);
12632                 }
12633                 case LDKEffectiveCapacity_Total: {
12634                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, obj->total.capacity_msat);
12635                 }
12636                 case LDKEffectiveCapacity_Infinite: {
12637                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
12638                 }
12639                 case LDKEffectiveCapacity_Unknown: {
12640                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
12641                 }
12642                 default: abort();
12643         }
12644 }
12645 typedef struct LDKScore_JCalls {
12646         atomic_size_t refcnt;
12647         JavaVM *vm;
12648         jweak o;
12649         jmethodID channel_penalty_msat_meth;
12650         jmethodID payment_path_failed_meth;
12651         jmethodID payment_path_successful_meth;
12652         jmethodID write_meth;
12653 } LDKScore_JCalls;
12654 static void LDKScore_JCalls_free(void* this_arg) {
12655         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12656         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12657                 JNIEnv *env;
12658                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12659                 if (get_jenv_res == JNI_EDETACHED) {
12660                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12661                 } else {
12662                         DO_ASSERT(get_jenv_res == JNI_OK);
12663                 }
12664                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12665                 if (get_jenv_res == JNI_EDETACHED) {
12666                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12667                 }
12668                 FREE(j_calls);
12669         }
12670 }
12671 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
12672         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12673         JNIEnv *env;
12674         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12675         if (get_jenv_res == JNI_EDETACHED) {
12676                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12677         } else {
12678                 DO_ASSERT(get_jenv_res == JNI_OK);
12679         }
12680         LDKNodeId source_var = *source;
12681         int64_t source_ref = 0;
12682         source_var = NodeId_clone(&source_var);
12683         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12684         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12685         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
12686         source_ref = (uintptr_t)source_var.inner;
12687         if (source_var.is_owned) {
12688                 source_ref |= 1;
12689         }
12690         LDKNodeId target_var = *target;
12691         int64_t target_ref = 0;
12692         target_var = NodeId_clone(&target_var);
12693         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12694         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12695         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
12696         target_ref = (uintptr_t)target_var.inner;
12697         if (target_var.is_owned) {
12698                 target_ref |= 1;
12699         }
12700         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12701         CHECK(obj != NULL);
12702         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, send_amt_msat, capacity_msat, source_ref, target_ref);
12703         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12704                 (*env)->ExceptionDescribe(env);
12705                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
12706         }
12707         if (get_jenv_res == JNI_EDETACHED) {
12708                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12709         }
12710         return ret;
12711 }
12712 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
12713         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12714         JNIEnv *env;
12715         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12716         if (get_jenv_res == JNI_EDETACHED) {
12717                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12718         } else {
12719                 DO_ASSERT(get_jenv_res == JNI_OK);
12720         }
12721         LDKCVec_RouteHopZ path_var = path;
12722         int64_tArray path_arr = NULL;
12723         path_arr = (*env)->NewLongArray(env, path_var.datalen);
12724         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
12725         for (size_t k = 0; k < path_var.datalen; k++) {
12726                 LDKRouteHop path_conv_10_var = path_var.data[k];
12727                 int64_t path_conv_10_ref = 0;
12728                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12729                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12730                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
12731                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
12732                 if (path_conv_10_var.is_owned) {
12733                         path_conv_10_ref |= 1;
12734                 }
12735                 path_arr_ptr[k] = path_conv_10_ref;
12736         }
12737         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
12738         FREE(path_var.data);
12739         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12740         CHECK(obj != NULL);
12741         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
12742         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12743                 (*env)->ExceptionDescribe(env);
12744                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
12745         }
12746         if (get_jenv_res == JNI_EDETACHED) {
12747                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12748         }
12749 }
12750 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
12751         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12752         JNIEnv *env;
12753         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12754         if (get_jenv_res == JNI_EDETACHED) {
12755                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12756         } else {
12757                 DO_ASSERT(get_jenv_res == JNI_OK);
12758         }
12759         LDKCVec_RouteHopZ path_var = path;
12760         int64_tArray path_arr = NULL;
12761         path_arr = (*env)->NewLongArray(env, path_var.datalen);
12762         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
12763         for (size_t k = 0; k < path_var.datalen; k++) {
12764                 LDKRouteHop path_conv_10_var = path_var.data[k];
12765                 int64_t path_conv_10_ref = 0;
12766                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12767                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12768                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
12769                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
12770                 if (path_conv_10_var.is_owned) {
12771                         path_conv_10_ref |= 1;
12772                 }
12773                 path_arr_ptr[k] = path_conv_10_ref;
12774         }
12775         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
12776         FREE(path_var.data);
12777         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12778         CHECK(obj != NULL);
12779         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
12780         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12781                 (*env)->ExceptionDescribe(env);
12782                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
12783         }
12784         if (get_jenv_res == JNI_EDETACHED) {
12785                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12786         }
12787 }
12788 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
12789         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12790         JNIEnv *env;
12791         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12792         if (get_jenv_res == JNI_EDETACHED) {
12793                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12794         } else {
12795                 DO_ASSERT(get_jenv_res == JNI_OK);
12796         }
12797         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12798         CHECK(obj != NULL);
12799         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
12800         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12801                 (*env)->ExceptionDescribe(env);
12802                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
12803         }
12804         LDKCVec_u8Z ret_ref;
12805         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
12806         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
12807         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
12808         if (get_jenv_res == JNI_EDETACHED) {
12809                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12810         }
12811         return ret_ref;
12812 }
12813 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
12814         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
12815         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12816 }
12817 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
12818         jclass c = (*env)->GetObjectClass(env, o);
12819         CHECK(c != NULL);
12820         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
12821         atomic_init(&calls->refcnt, 1);
12822         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12823         calls->o = (*env)->NewWeakGlobalRef(env, o);
12824         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJJ)J");
12825         CHECK(calls->channel_penalty_msat_meth != NULL);
12826         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
12827         CHECK(calls->payment_path_failed_meth != NULL);
12828         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
12829         CHECK(calls->payment_path_successful_meth != NULL);
12830         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
12831         CHECK(calls->write_meth != NULL);
12832
12833         LDKScore ret = {
12834                 .this_arg = (void*) calls,
12835                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
12836                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
12837                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
12838                 .write = write_LDKScore_jcall,
12839                 .free = LDKScore_JCalls_free,
12840         };
12841         return ret;
12842 }
12843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
12844         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
12845         *res_ptr = LDKScore_init(env, clz, o);
12846         return (uint64_t)res_ptr;
12847 }
12848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, int64_t capacity_msat, int64_t source, int64_t target) {
12849         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12850         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12851         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12852         LDKNodeId source_conv;
12853         source_conv.inner = (void*)(source & (~1));
12854         source_conv.is_owned = false;
12855         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
12856         LDKNodeId target_conv;
12857         target_conv.inner = (void*)(target & (~1));
12858         target_conv.is_owned = false;
12859         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
12860         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, capacity_msat, &source_conv, &target_conv);
12861         return ret_val;
12862 }
12863
12864 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) {
12865         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12866         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12867         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12868         LDKCVec_RouteHopZ path_constr;
12869         path_constr.datalen = (*env)->GetArrayLength(env, path);
12870         if (path_constr.datalen > 0)
12871                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12872         else
12873                 path_constr.data = NULL;
12874         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
12875         for (size_t k = 0; k < path_constr.datalen; k++) {
12876                 int64_t path_conv_10 = path_vals[k];
12877                 LDKRouteHop path_conv_10_conv;
12878                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
12879                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
12880                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
12881                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
12882                 path_constr.data[k] = path_conv_10_conv;
12883         }
12884         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
12885         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
12886 }
12887
12888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
12889         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12890         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12891         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12892         LDKCVec_RouteHopZ path_constr;
12893         path_constr.datalen = (*env)->GetArrayLength(env, path);
12894         if (path_constr.datalen > 0)
12895                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12896         else
12897                 path_constr.data = NULL;
12898         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
12899         for (size_t k = 0; k < path_constr.datalen; k++) {
12900                 int64_t path_conv_10 = path_vals[k];
12901                 LDKRouteHop path_conv_10_conv;
12902                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
12903                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
12904                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
12905                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
12906                 path_constr.data[k] = path_conv_10_conv;
12907         }
12908         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
12909         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
12910 }
12911
12912 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
12913         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12914         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12915         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12916         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
12917         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12918         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12919         CVec_u8Z_free(ret_var);
12920         return ret_arr;
12921 }
12922
12923 typedef struct LDKLockableScore_JCalls {
12924         atomic_size_t refcnt;
12925         JavaVM *vm;
12926         jweak o;
12927         jmethodID lock_meth;
12928 } LDKLockableScore_JCalls;
12929 static void LDKLockableScore_JCalls_free(void* this_arg) {
12930         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
12931         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12932                 JNIEnv *env;
12933                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12934                 if (get_jenv_res == JNI_EDETACHED) {
12935                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12936                 } else {
12937                         DO_ASSERT(get_jenv_res == JNI_OK);
12938                 }
12939                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12940                 if (get_jenv_res == JNI_EDETACHED) {
12941                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12942                 }
12943                 FREE(j_calls);
12944         }
12945 }
12946 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
12947         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
12948         JNIEnv *env;
12949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12950         if (get_jenv_res == JNI_EDETACHED) {
12951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12952         } else {
12953                 DO_ASSERT(get_jenv_res == JNI_OK);
12954         }
12955         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12956         CHECK(obj != NULL);
12957         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
12958         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12959                 (*env)->ExceptionDescribe(env);
12960                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
12961         }
12962         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12963         CHECK_ACCESS(ret_ptr);
12964         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
12965         if (ret_conv.free == LDKScore_JCalls_free) {
12966                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12967                 LDKScore_JCalls_cloned(&ret_conv);
12968         }// WARNING: we may need a move here but no clone is available for LDKScore
12969         
12970         if (get_jenv_res == JNI_EDETACHED) {
12971                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12972         }
12973         return ret_conv;
12974 }
12975 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
12976         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
12977         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12978 }
12979 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
12980         jclass c = (*env)->GetObjectClass(env, o);
12981         CHECK(c != NULL);
12982         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
12983         atomic_init(&calls->refcnt, 1);
12984         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12985         calls->o = (*env)->NewWeakGlobalRef(env, o);
12986         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
12987         CHECK(calls->lock_meth != NULL);
12988
12989         LDKLockableScore ret = {
12990                 .this_arg = (void*) calls,
12991                 .lock = lock_LDKLockableScore_jcall,
12992                 .free = LDKLockableScore_JCalls_free,
12993         };
12994         return ret;
12995 }
12996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
12997         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
12998         *res_ptr = LDKLockableScore_init(env, clz, o);
12999         return (uint64_t)res_ptr;
13000 }
13001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
13002         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13003         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13004         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
13005         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
13006         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
13007         return (int64_t)ret_ret;
13008 }
13009
13010 typedef struct LDKChannelManagerPersister_JCalls {
13011         atomic_size_t refcnt;
13012         JavaVM *vm;
13013         jweak o;
13014         jmethodID persist_manager_meth;
13015 } LDKChannelManagerPersister_JCalls;
13016 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
13017         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
13018         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13019                 JNIEnv *env;
13020                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13021                 if (get_jenv_res == JNI_EDETACHED) {
13022                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13023                 } else {
13024                         DO_ASSERT(get_jenv_res == JNI_OK);
13025                 }
13026                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13027                 if (get_jenv_res == JNI_EDETACHED) {
13028                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13029                 }
13030                 FREE(j_calls);
13031         }
13032 }
13033 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
13034         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
13035         JNIEnv *env;
13036         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13037         if (get_jenv_res == JNI_EDETACHED) {
13038                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13039         } else {
13040                 DO_ASSERT(get_jenv_res == JNI_OK);
13041         }
13042         LDKChannelManager channel_manager_var = *channel_manager;
13043         int64_t channel_manager_ref = 0;
13044         // WARNING: we may need a move here but no clone is available for LDKChannelManager
13045         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13046         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13047         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
13048         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
13049         if (channel_manager_var.is_owned) {
13050                 channel_manager_ref |= 1;
13051         }
13052         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13053         CHECK(obj != NULL);
13054         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
13055         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13056                 (*env)->ExceptionDescribe(env);
13057                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
13058         }
13059         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13060         CHECK_ACCESS(ret_ptr);
13061         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
13062         FREE((void*)ret);
13063         if (get_jenv_res == JNI_EDETACHED) {
13064                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13065         }
13066         return ret_conv;
13067 }
13068 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
13069         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
13070         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13071 }
13072 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
13073         jclass c = (*env)->GetObjectClass(env, o);
13074         CHECK(c != NULL);
13075         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
13076         atomic_init(&calls->refcnt, 1);
13077         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13078         calls->o = (*env)->NewWeakGlobalRef(env, o);
13079         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
13080         CHECK(calls->persist_manager_meth != NULL);
13081
13082         LDKChannelManagerPersister ret = {
13083                 .this_arg = (void*) calls,
13084                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
13085                 .free = LDKChannelManagerPersister_JCalls_free,
13086         };
13087         return ret;
13088 }
13089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
13090         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
13091         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
13092         return (uint64_t)res_ptr;
13093 }
13094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
13095         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13096         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13097         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
13098         LDKChannelManager channel_manager_conv;
13099         channel_manager_conv.inner = (void*)(channel_manager & (~1));
13100         channel_manager_conv.is_owned = false;
13101         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
13102         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
13103         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
13104         return (int64_t)ret_conv;
13105 }
13106
13107 static jclass LDKFallback_SegWitProgram_class = NULL;
13108 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
13109 static jclass LDKFallback_PubKeyHash_class = NULL;
13110 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
13111 static jclass LDKFallback_ScriptHash_class = NULL;
13112 static jmethodID LDKFallback_ScriptHash_meth = NULL;
13113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
13114         LDKFallback_SegWitProgram_class =
13115                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
13116         CHECK(LDKFallback_SegWitProgram_class != NULL);
13117         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
13118         CHECK(LDKFallback_SegWitProgram_meth != NULL);
13119         LDKFallback_PubKeyHash_class =
13120                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
13121         CHECK(LDKFallback_PubKeyHash_class != NULL);
13122         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
13123         CHECK(LDKFallback_PubKeyHash_meth != NULL);
13124         LDKFallback_ScriptHash_class =
13125                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
13126         CHECK(LDKFallback_ScriptHash_class != NULL);
13127         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
13128         CHECK(LDKFallback_ScriptHash_meth != NULL);
13129 }
13130 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13131         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
13132         switch(obj->tag) {
13133                 case LDKFallback_SegWitProgram: {
13134                         uint8_t version_val = obj->seg_wit_program.version._0;
13135                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
13136                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
13137                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
13138                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
13139                 }
13140                 case LDKFallback_PubKeyHash: {
13141                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
13142                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
13143                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
13144                 }
13145                 case LDKFallback_ScriptHash: {
13146                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
13147                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
13148                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
13149                 }
13150                 default: abort();
13151         }
13152 }
13153 typedef struct LDKPayer_JCalls {
13154         atomic_size_t refcnt;
13155         JavaVM *vm;
13156         jweak o;
13157         jmethodID node_id_meth;
13158         jmethodID first_hops_meth;
13159         jmethodID send_payment_meth;
13160         jmethodID send_spontaneous_payment_meth;
13161         jmethodID retry_payment_meth;
13162         jmethodID abandon_payment_meth;
13163 } LDKPayer_JCalls;
13164 static void LDKPayer_JCalls_free(void* this_arg) {
13165         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13166         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13167                 JNIEnv *env;
13168                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13169                 if (get_jenv_res == JNI_EDETACHED) {
13170                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13171                 } else {
13172                         DO_ASSERT(get_jenv_res == JNI_OK);
13173                 }
13174                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13175                 if (get_jenv_res == JNI_EDETACHED) {
13176                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13177                 }
13178                 FREE(j_calls);
13179         }
13180 }
13181 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
13182         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13183         JNIEnv *env;
13184         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13185         if (get_jenv_res == JNI_EDETACHED) {
13186                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13187         } else {
13188                 DO_ASSERT(get_jenv_res == JNI_OK);
13189         }
13190         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13191         CHECK(obj != NULL);
13192         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
13193         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13194                 (*env)->ExceptionDescribe(env);
13195                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
13196         }
13197         LDKPublicKey ret_ref;
13198         CHECK((*env)->GetArrayLength(env, ret) == 33);
13199         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
13200         if (get_jenv_res == JNI_EDETACHED) {
13201                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13202         }
13203         return ret_ref;
13204 }
13205 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
13206         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13207         JNIEnv *env;
13208         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13209         if (get_jenv_res == JNI_EDETACHED) {
13210                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13211         } else {
13212                 DO_ASSERT(get_jenv_res == JNI_OK);
13213         }
13214         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13215         CHECK(obj != NULL);
13216         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
13217         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13218                 (*env)->ExceptionDescribe(env);
13219                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
13220         }
13221         LDKCVec_ChannelDetailsZ ret_constr;
13222         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13223         if (ret_constr.datalen > 0)
13224                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13225         else
13226                 ret_constr.data = NULL;
13227         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13228         for (size_t q = 0; q < ret_constr.datalen; q++) {
13229                 int64_t ret_conv_16 = ret_vals[q];
13230                 LDKChannelDetails ret_conv_16_conv;
13231                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
13232                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
13233                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
13234                 ret_constr.data[q] = ret_conv_16_conv;
13235         }
13236         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13237         if (get_jenv_res == JNI_EDETACHED) {
13238                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13239         }
13240         return ret_constr;
13241 }
13242 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
13243         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13244         JNIEnv *env;
13245         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13246         if (get_jenv_res == JNI_EDETACHED) {
13247                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13248         } else {
13249                 DO_ASSERT(get_jenv_res == JNI_OK);
13250         }
13251         LDKRoute route_var = *route;
13252         int64_t route_ref = 0;
13253         route_var = Route_clone(&route_var);
13254         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13255         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13256         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13257         route_ref = (uintptr_t)route_var.inner;
13258         if (route_var.is_owned) {
13259                 route_ref |= 1;
13260         }
13261         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13262         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
13263         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
13264         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
13265         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13266         CHECK(obj != NULL);
13267         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
13268         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13269                 (*env)->ExceptionDescribe(env);
13270                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
13271         }
13272         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13273         CHECK_ACCESS(ret_ptr);
13274         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13275         FREE((void*)ret);
13276         if (get_jenv_res == JNI_EDETACHED) {
13277                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13278         }
13279         return ret_conv;
13280 }
13281 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
13282         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13283         JNIEnv *env;
13284         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13285         if (get_jenv_res == JNI_EDETACHED) {
13286                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13287         } else {
13288                 DO_ASSERT(get_jenv_res == JNI_OK);
13289         }
13290         LDKRoute route_var = *route;
13291         int64_t route_ref = 0;
13292         route_var = Route_clone(&route_var);
13293         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13294         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13295         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13296         route_ref = (uintptr_t)route_var.inner;
13297         if (route_var.is_owned) {
13298                 route_ref |= 1;
13299         }
13300         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
13301         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
13302         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13303         CHECK(obj != NULL);
13304         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
13305         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13306                 (*env)->ExceptionDescribe(env);
13307                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
13308         }
13309         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13310         CHECK_ACCESS(ret_ptr);
13311         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13312         FREE((void*)ret);
13313         if (get_jenv_res == JNI_EDETACHED) {
13314                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13315         }
13316         return ret_conv;
13317 }
13318 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
13319         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13320         JNIEnv *env;
13321         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13322         if (get_jenv_res == JNI_EDETACHED) {
13323                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13324         } else {
13325                 DO_ASSERT(get_jenv_res == JNI_OK);
13326         }
13327         LDKRoute route_var = *route;
13328         int64_t route_ref = 0;
13329         route_var = Route_clone(&route_var);
13330         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13331         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13332         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13333         route_ref = (uintptr_t)route_var.inner;
13334         if (route_var.is_owned) {
13335                 route_ref |= 1;
13336         }
13337         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13338         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13339         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13340         CHECK(obj != NULL);
13341         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
13342         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13343                 (*env)->ExceptionDescribe(env);
13344                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
13345         }
13346         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13347         CHECK_ACCESS(ret_ptr);
13348         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
13349         FREE((void*)ret);
13350         if (get_jenv_res == JNI_EDETACHED) {
13351                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13352         }
13353         return ret_conv;
13354 }
13355 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
13356         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13357         JNIEnv *env;
13358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13359         if (get_jenv_res == JNI_EDETACHED) {
13360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13361         } else {
13362                 DO_ASSERT(get_jenv_res == JNI_OK);
13363         }
13364         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13365         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13366         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13367         CHECK(obj != NULL);
13368         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
13369         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13370                 (*env)->ExceptionDescribe(env);
13371                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
13372         }
13373         if (get_jenv_res == JNI_EDETACHED) {
13374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13375         }
13376 }
13377 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
13378         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
13379         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13380 }
13381 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
13382         jclass c = (*env)->GetObjectClass(env, o);
13383         CHECK(c != NULL);
13384         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
13385         atomic_init(&calls->refcnt, 1);
13386         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13387         calls->o = (*env)->NewWeakGlobalRef(env, o);
13388         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
13389         CHECK(calls->node_id_meth != NULL);
13390         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
13391         CHECK(calls->first_hops_meth != NULL);
13392         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
13393         CHECK(calls->send_payment_meth != NULL);
13394         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
13395         CHECK(calls->send_spontaneous_payment_meth != NULL);
13396         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
13397         CHECK(calls->retry_payment_meth != NULL);
13398         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
13399         CHECK(calls->abandon_payment_meth != NULL);
13400
13401         LDKPayer ret = {
13402                 .this_arg = (void*) calls,
13403                 .node_id = node_id_LDKPayer_jcall,
13404                 .first_hops = first_hops_LDKPayer_jcall,
13405                 .send_payment = send_payment_LDKPayer_jcall,
13406                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
13407                 .retry_payment = retry_payment_LDKPayer_jcall,
13408                 .abandon_payment = abandon_payment_LDKPayer_jcall,
13409                 .free = LDKPayer_JCalls_free,
13410         };
13411         return ret;
13412 }
13413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
13414         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
13415         *res_ptr = LDKPayer_init(env, clz, o);
13416         return (uint64_t)res_ptr;
13417 }
13418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13419         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13420         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13421         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13422         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13423         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
13424         return ret_arr;
13425 }
13426
13427 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
13428         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13429         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13430         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13431         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
13432         int64_tArray ret_arr = NULL;
13433         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13434         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13435         for (size_t q = 0; q < ret_var.datalen; q++) {
13436                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13437                 int64_t ret_conv_16_ref = 0;
13438                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13439                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13440                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
13441                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
13442                 if (ret_conv_16_var.is_owned) {
13443                         ret_conv_16_ref |= 1;
13444                 }
13445                 ret_arr_ptr[q] = ret_conv_16_ref;
13446         }
13447         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13448         FREE(ret_var.data);
13449         return ret_arr;
13450 }
13451
13452 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) {
13453         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13454         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13455         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13456         LDKRoute route_conv;
13457         route_conv.inner = (void*)(route & (~1));
13458         route_conv.is_owned = false;
13459         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13460         LDKThirtyTwoBytes payment_hash_ref;
13461         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13462         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13463         LDKThirtyTwoBytes payment_secret_ref;
13464         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13465         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13466         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13467         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
13468         return (int64_t)ret_conv;
13469 }
13470
13471 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) {
13472         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13473         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13474         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13475         LDKRoute route_conv;
13476         route_conv.inner = (void*)(route & (~1));
13477         route_conv.is_owned = false;
13478         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13479         LDKThirtyTwoBytes payment_preimage_ref;
13480         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13481         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13482         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13483         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
13484         return (int64_t)ret_conv;
13485 }
13486
13487 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) {
13488         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13489         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13490         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13491         LDKRoute route_conv;
13492         route_conv.inner = (void*)(route & (~1));
13493         route_conv.is_owned = false;
13494         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13495         LDKThirtyTwoBytes payment_id_ref;
13496         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13497         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13498         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13499         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
13500         return (int64_t)ret_conv;
13501 }
13502
13503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
13504         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13505         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13506         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13507         LDKThirtyTwoBytes payment_id_ref;
13508         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13509         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13510         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
13511 }
13512
13513 typedef struct LDKRouter_JCalls {
13514         atomic_size_t refcnt;
13515         JavaVM *vm;
13516         jweak o;
13517         jmethodID find_route_meth;
13518 } LDKRouter_JCalls;
13519 static void LDKRouter_JCalls_free(void* this_arg) {
13520         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13521         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13522                 JNIEnv *env;
13523                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13524                 if (get_jenv_res == JNI_EDETACHED) {
13525                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13526                 } else {
13527                         DO_ASSERT(get_jenv_res == JNI_OK);
13528                 }
13529                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13530                 if (get_jenv_res == JNI_EDETACHED) {
13531                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13532                 }
13533                 FREE(j_calls);
13534         }
13535 }
13536 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) {
13537         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13538         JNIEnv *env;
13539         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13540         if (get_jenv_res == JNI_EDETACHED) {
13541                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13542         } else {
13543                 DO_ASSERT(get_jenv_res == JNI_OK);
13544         }
13545         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
13546         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
13547         LDKRouteParameters route_params_var = *route_params;
13548         int64_t route_params_ref = 0;
13549         route_params_var = RouteParameters_clone(&route_params_var);
13550         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13551         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13552         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
13553         route_params_ref = (uintptr_t)route_params_var.inner;
13554         if (route_params_var.is_owned) {
13555                 route_params_ref |= 1;
13556         }
13557         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13558         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
13559         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
13560         int64_tArray first_hops_arr = NULL;
13561         if (first_hops != NULL) {
13562                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
13563                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
13564                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
13565                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
13566                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
13567                         int64_t first_hops_conv_16_ref = 0;
13568                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13569                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13570                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
13571                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
13572                         if (first_hops_conv_16_var.is_owned) {
13573                                 first_hops_conv_16_ref |= 1;
13574                         }
13575                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
13576                 }
13577                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
13578         }
13579         // WARNING: This object doesn't live past this scope, needs clone!
13580         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
13581         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13582         CHECK(obj != NULL);
13583         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);
13584         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13585                 (*env)->ExceptionDescribe(env);
13586                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
13587         }
13588         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13589         CHECK_ACCESS(ret_ptr);
13590         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
13591         FREE((void*)ret);
13592         if (get_jenv_res == JNI_EDETACHED) {
13593                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13594         }
13595         return ret_conv;
13596 }
13597 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
13598         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
13599         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13600 }
13601 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
13602         jclass c = (*env)->GetObjectClass(env, o);
13603         CHECK(c != NULL);
13604         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
13605         atomic_init(&calls->refcnt, 1);
13606         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13607         calls->o = (*env)->NewWeakGlobalRef(env, o);
13608         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
13609         CHECK(calls->find_route_meth != NULL);
13610
13611         LDKRouter ret = {
13612                 .this_arg = (void*) calls,
13613                 .find_route = find_route_LDKRouter_jcall,
13614                 .free = LDKRouter_JCalls_free,
13615         };
13616         return ret;
13617 }
13618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
13619         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
13620         *res_ptr = LDKRouter_init(env, clz, o);
13621         return (uint64_t)res_ptr;
13622 }
13623 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) {
13624         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13625         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13626         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
13627         LDKPublicKey payer_ref;
13628         CHECK((*env)->GetArrayLength(env, payer) == 33);
13629         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
13630         LDKRouteParameters route_params_conv;
13631         route_params_conv.inner = (void*)(route_params & (~1));
13632         route_params_conv.is_owned = false;
13633         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
13634         unsigned char payment_hash_arr[32];
13635         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13636         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
13637         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13638         LDKCVec_ChannelDetailsZ first_hops_constr;
13639         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
13640         if (first_hops != NULL) {
13641                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
13642                 if (first_hops_constr.datalen > 0)
13643                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13644                 else
13645                         first_hops_constr.data = NULL;
13646                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
13647                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
13648                         int64_t first_hops_conv_16 = first_hops_vals[q];
13649                         LDKChannelDetails first_hops_conv_16_conv;
13650                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
13651                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
13652                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
13653                         first_hops_constr.data[q] = first_hops_conv_16_conv;
13654                 }
13655                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
13656                 first_hops_ptr = &first_hops_constr;
13657         }
13658         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
13659         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
13660         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
13661         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
13662         *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);
13663         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
13664         return (int64_t)ret_conv;
13665 }
13666
13667 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
13668         LDKStr ret_str = _ldk_get_compiled_version();
13669         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
13670         Str_free(ret_str);
13671         return ret_conv;
13672 }
13673
13674 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
13675         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
13676         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
13677         Str_free(ret_str);
13678         return ret_conv;
13679 }
13680
13681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
13682         LDKTransaction _res_ref;
13683         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
13684         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
13685         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
13686         _res_ref.data_is_owned = true;
13687         Transaction_free(_res_ref);
13688 }
13689
13690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
13691         LDKCVec_u8Z script_pubkey_ref;
13692         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
13693         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
13694         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
13695         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13696         *ret_ref = TxOut_new(script_pubkey_ref, value);
13697         return (int64_t)ret_ref;
13698 }
13699
13700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
13701         if ((_res & 1) != 0) return;
13702         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13703         CHECK_ACCESS(_res_ptr);
13704         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
13705         FREE((void*)_res);
13706         TxOut_free(_res_conv);
13707 }
13708
13709 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
13710         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13711         *ret_ref = TxOut_clone(arg);
13712         return (int64_t)ret_ref;
13713 }
13714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13715         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
13716         int64_t ret_val = TxOut_clone_ptr(arg_conv);
13717         return ret_val;
13718 }
13719
13720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13721         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
13722         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13723         *ret_ref = TxOut_clone(orig_conv);
13724         return (int64_t)ret_ref;
13725 }
13726
13727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
13728         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
13729         Str_free(dummy);
13730 }
13731
13732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
13733         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13734         *ret_conv = CResult_NoneNoneZ_ok();
13735         return (int64_t)ret_conv;
13736 }
13737
13738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
13739         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13740         *ret_conv = CResult_NoneNoneZ_err();
13741         return (int64_t)ret_conv;
13742 }
13743
13744 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13745         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
13746         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
13747         return ret_val;
13748 }
13749
13750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13751         if ((_res & 1) != 0) return;
13752         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13753         CHECK_ACCESS(_res_ptr);
13754         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
13755         FREE((void*)_res);
13756         CResult_NoneNoneZ_free(_res_conv);
13757 }
13758
13759 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
13760         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13761         *ret_conv = CResult_NoneNoneZ_clone(arg);
13762         return (int64_t)ret_conv;
13763 }
13764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13765         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
13766         int64_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
13767         return ret_val;
13768 }
13769
13770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13771         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
13772         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13773         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
13774         return (int64_t)ret_conv;
13775 }
13776
13777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13778         LDKCounterpartyCommitmentSecrets o_conv;
13779         o_conv.inner = (void*)(o & (~1));
13780         o_conv.is_owned = (o & 1) || (o == 0);
13781         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13782         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
13783         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13784         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
13785         return (int64_t)ret_conv;
13786 }
13787
13788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13789         LDKDecodeError e_conv;
13790         e_conv.inner = (void*)(e & (~1));
13791         e_conv.is_owned = (e & 1) || (e == 0);
13792         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13793         e_conv = DecodeError_clone(&e_conv);
13794         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13795         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
13796         return (int64_t)ret_conv;
13797 }
13798
13799 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13800         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
13801         jboolean ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
13802         return ret_val;
13803 }
13804
13805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13806         if ((_res & 1) != 0) return;
13807         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13808         CHECK_ACCESS(_res_ptr);
13809         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
13810         FREE((void*)_res);
13811         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
13812 }
13813
13814 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
13815         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13816         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
13817         return (int64_t)ret_conv;
13818 }
13819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13820         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
13821         int64_t ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
13822         return ret_val;
13823 }
13824
13825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13826         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
13827         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13828         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
13829         return (int64_t)ret_conv;
13830 }
13831
13832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13833         LDKSecretKey o_ref;
13834         CHECK((*env)->GetArrayLength(env, o) == 32);
13835         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
13836         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13837         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
13838         return (int64_t)ret_conv;
13839 }
13840
13841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13842         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13843         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13844         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
13845         return (int64_t)ret_conv;
13846 }
13847
13848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13849         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
13850         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
13851         return ret_val;
13852 }
13853
13854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13855         if ((_res & 1) != 0) return;
13856         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13857         CHECK_ACCESS(_res_ptr);
13858         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
13859         FREE((void*)_res);
13860         CResult_SecretKeyErrorZ_free(_res_conv);
13861 }
13862
13863 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
13864         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13865         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
13866         return (int64_t)ret_conv;
13867 }
13868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13869         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
13870         int64_t ret_val = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
13871         return ret_val;
13872 }
13873
13874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13875         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
13876         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13877         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
13878         return (int64_t)ret_conv;
13879 }
13880
13881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13882         LDKPublicKey o_ref;
13883         CHECK((*env)->GetArrayLength(env, o) == 33);
13884         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
13885         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13886         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
13887         return (int64_t)ret_conv;
13888 }
13889
13890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13891         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13892         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13893         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
13894         return (int64_t)ret_conv;
13895 }
13896
13897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13898         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
13899         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
13900         return ret_val;
13901 }
13902
13903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13904         if ((_res & 1) != 0) return;
13905         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13906         CHECK_ACCESS(_res_ptr);
13907         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
13908         FREE((void*)_res);
13909         CResult_PublicKeyErrorZ_free(_res_conv);
13910 }
13911
13912 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
13913         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13914         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
13915         return (int64_t)ret_conv;
13916 }
13917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13918         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
13919         int64_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
13920         return ret_val;
13921 }
13922
13923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13924         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
13925         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13926         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
13927         return (int64_t)ret_conv;
13928 }
13929
13930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13931         LDKTxCreationKeys o_conv;
13932         o_conv.inner = (void*)(o & (~1));
13933         o_conv.is_owned = (o & 1) || (o == 0);
13934         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13935         o_conv = TxCreationKeys_clone(&o_conv);
13936         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13937         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
13938         return (int64_t)ret_conv;
13939 }
13940
13941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13942         LDKDecodeError e_conv;
13943         e_conv.inner = (void*)(e & (~1));
13944         e_conv.is_owned = (e & 1) || (e == 0);
13945         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13946         e_conv = DecodeError_clone(&e_conv);
13947         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13948         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
13949         return (int64_t)ret_conv;
13950 }
13951
13952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13953         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
13954         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
13955         return ret_val;
13956 }
13957
13958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13959         if ((_res & 1) != 0) return;
13960         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13961         CHECK_ACCESS(_res_ptr);
13962         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
13963         FREE((void*)_res);
13964         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
13965 }
13966
13967 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
13968         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13969         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
13970         return (int64_t)ret_conv;
13971 }
13972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13973         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
13974         int64_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
13975         return ret_val;
13976 }
13977
13978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13979         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
13980         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13981         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
13982         return (int64_t)ret_conv;
13983 }
13984
13985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13986         LDKChannelPublicKeys o_conv;
13987         o_conv.inner = (void*)(o & (~1));
13988         o_conv.is_owned = (o & 1) || (o == 0);
13989         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13990         o_conv = ChannelPublicKeys_clone(&o_conv);
13991         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13992         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
13993         return (int64_t)ret_conv;
13994 }
13995
13996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13997         LDKDecodeError e_conv;
13998         e_conv.inner = (void*)(e & (~1));
13999         e_conv.is_owned = (e & 1) || (e == 0);
14000         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14001         e_conv = DecodeError_clone(&e_conv);
14002         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14003         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
14004         return (int64_t)ret_conv;
14005 }
14006
14007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14008         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
14009         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
14010         return ret_val;
14011 }
14012
14013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14014         if ((_res & 1) != 0) return;
14015         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14016         CHECK_ACCESS(_res_ptr);
14017         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
14018         FREE((void*)_res);
14019         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
14020 }
14021
14022 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
14023         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14024         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
14025         return (int64_t)ret_conv;
14026 }
14027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14028         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
14029         int64_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
14030         return ret_val;
14031 }
14032
14033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14034         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
14035         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14036         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
14037         return (int64_t)ret_conv;
14038 }
14039
14040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14041         LDKTxCreationKeys o_conv;
14042         o_conv.inner = (void*)(o & (~1));
14043         o_conv.is_owned = (o & 1) || (o == 0);
14044         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14045         o_conv = TxCreationKeys_clone(&o_conv);
14046         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14047         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
14048         return (int64_t)ret_conv;
14049 }
14050
14051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14052         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14053         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14054         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
14055         return (int64_t)ret_conv;
14056 }
14057
14058 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14059         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
14060         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
14061         return ret_val;
14062 }
14063
14064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14065         if ((_res & 1) != 0) return;
14066         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14067         CHECK_ACCESS(_res_ptr);
14068         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
14069         FREE((void*)_res);
14070         CResult_TxCreationKeysErrorZ_free(_res_conv);
14071 }
14072
14073 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
14074         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14075         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
14076         return (int64_t)ret_conv;
14077 }
14078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14079         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
14080         int64_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
14081         return ret_val;
14082 }
14083
14084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14085         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
14086         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14087         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
14088         return (int64_t)ret_conv;
14089 }
14090
14091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
14092         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14093         *ret_copy = COption_u32Z_some(o);
14094         int64_t ret_ref = (uintptr_t)ret_copy;
14095         return ret_ref;
14096 }
14097
14098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
14099         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14100         *ret_copy = COption_u32Z_none();
14101         int64_t ret_ref = (uintptr_t)ret_copy;
14102         return ret_ref;
14103 }
14104
14105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14106         if ((_res & 1) != 0) return;
14107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14108         CHECK_ACCESS(_res_ptr);
14109         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
14110         FREE((void*)_res);
14111         COption_u32Z_free(_res_conv);
14112 }
14113
14114 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
14115         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14116         *ret_copy = COption_u32Z_clone(arg);
14117 int64_t ret_ref = (uintptr_t)ret_copy;
14118         return ret_ref;
14119 }
14120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14121         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
14122         int64_t ret_val = COption_u32Z_clone_ptr(arg_conv);
14123         return ret_val;
14124 }
14125
14126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14127         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
14128         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14129         *ret_copy = COption_u32Z_clone(orig_conv);
14130         int64_t ret_ref = (uintptr_t)ret_copy;
14131         return ret_ref;
14132 }
14133
14134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14135         LDKHTLCOutputInCommitment o_conv;
14136         o_conv.inner = (void*)(o & (~1));
14137         o_conv.is_owned = (o & 1) || (o == 0);
14138         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14139         o_conv = HTLCOutputInCommitment_clone(&o_conv);
14140         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14141         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
14142         return (int64_t)ret_conv;
14143 }
14144
14145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14146         LDKDecodeError e_conv;
14147         e_conv.inner = (void*)(e & (~1));
14148         e_conv.is_owned = (e & 1) || (e == 0);
14149         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14150         e_conv = DecodeError_clone(&e_conv);
14151         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14152         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
14153         return (int64_t)ret_conv;
14154 }
14155
14156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14157         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
14158         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
14159         return ret_val;
14160 }
14161
14162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14163         if ((_res & 1) != 0) return;
14164         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14165         CHECK_ACCESS(_res_ptr);
14166         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
14167         FREE((void*)_res);
14168         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
14169 }
14170
14171 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
14172         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14173         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
14174         return (int64_t)ret_conv;
14175 }
14176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14177         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
14178         int64_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
14179         return ret_val;
14180 }
14181
14182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14183         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
14184         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14185         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
14186         return (int64_t)ret_conv;
14187 }
14188
14189 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
14190         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
14191         return ret_conv;
14192 }
14193
14194 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
14195         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
14196         return ret_conv;
14197 }
14198
14199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
14200         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
14201         COption_NoneZ_free(_res_conv);
14202 }
14203
14204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14205         LDKCounterpartyChannelTransactionParameters o_conv;
14206         o_conv.inner = (void*)(o & (~1));
14207         o_conv.is_owned = (o & 1) || (o == 0);
14208         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14209         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
14210         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14211         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14212         return (int64_t)ret_conv;
14213 }
14214
14215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14216         LDKDecodeError e_conv;
14217         e_conv.inner = (void*)(e & (~1));
14218         e_conv.is_owned = (e & 1) || (e == 0);
14219         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14220         e_conv = DecodeError_clone(&e_conv);
14221         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14222         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
14223         return (int64_t)ret_conv;
14224 }
14225
14226 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14227         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14228         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14229         return ret_val;
14230 }
14231
14232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14233         if ((_res & 1) != 0) return;
14234         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14235         CHECK_ACCESS(_res_ptr);
14236         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14237         FREE((void*)_res);
14238         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14239 }
14240
14241 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14242         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14243         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
14244         return (int64_t)ret_conv;
14245 }
14246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14247         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14248         int64_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14249         return ret_val;
14250 }
14251
14252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14253         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14254         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14255         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14256         return (int64_t)ret_conv;
14257 }
14258
14259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14260         LDKChannelTransactionParameters o_conv;
14261         o_conv.inner = (void*)(o & (~1));
14262         o_conv.is_owned = (o & 1) || (o == 0);
14263         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14264         o_conv = ChannelTransactionParameters_clone(&o_conv);
14265         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14266         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14267         return (int64_t)ret_conv;
14268 }
14269
14270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14271         LDKDecodeError e_conv;
14272         e_conv.inner = (void*)(e & (~1));
14273         e_conv.is_owned = (e & 1) || (e == 0);
14274         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14275         e_conv = DecodeError_clone(&e_conv);
14276         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14277         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
14278         return (int64_t)ret_conv;
14279 }
14280
14281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14282         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14283         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14284         return ret_val;
14285 }
14286
14287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14288         if ((_res & 1) != 0) return;
14289         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14290         CHECK_ACCESS(_res_ptr);
14291         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14292         FREE((void*)_res);
14293         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14294 }
14295
14296 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14297         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14298         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
14299         return (int64_t)ret_conv;
14300 }
14301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14302         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14303         int64_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14304         return ret_val;
14305 }
14306
14307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14308         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14309         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14310         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14311         return (int64_t)ret_conv;
14312 }
14313
14314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14315         LDKCVec_SignatureZ _res_constr;
14316         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14317         if (_res_constr.datalen > 0)
14318                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14319         else
14320                 _res_constr.data = NULL;
14321         for (size_t i = 0; i < _res_constr.datalen; i++) {
14322                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
14323                 LDKSignature _res_conv_8_ref;
14324                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
14325                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
14326                 _res_constr.data[i] = _res_conv_8_ref;
14327         }
14328         CVec_SignatureZ_free(_res_constr);
14329 }
14330
14331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14332         LDKHolderCommitmentTransaction o_conv;
14333         o_conv.inner = (void*)(o & (~1));
14334         o_conv.is_owned = (o & 1) || (o == 0);
14335         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14336         o_conv = HolderCommitmentTransaction_clone(&o_conv);
14337         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14338         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
14339         return (int64_t)ret_conv;
14340 }
14341
14342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14343         LDKDecodeError e_conv;
14344         e_conv.inner = (void*)(e & (~1));
14345         e_conv.is_owned = (e & 1) || (e == 0);
14346         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14347         e_conv = DecodeError_clone(&e_conv);
14348         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14349         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
14350         return (int64_t)ret_conv;
14351 }
14352
14353 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14354         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
14355         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14356         return ret_val;
14357 }
14358
14359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14360         if ((_res & 1) != 0) return;
14361         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14362         CHECK_ACCESS(_res_ptr);
14363         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14364         FREE((void*)_res);
14365         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
14366 }
14367
14368 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14369         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14370         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
14371         return (int64_t)ret_conv;
14372 }
14373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14374         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14375         int64_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14376         return ret_val;
14377 }
14378
14379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14380         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14381         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14382         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14383         return (int64_t)ret_conv;
14384 }
14385
14386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14387         LDKBuiltCommitmentTransaction o_conv;
14388         o_conv.inner = (void*)(o & (~1));
14389         o_conv.is_owned = (o & 1) || (o == 0);
14390         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14391         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
14392         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14393         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
14394         return (int64_t)ret_conv;
14395 }
14396
14397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14398         LDKDecodeError e_conv;
14399         e_conv.inner = (void*)(e & (~1));
14400         e_conv.is_owned = (e & 1) || (e == 0);
14401         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14402         e_conv = DecodeError_clone(&e_conv);
14403         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14404         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
14405         return (int64_t)ret_conv;
14406 }
14407
14408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14409         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
14410         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14411         return ret_val;
14412 }
14413
14414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14415         if ((_res & 1) != 0) return;
14416         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14417         CHECK_ACCESS(_res_ptr);
14418         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14419         FREE((void*)_res);
14420         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
14421 }
14422
14423 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14424         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14425         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
14426         return (int64_t)ret_conv;
14427 }
14428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14429         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14430         int64_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14431         return ret_val;
14432 }
14433
14434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14435         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14436         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14437         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14438         return (int64_t)ret_conv;
14439 }
14440
14441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14442         LDKTrustedClosingTransaction o_conv;
14443         o_conv.inner = (void*)(o & (~1));
14444         o_conv.is_owned = (o & 1) || (o == 0);
14445         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14446         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
14447         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14448         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
14449         return (int64_t)ret_conv;
14450 }
14451
14452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14453         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14454         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
14455         return (int64_t)ret_conv;
14456 }
14457
14458 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14459         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
14460         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
14461         return ret_val;
14462 }
14463
14464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14465         if ((_res & 1) != 0) return;
14466         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14467         CHECK_ACCESS(_res_ptr);
14468         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
14469         FREE((void*)_res);
14470         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
14471 }
14472
14473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14474         LDKCommitmentTransaction o_conv;
14475         o_conv.inner = (void*)(o & (~1));
14476         o_conv.is_owned = (o & 1) || (o == 0);
14477         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14478         o_conv = CommitmentTransaction_clone(&o_conv);
14479         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14480         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
14481         return (int64_t)ret_conv;
14482 }
14483
14484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14485         LDKDecodeError e_conv;
14486         e_conv.inner = (void*)(e & (~1));
14487         e_conv.is_owned = (e & 1) || (e == 0);
14488         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14489         e_conv = DecodeError_clone(&e_conv);
14490         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14491         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
14492         return (int64_t)ret_conv;
14493 }
14494
14495 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14496         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
14497         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14498         return ret_val;
14499 }
14500
14501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14502         if ((_res & 1) != 0) return;
14503         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14504         CHECK_ACCESS(_res_ptr);
14505         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
14506         FREE((void*)_res);
14507         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
14508 }
14509
14510 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14511         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14512         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
14513         return (int64_t)ret_conv;
14514 }
14515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14516         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
14517         int64_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14518         return ret_val;
14519 }
14520
14521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14522         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
14523         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14524         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
14525         return (int64_t)ret_conv;
14526 }
14527
14528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14529         LDKTrustedCommitmentTransaction o_conv;
14530         o_conv.inner = (void*)(o & (~1));
14531         o_conv.is_owned = (o & 1) || (o == 0);
14532         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14533         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
14534         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14535         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
14536         return (int64_t)ret_conv;
14537 }
14538
14539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14540         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14541         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
14542         return (int64_t)ret_conv;
14543 }
14544
14545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14546         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
14547         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
14548         return ret_val;
14549 }
14550
14551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14552         if ((_res & 1) != 0) return;
14553         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14554         CHECK_ACCESS(_res_ptr);
14555         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
14556         FREE((void*)_res);
14557         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
14558 }
14559
14560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
14561         LDKCVec_SignatureZ o_constr;
14562         o_constr.datalen = (*env)->GetArrayLength(env, o);
14563         if (o_constr.datalen > 0)
14564                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14565         else
14566                 o_constr.data = NULL;
14567         for (size_t i = 0; i < o_constr.datalen; i++) {
14568                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
14569                 LDKSignature o_conv_8_ref;
14570                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
14571                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
14572                 o_constr.data[i] = o_conv_8_ref;
14573         }
14574         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14575         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
14576         return (int64_t)ret_conv;
14577 }
14578
14579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
14580         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14581         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
14582         return (int64_t)ret_conv;
14583 }
14584
14585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14586         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
14587         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
14588         return ret_val;
14589 }
14590
14591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14592         if ((_res & 1) != 0) return;
14593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14594         CHECK_ACCESS(_res_ptr);
14595         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
14596         FREE((void*)_res);
14597         CResult_CVec_SignatureZNoneZ_free(_res_conv);
14598 }
14599
14600 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
14601         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14602         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
14603         return (int64_t)ret_conv;
14604 }
14605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14606         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
14607         int64_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
14608         return ret_val;
14609 }
14610
14611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14612         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
14613         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14614         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
14615         return (int64_t)ret_conv;
14616 }
14617
14618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14619         LDKShutdownScript o_conv;
14620         o_conv.inner = (void*)(o & (~1));
14621         o_conv.is_owned = (o & 1) || (o == 0);
14622         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14623         o_conv = ShutdownScript_clone(&o_conv);
14624         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14625         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
14626         return (int64_t)ret_conv;
14627 }
14628
14629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14630         LDKDecodeError e_conv;
14631         e_conv.inner = (void*)(e & (~1));
14632         e_conv.is_owned = (e & 1) || (e == 0);
14633         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14634         e_conv = DecodeError_clone(&e_conv);
14635         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14636         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
14637         return (int64_t)ret_conv;
14638 }
14639
14640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14641         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
14642         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
14643         return ret_val;
14644 }
14645
14646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14647         if ((_res & 1) != 0) return;
14648         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14649         CHECK_ACCESS(_res_ptr);
14650         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
14651         FREE((void*)_res);
14652         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
14653 }
14654
14655 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
14656         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14657         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
14658         return (int64_t)ret_conv;
14659 }
14660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14661         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
14662         int64_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
14663         return ret_val;
14664 }
14665
14666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14667         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
14668         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14669         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
14670         return (int64_t)ret_conv;
14671 }
14672
14673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14674         LDKShutdownScript o_conv;
14675         o_conv.inner = (void*)(o & (~1));
14676         o_conv.is_owned = (o & 1) || (o == 0);
14677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14678         o_conv = ShutdownScript_clone(&o_conv);
14679         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14680         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
14681         return (int64_t)ret_conv;
14682 }
14683
14684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14685         LDKInvalidShutdownScript e_conv;
14686         e_conv.inner = (void*)(e & (~1));
14687         e_conv.is_owned = (e & 1) || (e == 0);
14688         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14689         e_conv = InvalidShutdownScript_clone(&e_conv);
14690         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14691         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
14692         return (int64_t)ret_conv;
14693 }
14694
14695 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14696         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
14697         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
14698         return ret_val;
14699 }
14700
14701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14702         if ((_res & 1) != 0) return;
14703         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14704         CHECK_ACCESS(_res_ptr);
14705         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
14706         FREE((void*)_res);
14707         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
14708 }
14709
14710 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
14711         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14712         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
14713         return (int64_t)ret_conv;
14714 }
14715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14716         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
14717         int64_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
14718         return ret_val;
14719 }
14720
14721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14722         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
14723         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14724         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
14725         return (int64_t)ret_conv;
14726 }
14727
14728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
14729         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14730         *ret_conv = CResult_NoneErrorZ_ok();
14731         return (int64_t)ret_conv;
14732 }
14733
14734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14735         LDKIOError e_conv = LDKIOError_from_java(env, e);
14736         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14737         *ret_conv = CResult_NoneErrorZ_err(e_conv);
14738         return (int64_t)ret_conv;
14739 }
14740
14741 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14742         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
14743         jboolean ret_val = CResult_NoneErrorZ_is_ok(o_conv);
14744         return ret_val;
14745 }
14746
14747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14748         if ((_res & 1) != 0) return;
14749         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14750         CHECK_ACCESS(_res_ptr);
14751         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
14752         FREE((void*)_res);
14753         CResult_NoneErrorZ_free(_res_conv);
14754 }
14755
14756 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
14757         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14758         *ret_conv = CResult_NoneErrorZ_clone(arg);
14759         return (int64_t)ret_conv;
14760 }
14761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14762         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
14763         int64_t ret_val = CResult_NoneErrorZ_clone_ptr(arg_conv);
14764         return ret_val;
14765 }
14766
14767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14768         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
14769         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14770         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
14771         return (int64_t)ret_conv;
14772 }
14773
14774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14775         LDKRouteHop o_conv;
14776         o_conv.inner = (void*)(o & (~1));
14777         o_conv.is_owned = (o & 1) || (o == 0);
14778         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14779         o_conv = RouteHop_clone(&o_conv);
14780         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14781         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
14782         return (int64_t)ret_conv;
14783 }
14784
14785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14786         LDKDecodeError e_conv;
14787         e_conv.inner = (void*)(e & (~1));
14788         e_conv.is_owned = (e & 1) || (e == 0);
14789         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14790         e_conv = DecodeError_clone(&e_conv);
14791         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14792         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
14793         return (int64_t)ret_conv;
14794 }
14795
14796 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14797         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
14798         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
14799         return ret_val;
14800 }
14801
14802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14803         if ((_res & 1) != 0) return;
14804         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14805         CHECK_ACCESS(_res_ptr);
14806         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
14807         FREE((void*)_res);
14808         CResult_RouteHopDecodeErrorZ_free(_res_conv);
14809 }
14810
14811 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
14812         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14813         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
14814         return (int64_t)ret_conv;
14815 }
14816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14817         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
14818         int64_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
14819         return ret_val;
14820 }
14821
14822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14823         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
14824         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14825         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
14826         return (int64_t)ret_conv;
14827 }
14828
14829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14830         LDKCVec_RouteHopZ _res_constr;
14831         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14832         if (_res_constr.datalen > 0)
14833                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14834         else
14835                 _res_constr.data = NULL;
14836         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14837         for (size_t k = 0; k < _res_constr.datalen; k++) {
14838                 int64_t _res_conv_10 = _res_vals[k];
14839                 LDKRouteHop _res_conv_10_conv;
14840                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
14841                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
14842                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
14843                 _res_constr.data[k] = _res_conv_10_conv;
14844         }
14845         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14846         CVec_RouteHopZ_free(_res_constr);
14847 }
14848
14849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14850         LDKCVec_CVec_RouteHopZZ _res_constr;
14851         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14852         if (_res_constr.datalen > 0)
14853                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14854         else
14855                 _res_constr.data = NULL;
14856         for (size_t m = 0; m < _res_constr.datalen; m++) {
14857                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
14858                 LDKCVec_RouteHopZ _res_conv_12_constr;
14859                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
14860                 if (_res_conv_12_constr.datalen > 0)
14861                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14862                 else
14863                         _res_conv_12_constr.data = NULL;
14864                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
14865                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
14866                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
14867                         LDKRouteHop _res_conv_12_conv_10_conv;
14868                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
14869                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
14870                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
14871                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
14872                 }
14873                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
14874                 _res_constr.data[m] = _res_conv_12_constr;
14875         }
14876         CVec_CVec_RouteHopZZ_free(_res_constr);
14877 }
14878
14879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14880         LDKRoute o_conv;
14881         o_conv.inner = (void*)(o & (~1));
14882         o_conv.is_owned = (o & 1) || (o == 0);
14883         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14884         o_conv = Route_clone(&o_conv);
14885         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14886         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
14887         return (int64_t)ret_conv;
14888 }
14889
14890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14891         LDKDecodeError e_conv;
14892         e_conv.inner = (void*)(e & (~1));
14893         e_conv.is_owned = (e & 1) || (e == 0);
14894         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14895         e_conv = DecodeError_clone(&e_conv);
14896         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14897         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
14898         return (int64_t)ret_conv;
14899 }
14900
14901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14902         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
14903         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
14904         return ret_val;
14905 }
14906
14907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14908         if ((_res & 1) != 0) return;
14909         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14910         CHECK_ACCESS(_res_ptr);
14911         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
14912         FREE((void*)_res);
14913         CResult_RouteDecodeErrorZ_free(_res_conv);
14914 }
14915
14916 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
14917         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14918         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
14919         return (int64_t)ret_conv;
14920 }
14921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14922         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
14923         int64_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
14924         return ret_val;
14925 }
14926
14927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14928         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
14929         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14930         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
14931         return (int64_t)ret_conv;
14932 }
14933
14934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14935         LDKRouteParameters o_conv;
14936         o_conv.inner = (void*)(o & (~1));
14937         o_conv.is_owned = (o & 1) || (o == 0);
14938         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14939         o_conv = RouteParameters_clone(&o_conv);
14940         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14941         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
14942         return (int64_t)ret_conv;
14943 }
14944
14945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14946         LDKDecodeError e_conv;
14947         e_conv.inner = (void*)(e & (~1));
14948         e_conv.is_owned = (e & 1) || (e == 0);
14949         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14950         e_conv = DecodeError_clone(&e_conv);
14951         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14952         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
14953         return (int64_t)ret_conv;
14954 }
14955
14956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14957         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
14958         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
14959         return ret_val;
14960 }
14961
14962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14963         if ((_res & 1) != 0) return;
14964         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14965         CHECK_ACCESS(_res_ptr);
14966         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
14967         FREE((void*)_res);
14968         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
14969 }
14970
14971 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
14972         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14973         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
14974         return (int64_t)ret_conv;
14975 }
14976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14977         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
14978         int64_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
14979         return ret_val;
14980 }
14981
14982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14983         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
14984         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14985         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
14986         return (int64_t)ret_conv;
14987 }
14988
14989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14990         LDKCVec_RouteHintZ _res_constr;
14991         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14992         if (_res_constr.datalen > 0)
14993                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
14994         else
14995                 _res_constr.data = NULL;
14996         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14997         for (size_t l = 0; l < _res_constr.datalen; l++) {
14998                 int64_t _res_conv_11 = _res_vals[l];
14999                 LDKRouteHint _res_conv_11_conv;
15000                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
15001                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
15002                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
15003                 _res_constr.data[l] = _res_conv_11_conv;
15004         }
15005         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15006         CVec_RouteHintZ_free(_res_constr);
15007 }
15008
15009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
15010         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15011         *ret_copy = COption_u64Z_some(o);
15012         int64_t ret_ref = (uintptr_t)ret_copy;
15013         return ret_ref;
15014 }
15015
15016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
15017         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15018         *ret_copy = COption_u64Z_none();
15019         int64_t ret_ref = (uintptr_t)ret_copy;
15020         return ret_ref;
15021 }
15022
15023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15024         if ((_res & 1) != 0) return;
15025         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15026         CHECK_ACCESS(_res_ptr);
15027         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
15028         FREE((void*)_res);
15029         COption_u64Z_free(_res_conv);
15030 }
15031
15032 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
15033         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15034         *ret_copy = COption_u64Z_clone(arg);
15035 int64_t ret_ref = (uintptr_t)ret_copy;
15036         return ret_ref;
15037 }
15038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15039         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
15040         int64_t ret_val = COption_u64Z_clone_ptr(arg_conv);
15041         return ret_val;
15042 }
15043
15044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15045         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
15046         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15047         *ret_copy = COption_u64Z_clone(orig_conv);
15048         int64_t ret_ref = (uintptr_t)ret_copy;
15049         return ret_ref;
15050 }
15051
15052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15053         LDKPaymentParameters o_conv;
15054         o_conv.inner = (void*)(o & (~1));
15055         o_conv.is_owned = (o & 1) || (o == 0);
15056         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15057         o_conv = PaymentParameters_clone(&o_conv);
15058         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15059         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
15060         return (int64_t)ret_conv;
15061 }
15062
15063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15064         LDKDecodeError e_conv;
15065         e_conv.inner = (void*)(e & (~1));
15066         e_conv.is_owned = (e & 1) || (e == 0);
15067         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15068         e_conv = DecodeError_clone(&e_conv);
15069         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15070         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
15071         return (int64_t)ret_conv;
15072 }
15073
15074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15075         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
15076         jboolean ret_val = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
15077         return ret_val;
15078 }
15079
15080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15081         if ((_res & 1) != 0) return;
15082         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15083         CHECK_ACCESS(_res_ptr);
15084         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
15085         FREE((void*)_res);
15086         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
15087 }
15088
15089 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
15090         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15091         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
15092         return (int64_t)ret_conv;
15093 }
15094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15095         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
15096         int64_t ret_val = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
15097         return ret_val;
15098 }
15099
15100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15101         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
15102         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15103         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
15104         return (int64_t)ret_conv;
15105 }
15106
15107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15108         LDKCVec_RouteHintHopZ _res_constr;
15109         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15110         if (_res_constr.datalen > 0)
15111                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
15112         else
15113                 _res_constr.data = NULL;
15114         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15115         for (size_t o = 0; o < _res_constr.datalen; o++) {
15116                 int64_t _res_conv_14 = _res_vals[o];
15117                 LDKRouteHintHop _res_conv_14_conv;
15118                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15119                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15120                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15121                 _res_constr.data[o] = _res_conv_14_conv;
15122         }
15123         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15124         CVec_RouteHintHopZ_free(_res_constr);
15125 }
15126
15127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15128         LDKRouteHint o_conv;
15129         o_conv.inner = (void*)(o & (~1));
15130         o_conv.is_owned = (o & 1) || (o == 0);
15131         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15132         o_conv = RouteHint_clone(&o_conv);
15133         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15134         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
15135         return (int64_t)ret_conv;
15136 }
15137
15138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15139         LDKDecodeError e_conv;
15140         e_conv.inner = (void*)(e & (~1));
15141         e_conv.is_owned = (e & 1) || (e == 0);
15142         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15143         e_conv = DecodeError_clone(&e_conv);
15144         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15145         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
15146         return (int64_t)ret_conv;
15147 }
15148
15149 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15150         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
15151         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
15152         return ret_val;
15153 }
15154
15155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15156         if ((_res & 1) != 0) return;
15157         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15158         CHECK_ACCESS(_res_ptr);
15159         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
15160         FREE((void*)_res);
15161         CResult_RouteHintDecodeErrorZ_free(_res_conv);
15162 }
15163
15164 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
15165         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15166         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
15167         return (int64_t)ret_conv;
15168 }
15169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15170         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
15171         int64_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
15172         return ret_val;
15173 }
15174
15175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15176         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
15177         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15178         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
15179         return (int64_t)ret_conv;
15180 }
15181
15182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15183         LDKRouteHintHop o_conv;
15184         o_conv.inner = (void*)(o & (~1));
15185         o_conv.is_owned = (o & 1) || (o == 0);
15186         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15187         o_conv = RouteHintHop_clone(&o_conv);
15188         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15189         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
15190         return (int64_t)ret_conv;
15191 }
15192
15193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15194         LDKDecodeError e_conv;
15195         e_conv.inner = (void*)(e & (~1));
15196         e_conv.is_owned = (e & 1) || (e == 0);
15197         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15198         e_conv = DecodeError_clone(&e_conv);
15199         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15200         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
15201         return (int64_t)ret_conv;
15202 }
15203
15204 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15205         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
15206         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
15207         return ret_val;
15208 }
15209
15210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15211         if ((_res & 1) != 0) return;
15212         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15213         CHECK_ACCESS(_res_ptr);
15214         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
15215         FREE((void*)_res);
15216         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
15217 }
15218
15219 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
15220         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15221         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
15222         return (int64_t)ret_conv;
15223 }
15224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15225         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
15226         int64_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
15227         return ret_val;
15228 }
15229
15230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15231         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
15232         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15233         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
15234         return (int64_t)ret_conv;
15235 }
15236
15237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15238         LDKCVec_ChannelDetailsZ _res_constr;
15239         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15240         if (_res_constr.datalen > 0)
15241                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15242         else
15243                 _res_constr.data = NULL;
15244         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15245         for (size_t q = 0; q < _res_constr.datalen; q++) {
15246                 int64_t _res_conv_16 = _res_vals[q];
15247                 LDKChannelDetails _res_conv_16_conv;
15248                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
15249                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
15250                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
15251                 _res_constr.data[q] = _res_conv_16_conv;
15252         }
15253         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15254         CVec_ChannelDetailsZ_free(_res_constr);
15255 }
15256
15257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15258         LDKRoute o_conv;
15259         o_conv.inner = (void*)(o & (~1));
15260         o_conv.is_owned = (o & 1) || (o == 0);
15261         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15262         o_conv = Route_clone(&o_conv);
15263         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15264         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
15265         return (int64_t)ret_conv;
15266 }
15267
15268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15269         LDKLightningError e_conv;
15270         e_conv.inner = (void*)(e & (~1));
15271         e_conv.is_owned = (e & 1) || (e == 0);
15272         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15273         e_conv = LightningError_clone(&e_conv);
15274         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15275         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
15276         return (int64_t)ret_conv;
15277 }
15278
15279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15280         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
15281         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
15282         return ret_val;
15283 }
15284
15285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15286         if ((_res & 1) != 0) return;
15287         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15288         CHECK_ACCESS(_res_ptr);
15289         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
15290         FREE((void*)_res);
15291         CResult_RouteLightningErrorZ_free(_res_conv);
15292 }
15293
15294 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
15295         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15296         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
15297         return (int64_t)ret_conv;
15298 }
15299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15300         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
15301         int64_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
15302         return ret_val;
15303 }
15304
15305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15306         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
15307         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15308         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
15309         return (int64_t)ret_conv;
15310 }
15311
15312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15313         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15314         CHECK_ACCESS(o_ptr);
15315         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
15316         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
15317         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15318         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
15319         return (int64_t)ret_conv;
15320 }
15321
15322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15323         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
15324         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15325         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
15326         return (int64_t)ret_conv;
15327 }
15328
15329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15330         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
15331         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
15332         return ret_val;
15333 }
15334
15335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15336         if ((_res & 1) != 0) return;
15337         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15338         CHECK_ACCESS(_res_ptr);
15339         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
15340         FREE((void*)_res);
15341         CResult_TxOutAccessErrorZ_free(_res_conv);
15342 }
15343
15344 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
15345         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15346         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
15347         return (int64_t)ret_conv;
15348 }
15349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15350         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
15351         int64_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
15352         return ret_val;
15353 }
15354
15355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15356         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
15357         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15358         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
15359         return (int64_t)ret_conv;
15360 }
15361
15362 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
15363         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15364         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
15365         return ((int64_t)ret_conv);
15366 }
15367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15368         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
15369         int64_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
15370         return ret_val;
15371 }
15372
15373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15374         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
15375         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15376         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
15377         return ((int64_t)ret_conv);
15378 }
15379
15380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
15381         LDKTransaction b_ref;
15382         b_ref.datalen = (*env)->GetArrayLength(env, b);
15383         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
15384         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15385         b_ref.data_is_owned = true;
15386         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15387         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
15388         return ((int64_t)ret_conv);
15389 }
15390
15391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15392         if ((_res & 1) != 0) return;
15393         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15394         CHECK_ACCESS(_res_ptr);
15395         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
15396         FREE((void*)_res);
15397         C2Tuple_usizeTransactionZ_free(_res_conv);
15398 }
15399
15400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15401         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
15402         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15403         if (_res_constr.datalen > 0)
15404                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15405         else
15406                 _res_constr.data = NULL;
15407         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15408         for (size_t c = 0; c < _res_constr.datalen; c++) {
15409                 int64_t _res_conv_28 = _res_vals[c];
15410                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
15411                 CHECK_ACCESS(_res_conv_28_ptr);
15412                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
15413                 FREE((void*)_res_conv_28);
15414                 _res_constr.data[c] = _res_conv_28_conv;
15415         }
15416         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15417         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
15418 }
15419
15420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15421         LDKCVec_TxidZ _res_constr;
15422         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15423         if (_res_constr.datalen > 0)
15424                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
15425         else
15426                 _res_constr.data = NULL;
15427         for (size_t i = 0; i < _res_constr.datalen; i++) {
15428                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15429                 LDKThirtyTwoBytes _res_conv_8_ref;
15430                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
15431                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
15432                 _res_constr.data[i] = _res_conv_8_ref;
15433         }
15434         CVec_TxidZ_free(_res_constr);
15435 }
15436
15437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
15438         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15439         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
15440         return (int64_t)ret_conv;
15441 }
15442
15443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
15444         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
15445         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15446         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
15447         return (int64_t)ret_conv;
15448 }
15449
15450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15451         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
15452         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
15453         return ret_val;
15454 }
15455
15456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15457         if ((_res & 1) != 0) return;
15458         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15459         CHECK_ACCESS(_res_ptr);
15460         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
15461         FREE((void*)_res);
15462         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
15463 }
15464
15465 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
15466         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15467         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
15468         return (int64_t)ret_conv;
15469 }
15470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15471         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
15472         int64_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
15473         return ret_val;
15474 }
15475
15476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15477         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
15478         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15479         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
15480         return (int64_t)ret_conv;
15481 }
15482
15483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15484         LDKCVec_MonitorEventZ _res_constr;
15485         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15486         if (_res_constr.datalen > 0)
15487                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
15488         else
15489                 _res_constr.data = NULL;
15490         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15491         for (size_t o = 0; o < _res_constr.datalen; o++) {
15492                 int64_t _res_conv_14 = _res_vals[o];
15493                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
15494                 CHECK_ACCESS(_res_conv_14_ptr);
15495                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
15496                 FREE((void*)_res_conv_14);
15497                 _res_constr.data[o] = _res_conv_14_conv;
15498         }
15499         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15500         CVec_MonitorEventZ_free(_res_constr);
15501 }
15502
15503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15504         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15505         CHECK_ACCESS(o_ptr);
15506         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
15507         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
15508         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15509         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
15510         int64_t ret_ref = (uintptr_t)ret_copy;
15511         return ret_ref;
15512 }
15513
15514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
15515         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15516         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
15517         int64_t ret_ref = (uintptr_t)ret_copy;
15518         return ret_ref;
15519 }
15520
15521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15522         if ((_res & 1) != 0) return;
15523         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15524         CHECK_ACCESS(_res_ptr);
15525         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
15526         FREE((void*)_res);
15527         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
15528 }
15529
15530 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
15531         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15532         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
15533 int64_t ret_ref = (uintptr_t)ret_copy;
15534         return ret_ref;
15535 }
15536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15537         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
15538         int64_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
15539         return ret_val;
15540 }
15541
15542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15543         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
15544         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15545         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
15546         int64_t ret_ref = (uintptr_t)ret_copy;
15547         return ret_ref;
15548 }
15549
15550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15551         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15552         CHECK_ACCESS(o_ptr);
15553         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
15554         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
15555         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15556         *ret_copy = COption_ClosureReasonZ_some(o_conv);
15557         int64_t ret_ref = (uintptr_t)ret_copy;
15558         return ret_ref;
15559 }
15560
15561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
15562         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15563         *ret_copy = COption_ClosureReasonZ_none();
15564         int64_t ret_ref = (uintptr_t)ret_copy;
15565         return ret_ref;
15566 }
15567
15568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15569         if ((_res & 1) != 0) return;
15570         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15571         CHECK_ACCESS(_res_ptr);
15572         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
15573         FREE((void*)_res);
15574         COption_ClosureReasonZ_free(_res_conv);
15575 }
15576
15577 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
15578         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15579         *ret_copy = COption_ClosureReasonZ_clone(arg);
15580 int64_t ret_ref = (uintptr_t)ret_copy;
15581         return ret_ref;
15582 }
15583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15584         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
15585         int64_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
15586         return ret_val;
15587 }
15588
15589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15590         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
15591         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15592         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
15593         int64_t ret_ref = (uintptr_t)ret_copy;
15594         return ret_ref;
15595 }
15596
15597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15598         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15599         CHECK_ACCESS(o_ptr);
15600         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
15601         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
15602         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15603         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
15604         return (int64_t)ret_conv;
15605 }
15606
15607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15608         LDKDecodeError e_conv;
15609         e_conv.inner = (void*)(e & (~1));
15610         e_conv.is_owned = (e & 1) || (e == 0);
15611         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15612         e_conv = DecodeError_clone(&e_conv);
15613         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15614         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
15615         return (int64_t)ret_conv;
15616 }
15617
15618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15619         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
15620         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
15621         return ret_val;
15622 }
15623
15624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15625         if ((_res & 1) != 0) return;
15626         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15627         CHECK_ACCESS(_res_ptr);
15628         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
15629         FREE((void*)_res);
15630         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
15631 }
15632
15633 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
15634         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15635         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
15636         return (int64_t)ret_conv;
15637 }
15638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15639         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
15640         int64_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
15641         return ret_val;
15642 }
15643
15644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15645         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
15646         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15647         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
15648         return (int64_t)ret_conv;
15649 }
15650
15651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15652         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15653         CHECK_ACCESS(o_ptr);
15654         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
15655         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
15656         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15657         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
15658         int64_t ret_ref = (uintptr_t)ret_copy;
15659         return ret_ref;
15660 }
15661
15662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
15663         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15664         *ret_copy = COption_NetworkUpdateZ_none();
15665         int64_t ret_ref = (uintptr_t)ret_copy;
15666         return ret_ref;
15667 }
15668
15669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15670         if ((_res & 1) != 0) return;
15671         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15672         CHECK_ACCESS(_res_ptr);
15673         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
15674         FREE((void*)_res);
15675         COption_NetworkUpdateZ_free(_res_conv);
15676 }
15677
15678 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
15679         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15680         *ret_copy = COption_NetworkUpdateZ_clone(arg);
15681 int64_t ret_ref = (uintptr_t)ret_copy;
15682         return ret_ref;
15683 }
15684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15685         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
15686         int64_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
15687         return ret_val;
15688 }
15689
15690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15691         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
15692         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15693         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
15694         int64_t ret_ref = (uintptr_t)ret_copy;
15695         return ret_ref;
15696 }
15697
15698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15699         LDKCVec_SpendableOutputDescriptorZ _res_constr;
15700         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15701         if (_res_constr.datalen > 0)
15702                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15703         else
15704                 _res_constr.data = NULL;
15705         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15706         for (size_t b = 0; b < _res_constr.datalen; b++) {
15707                 int64_t _res_conv_27 = _res_vals[b];
15708                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
15709                 CHECK_ACCESS(_res_conv_27_ptr);
15710                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
15711                 FREE((void*)_res_conv_27);
15712                 _res_constr.data[b] = _res_conv_27_conv;
15713         }
15714         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15715         CVec_SpendableOutputDescriptorZ_free(_res_constr);
15716 }
15717
15718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15719         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15720         CHECK_ACCESS(o_ptr);
15721         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
15722         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
15723         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15724         *ret_copy = COption_EventZ_some(o_conv);
15725         int64_t ret_ref = (uintptr_t)ret_copy;
15726         return ret_ref;
15727 }
15728
15729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
15730         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15731         *ret_copy = COption_EventZ_none();
15732         int64_t ret_ref = (uintptr_t)ret_copy;
15733         return ret_ref;
15734 }
15735
15736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15737         if ((_res & 1) != 0) return;
15738         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15739         CHECK_ACCESS(_res_ptr);
15740         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
15741         FREE((void*)_res);
15742         COption_EventZ_free(_res_conv);
15743 }
15744
15745 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
15746         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15747         *ret_copy = COption_EventZ_clone(arg);
15748 int64_t ret_ref = (uintptr_t)ret_copy;
15749         return ret_ref;
15750 }
15751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15752         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
15753         int64_t ret_val = COption_EventZ_clone_ptr(arg_conv);
15754         return ret_val;
15755 }
15756
15757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15758         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
15759         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15760         *ret_copy = COption_EventZ_clone(orig_conv);
15761         int64_t ret_ref = (uintptr_t)ret_copy;
15762         return ret_ref;
15763 }
15764
15765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15766         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15767         CHECK_ACCESS(o_ptr);
15768         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
15769         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
15770         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15771         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
15772         return (int64_t)ret_conv;
15773 }
15774
15775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15776         LDKDecodeError e_conv;
15777         e_conv.inner = (void*)(e & (~1));
15778         e_conv.is_owned = (e & 1) || (e == 0);
15779         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15780         e_conv = DecodeError_clone(&e_conv);
15781         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15782         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
15783         return (int64_t)ret_conv;
15784 }
15785
15786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15787         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
15788         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
15789         return ret_val;
15790 }
15791
15792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15793         if ((_res & 1) != 0) return;
15794         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15795         CHECK_ACCESS(_res_ptr);
15796         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
15797         FREE((void*)_res);
15798         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
15799 }
15800
15801 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
15802         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15803         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
15804         return (int64_t)ret_conv;
15805 }
15806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15807         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
15808         int64_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
15809         return ret_val;
15810 }
15811
15812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15813         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
15814         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15815         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
15816         return (int64_t)ret_conv;
15817 }
15818
15819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15820         LDKCVec_MessageSendEventZ _res_constr;
15821         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15822         if (_res_constr.datalen > 0)
15823                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
15824         else
15825                 _res_constr.data = NULL;
15826         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15827         for (size_t s = 0; s < _res_constr.datalen; s++) {
15828                 int64_t _res_conv_18 = _res_vals[s];
15829                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
15830                 CHECK_ACCESS(_res_conv_18_ptr);
15831                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
15832                 FREE((void*)_res_conv_18);
15833                 _res_constr.data[s] = _res_conv_18_conv;
15834         }
15835         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15836         CVec_MessageSendEventZ_free(_res_constr);
15837 }
15838
15839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15840         LDKFixedPenaltyScorer o_conv;
15841         o_conv.inner = (void*)(o & (~1));
15842         o_conv.is_owned = (o & 1) || (o == 0);
15843         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15844         o_conv = FixedPenaltyScorer_clone(&o_conv);
15845         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
15846         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
15847         return (int64_t)ret_conv;
15848 }
15849
15850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15851         LDKDecodeError e_conv;
15852         e_conv.inner = (void*)(e & (~1));
15853         e_conv.is_owned = (e & 1) || (e == 0);
15854         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15855         e_conv = DecodeError_clone(&e_conv);
15856         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
15857         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
15858         return (int64_t)ret_conv;
15859 }
15860
15861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15862         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
15863         jboolean ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
15864         return ret_val;
15865 }
15866
15867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15868         if ((_res & 1) != 0) return;
15869         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15870         CHECK_ACCESS(_res_ptr);
15871         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
15872         FREE((void*)_res);
15873         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
15874 }
15875
15876 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
15877         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
15878         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
15879         return (int64_t)ret_conv;
15880 }
15881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15882         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
15883         int64_t ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
15884         return ret_val;
15885 }
15886
15887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15888         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
15889         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
15890         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
15891         return (int64_t)ret_conv;
15892 }
15893
15894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15895         LDKScoringParameters o_conv;
15896         o_conv.inner = (void*)(o & (~1));
15897         o_conv.is_owned = (o & 1) || (o == 0);
15898         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15899         o_conv = ScoringParameters_clone(&o_conv);
15900         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15901         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
15902         return (int64_t)ret_conv;
15903 }
15904
15905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15906         LDKDecodeError e_conv;
15907         e_conv.inner = (void*)(e & (~1));
15908         e_conv.is_owned = (e & 1) || (e == 0);
15909         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15910         e_conv = DecodeError_clone(&e_conv);
15911         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15912         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
15913         return (int64_t)ret_conv;
15914 }
15915
15916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15917         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
15918         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
15919         return ret_val;
15920 }
15921
15922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15923         if ((_res & 1) != 0) return;
15924         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15925         CHECK_ACCESS(_res_ptr);
15926         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
15927         FREE((void*)_res);
15928         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
15929 }
15930
15931 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
15932         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15933         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
15934         return (int64_t)ret_conv;
15935 }
15936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15937         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
15938         int64_t ret_val = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
15939         return ret_val;
15940 }
15941
15942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15943         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
15944         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15945         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
15946         return (int64_t)ret_conv;
15947 }
15948
15949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15950         LDKScorer o_conv;
15951         o_conv.inner = (void*)(o & (~1));
15952         o_conv.is_owned = (o & 1) || (o == 0);
15953         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15954         // WARNING: we need a move here but no clone is available for LDKScorer
15955         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
15956         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
15957         return (int64_t)ret_conv;
15958 }
15959
15960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15961         LDKDecodeError e_conv;
15962         e_conv.inner = (void*)(e & (~1));
15963         e_conv.is_owned = (e & 1) || (e == 0);
15964         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15965         e_conv = DecodeError_clone(&e_conv);
15966         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
15967         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
15968         return (int64_t)ret_conv;
15969 }
15970
15971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15972         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
15973         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
15974         return ret_val;
15975 }
15976
15977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15978         if ((_res & 1) != 0) return;
15979         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15980         CHECK_ACCESS(_res_ptr);
15981         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
15982         FREE((void*)_res);
15983         CResult_ScorerDecodeErrorZ_free(_res_conv);
15984 }
15985
15986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15987         LDKProbabilisticScoringParameters o_conv;
15988         o_conv.inner = (void*)(o & (~1));
15989         o_conv.is_owned = (o & 1) || (o == 0);
15990         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15991         o_conv = ProbabilisticScoringParameters_clone(&o_conv);
15992         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
15993         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(o_conv);
15994         return (int64_t)ret_conv;
15995 }
15996
15997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15998         LDKDecodeError e_conv;
15999         e_conv.inner = (void*)(e & (~1));
16000         e_conv.is_owned = (e & 1) || (e == 0);
16001         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16002         e_conv = DecodeError_clone(&e_conv);
16003         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
16004         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_err(e_conv);
16005         return (int64_t)ret_conv;
16006 }
16007
16008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16009         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(o & ~1);
16010         jboolean ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(o_conv);
16011         return ret_val;
16012 }
16013
16014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16015         if ((_res & 1) != 0) return;
16016         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16017         CHECK_ACCESS(_res_ptr);
16018         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(_res_ptr);
16019         FREE((void*)_res);
16020         CResult_ProbabilisticScoringParametersDecodeErrorZ_free(_res_conv);
16021 }
16022
16023 static inline uintptr_t CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
16024         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
16025         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(arg);
16026         return (int64_t)ret_conv;
16027 }
16028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16029         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(arg & ~1);
16030         int64_t ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
16031         return ret_val;
16032 }
16033
16034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16035         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(orig & ~1);
16036         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
16037         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(orig_conv);
16038         return (int64_t)ret_conv;
16039 }
16040
16041 static inline uintptr_t C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone_ptr(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR arg) {
16042         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ), "LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ");
16043         *ret_conv = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone(arg);
16044         return ((int64_t)ret_conv);
16045 }
16046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1ProbabilisticScoringParametersNetworkGraphZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16047         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* arg_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(arg & ~1);
16048         int64_t ret_val = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone_ptr(arg_conv);
16049         return ret_val;
16050 }
16051
16052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1ProbabilisticScoringParametersNetworkGraphZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16053         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* orig_conv = (LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(orig & ~1);
16054         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ), "LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ");
16055         *ret_conv = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone(orig_conv);
16056         return ((int64_t)ret_conv);
16057 }
16058
16059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1ProbabilisticScoringParametersNetworkGraphZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
16060         LDKProbabilisticScoringParameters a_conv;
16061         a_conv.inner = (void*)(a & (~1));
16062         a_conv.is_owned = (a & 1) || (a == 0);
16063         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16064         a_conv = ProbabilisticScoringParameters_clone(&a_conv);
16065         LDKNetworkGraph b_conv;
16066         b_conv.inner = (void*)(b & (~1));
16067         b_conv.is_owned = false;
16068         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16069         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ), "LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ");
16070         *ret_conv = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_new(a_conv, &b_conv);
16071         return ((int64_t)ret_conv);
16072 }
16073
16074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1ProbabilisticScoringParametersNetworkGraphZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16075         if ((_res & 1) != 0) return;
16076         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16077         CHECK_ACCESS(_res_ptr);
16078         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ _res_conv = *(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(_res_ptr);
16079         FREE((void*)_res);
16080         C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(_res_conv);
16081 }
16082
16083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16084         LDKProbabilisticScorer o_conv;
16085         o_conv.inner = (void*)(o & (~1));
16086         o_conv.is_owned = (o & 1) || (o == 0);
16087         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16088         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
16089         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16090         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
16091         return (int64_t)ret_conv;
16092 }
16093
16094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16095         LDKDecodeError e_conv;
16096         e_conv.inner = (void*)(e & (~1));
16097         e_conv.is_owned = (e & 1) || (e == 0);
16098         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16099         e_conv = DecodeError_clone(&e_conv);
16100         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16101         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
16102         return (int64_t)ret_conv;
16103 }
16104
16105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16106         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
16107         jboolean ret_val = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
16108         return ret_val;
16109 }
16110
16111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16112         if ((_res & 1) != 0) return;
16113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16114         CHECK_ACCESS(_res_ptr);
16115         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
16116         FREE((void*)_res);
16117         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
16118 }
16119
16120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16121         LDKInitFeatures o_conv;
16122         o_conv.inner = (void*)(o & (~1));
16123         o_conv.is_owned = (o & 1) || (o == 0);
16124         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16125         o_conv = InitFeatures_clone(&o_conv);
16126         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16127         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
16128         return (int64_t)ret_conv;
16129 }
16130
16131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16132         LDKDecodeError e_conv;
16133         e_conv.inner = (void*)(e & (~1));
16134         e_conv.is_owned = (e & 1) || (e == 0);
16135         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16136         e_conv = DecodeError_clone(&e_conv);
16137         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16138         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
16139         return (int64_t)ret_conv;
16140 }
16141
16142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16143         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
16144         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
16145         return ret_val;
16146 }
16147
16148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16149         if ((_res & 1) != 0) return;
16150         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16151         CHECK_ACCESS(_res_ptr);
16152         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
16153         FREE((void*)_res);
16154         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
16155 }
16156
16157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16158         LDKChannelFeatures o_conv;
16159         o_conv.inner = (void*)(o & (~1));
16160         o_conv.is_owned = (o & 1) || (o == 0);
16161         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16162         o_conv = ChannelFeatures_clone(&o_conv);
16163         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16164         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
16165         return (int64_t)ret_conv;
16166 }
16167
16168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16169         LDKDecodeError e_conv;
16170         e_conv.inner = (void*)(e & (~1));
16171         e_conv.is_owned = (e & 1) || (e == 0);
16172         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16173         e_conv = DecodeError_clone(&e_conv);
16174         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16175         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
16176         return (int64_t)ret_conv;
16177 }
16178
16179 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16180         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
16181         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
16182         return ret_val;
16183 }
16184
16185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16186         if ((_res & 1) != 0) return;
16187         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16188         CHECK_ACCESS(_res_ptr);
16189         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
16190         FREE((void*)_res);
16191         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
16192 }
16193
16194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16195         LDKNodeFeatures o_conv;
16196         o_conv.inner = (void*)(o & (~1));
16197         o_conv.is_owned = (o & 1) || (o == 0);
16198         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16199         o_conv = NodeFeatures_clone(&o_conv);
16200         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16201         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
16202         return (int64_t)ret_conv;
16203 }
16204
16205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16206         LDKDecodeError e_conv;
16207         e_conv.inner = (void*)(e & (~1));
16208         e_conv.is_owned = (e & 1) || (e == 0);
16209         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16210         e_conv = DecodeError_clone(&e_conv);
16211         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16212         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
16213         return (int64_t)ret_conv;
16214 }
16215
16216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16217         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
16218         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
16219         return ret_val;
16220 }
16221
16222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16223         if ((_res & 1) != 0) return;
16224         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16225         CHECK_ACCESS(_res_ptr);
16226         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
16227         FREE((void*)_res);
16228         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
16229 }
16230
16231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16232         LDKInvoiceFeatures o_conv;
16233         o_conv.inner = (void*)(o & (~1));
16234         o_conv.is_owned = (o & 1) || (o == 0);
16235         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16236         o_conv = InvoiceFeatures_clone(&o_conv);
16237         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16238         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
16239         return (int64_t)ret_conv;
16240 }
16241
16242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16243         LDKDecodeError e_conv;
16244         e_conv.inner = (void*)(e & (~1));
16245         e_conv.is_owned = (e & 1) || (e == 0);
16246         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16247         e_conv = DecodeError_clone(&e_conv);
16248         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16249         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
16250         return (int64_t)ret_conv;
16251 }
16252
16253 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16254         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
16255         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
16256         return ret_val;
16257 }
16258
16259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16260         if ((_res & 1) != 0) return;
16261         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16262         CHECK_ACCESS(_res_ptr);
16263         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
16264         FREE((void*)_res);
16265         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
16266 }
16267
16268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16269         LDKChannelTypeFeatures o_conv;
16270         o_conv.inner = (void*)(o & (~1));
16271         o_conv.is_owned = (o & 1) || (o == 0);
16272         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16273         o_conv = ChannelTypeFeatures_clone(&o_conv);
16274         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16275         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
16276         return (int64_t)ret_conv;
16277 }
16278
16279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16280         LDKDecodeError e_conv;
16281         e_conv.inner = (void*)(e & (~1));
16282         e_conv.is_owned = (e & 1) || (e == 0);
16283         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16284         e_conv = DecodeError_clone(&e_conv);
16285         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16286         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
16287         return (int64_t)ret_conv;
16288 }
16289
16290 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16291         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
16292         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
16293         return ret_val;
16294 }
16295
16296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16297         if ((_res & 1) != 0) return;
16298         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16299         CHECK_ACCESS(_res_ptr);
16300         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
16301         FREE((void*)_res);
16302         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
16303 }
16304
16305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16306         LDKDelayedPaymentOutputDescriptor o_conv;
16307         o_conv.inner = (void*)(o & (~1));
16308         o_conv.is_owned = (o & 1) || (o == 0);
16309         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16310         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
16311         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16312         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16313         return (int64_t)ret_conv;
16314 }
16315
16316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16317         LDKDecodeError e_conv;
16318         e_conv.inner = (void*)(e & (~1));
16319         e_conv.is_owned = (e & 1) || (e == 0);
16320         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16321         e_conv = DecodeError_clone(&e_conv);
16322         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16323         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16324         return (int64_t)ret_conv;
16325 }
16326
16327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16328         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16329         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16330         return ret_val;
16331 }
16332
16333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16334         if ((_res & 1) != 0) return;
16335         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16336         CHECK_ACCESS(_res_ptr);
16337         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16338         FREE((void*)_res);
16339         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16340 }
16341
16342 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16343         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16344         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16345         return (int64_t)ret_conv;
16346 }
16347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16348         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16349         int64_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16350         return ret_val;
16351 }
16352
16353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16354         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16355         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16356         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16357         return (int64_t)ret_conv;
16358 }
16359
16360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16361         LDKStaticPaymentOutputDescriptor o_conv;
16362         o_conv.inner = (void*)(o & (~1));
16363         o_conv.is_owned = (o & 1) || (o == 0);
16364         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16365         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
16366         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16367         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16368         return (int64_t)ret_conv;
16369 }
16370
16371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16372         LDKDecodeError e_conv;
16373         e_conv.inner = (void*)(e & (~1));
16374         e_conv.is_owned = (e & 1) || (e == 0);
16375         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16376         e_conv = DecodeError_clone(&e_conv);
16377         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16378         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16379         return (int64_t)ret_conv;
16380 }
16381
16382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16383         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16384         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16385         return ret_val;
16386 }
16387
16388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16389         if ((_res & 1) != 0) return;
16390         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16391         CHECK_ACCESS(_res_ptr);
16392         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16393         FREE((void*)_res);
16394         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16395 }
16396
16397 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16398         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16399         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16400         return (int64_t)ret_conv;
16401 }
16402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16403         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16404         int64_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16405         return ret_val;
16406 }
16407
16408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16409         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16410         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16411         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16412         return (int64_t)ret_conv;
16413 }
16414
16415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16416         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16417         CHECK_ACCESS(o_ptr);
16418         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
16419         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
16420         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16421         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
16422         return (int64_t)ret_conv;
16423 }
16424
16425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16426         LDKDecodeError e_conv;
16427         e_conv.inner = (void*)(e & (~1));
16428         e_conv.is_owned = (e & 1) || (e == 0);
16429         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16430         e_conv = DecodeError_clone(&e_conv);
16431         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16432         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
16433         return (int64_t)ret_conv;
16434 }
16435
16436 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16437         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
16438         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16439         return ret_val;
16440 }
16441
16442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16443         if ((_res & 1) != 0) return;
16444         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16445         CHECK_ACCESS(_res_ptr);
16446         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
16447         FREE((void*)_res);
16448         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
16449 }
16450
16451 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16452         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16453         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
16454         return (int64_t)ret_conv;
16455 }
16456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16457         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
16458         int64_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16459         return ret_val;
16460 }
16461
16462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16463         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
16464         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16465         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
16466         return (int64_t)ret_conv;
16467 }
16468
16469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16470         LDKCVec_PaymentPreimageZ _res_constr;
16471         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16472         if (_res_constr.datalen > 0)
16473                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
16474         else
16475                 _res_constr.data = NULL;
16476         for (size_t i = 0; i < _res_constr.datalen; i++) {
16477                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16478                 LDKThirtyTwoBytes _res_conv_8_ref;
16479                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
16480                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
16481                 _res_constr.data[i] = _res_conv_8_ref;
16482         }
16483         CVec_PaymentPreimageZ_free(_res_constr);
16484 }
16485
16486 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
16487         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16488         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
16489         return ((int64_t)ret_conv);
16490 }
16491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16492         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
16493         int64_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
16494         return ret_val;
16495 }
16496
16497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16498         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
16499         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16500         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
16501         return ((int64_t)ret_conv);
16502 }
16503
16504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
16505         LDKSignature a_ref;
16506         CHECK((*env)->GetArrayLength(env, a) == 64);
16507         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16508         LDKCVec_SignatureZ b_constr;
16509         b_constr.datalen = (*env)->GetArrayLength(env, b);
16510         if (b_constr.datalen > 0)
16511                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16512         else
16513                 b_constr.data = NULL;
16514         for (size_t i = 0; i < b_constr.datalen; i++) {
16515                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
16516                 LDKSignature b_conv_8_ref;
16517                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
16518                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
16519                 b_constr.data[i] = b_conv_8_ref;
16520         }
16521         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16522         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
16523         return ((int64_t)ret_conv);
16524 }
16525
16526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16527         if ((_res & 1) != 0) return;
16528         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16529         CHECK_ACCESS(_res_ptr);
16530         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
16531         FREE((void*)_res);
16532         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
16533 }
16534
16535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16536         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16537         CHECK_ACCESS(o_ptr);
16538         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
16539         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
16540         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16541         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
16542         return (int64_t)ret_conv;
16543 }
16544
16545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
16546         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16547         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
16548         return (int64_t)ret_conv;
16549 }
16550
16551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16552         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
16553         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
16554         return ret_val;
16555 }
16556
16557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16558         if ((_res & 1) != 0) return;
16559         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16560         CHECK_ACCESS(_res_ptr);
16561         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
16562         FREE((void*)_res);
16563         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
16564 }
16565
16566 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
16567         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16568         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
16569         return (int64_t)ret_conv;
16570 }
16571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16572         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
16573         int64_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
16574         return ret_val;
16575 }
16576
16577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16578         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
16579         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16580         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
16581         return (int64_t)ret_conv;
16582 }
16583
16584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16585         LDKSignature o_ref;
16586         CHECK((*env)->GetArrayLength(env, o) == 64);
16587         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
16588         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16589         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
16590         return (int64_t)ret_conv;
16591 }
16592
16593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
16594         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16595         *ret_conv = CResult_SignatureNoneZ_err();
16596         return (int64_t)ret_conv;
16597 }
16598
16599 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16600         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
16601         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
16602         return ret_val;
16603 }
16604
16605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16606         if ((_res & 1) != 0) return;
16607         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16608         CHECK_ACCESS(_res_ptr);
16609         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
16610         FREE((void*)_res);
16611         CResult_SignatureNoneZ_free(_res_conv);
16612 }
16613
16614 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
16615         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16616         *ret_conv = CResult_SignatureNoneZ_clone(arg);
16617         return (int64_t)ret_conv;
16618 }
16619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16620         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
16621         int64_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
16622         return ret_val;
16623 }
16624
16625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16626         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
16627         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16628         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
16629         return (int64_t)ret_conv;
16630 }
16631
16632 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
16633         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16634         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
16635         return ((int64_t)ret_conv);
16636 }
16637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16638         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
16639         int64_t ret_val = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
16640         return ret_val;
16641 }
16642
16643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16644         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
16645         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16646         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
16647         return ((int64_t)ret_conv);
16648 }
16649
16650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
16651         LDKSignature a_ref;
16652         CHECK((*env)->GetArrayLength(env, a) == 64);
16653         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16654         LDKSignature b_ref;
16655         CHECK((*env)->GetArrayLength(env, b) == 64);
16656         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
16657         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16658         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
16659         return ((int64_t)ret_conv);
16660 }
16661
16662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16663         if ((_res & 1) != 0) return;
16664         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16665         CHECK_ACCESS(_res_ptr);
16666         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
16667         FREE((void*)_res);
16668         C2Tuple_SignatureSignatureZ_free(_res_conv);
16669 }
16670
16671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16672         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16673         CHECK_ACCESS(o_ptr);
16674         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
16675         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
16676         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16677         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
16678         return (int64_t)ret_conv;
16679 }
16680
16681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
16682         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16683         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
16684         return (int64_t)ret_conv;
16685 }
16686
16687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16688         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
16689         jboolean ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
16690         return ret_val;
16691 }
16692
16693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16694         if ((_res & 1) != 0) return;
16695         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16696         CHECK_ACCESS(_res_ptr);
16697         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
16698         FREE((void*)_res);
16699         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
16700 }
16701
16702 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
16703         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16704         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
16705         return (int64_t)ret_conv;
16706 }
16707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16708         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
16709         int64_t ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
16710         return ret_val;
16711 }
16712
16713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16714         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
16715         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16716         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
16717         return (int64_t)ret_conv;
16718 }
16719
16720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16721         LDKSecretKey o_ref;
16722         CHECK((*env)->GetArrayLength(env, o) == 32);
16723         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
16724         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
16725         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
16726         return (int64_t)ret_conv;
16727 }
16728
16729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
16730         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
16731         *ret_conv = CResult_SecretKeyNoneZ_err();
16732         return (int64_t)ret_conv;
16733 }
16734
16735 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16736         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
16737         jboolean ret_val = CResult_SecretKeyNoneZ_is_ok(o_conv);
16738         return ret_val;
16739 }
16740
16741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16742         if ((_res & 1) != 0) return;
16743         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16744         CHECK_ACCESS(_res_ptr);
16745         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
16746         FREE((void*)_res);
16747         CResult_SecretKeyNoneZ_free(_res_conv);
16748 }
16749
16750 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
16751         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
16752         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
16753         return (int64_t)ret_conv;
16754 }
16755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16756         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
16757         int64_t ret_val = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
16758         return ret_val;
16759 }
16760
16761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16762         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
16763         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
16764         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
16765         return (int64_t)ret_conv;
16766 }
16767
16768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16769         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16770         CHECK_ACCESS(o_ptr);
16771         LDKSign o_conv = *(LDKSign*)(o_ptr);
16772         if (o_conv.free == LDKSign_JCalls_free) {
16773                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16774                 LDKSign_JCalls_cloned(&o_conv);
16775         }
16776         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
16777         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
16778         return (int64_t)ret_conv;
16779 }
16780
16781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16782         LDKDecodeError e_conv;
16783         e_conv.inner = (void*)(e & (~1));
16784         e_conv.is_owned = (e & 1) || (e == 0);
16785         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16786         e_conv = DecodeError_clone(&e_conv);
16787         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
16788         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
16789         return (int64_t)ret_conv;
16790 }
16791
16792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16793         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
16794         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
16795         return ret_val;
16796 }
16797
16798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16799         if ((_res & 1) != 0) return;
16800         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16801         CHECK_ACCESS(_res_ptr);
16802         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
16803         FREE((void*)_res);
16804         CResult_SignDecodeErrorZ_free(_res_conv);
16805 }
16806
16807 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
16808         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
16809         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
16810         return (int64_t)ret_conv;
16811 }
16812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16813         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
16814         int64_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
16815         return ret_val;
16816 }
16817
16818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16819         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
16820         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
16821         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
16822         return (int64_t)ret_conv;
16823 }
16824
16825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16826         LDKCVec_u5Z _res_constr;
16827         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16828         if (_res_constr.datalen > 0)
16829                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
16830         else
16831                 _res_constr.data = NULL;
16832         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
16833         for (size_t h = 0; h < _res_constr.datalen; h++) {
16834                 int8_t _res_conv_7 = _res_vals[h];
16835                 
16836                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
16837         }
16838         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
16839         CVec_u5Z_free(_res_constr);
16840 }
16841
16842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16843         LDKRecoverableSignature o_ref;
16844         CHECK((*env)->GetArrayLength(env, o) == 68);
16845         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
16846         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
16847         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
16848         return (int64_t)ret_conv;
16849 }
16850
16851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
16852         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
16853         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
16854         return (int64_t)ret_conv;
16855 }
16856
16857 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16858         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
16859         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
16860         return ret_val;
16861 }
16862
16863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16864         if ((_res & 1) != 0) return;
16865         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16866         CHECK_ACCESS(_res_ptr);
16867         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
16868         FREE((void*)_res);
16869         CResult_RecoverableSignatureNoneZ_free(_res_conv);
16870 }
16871
16872 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
16873         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
16874         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
16875         return (int64_t)ret_conv;
16876 }
16877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16878         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
16879         int64_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
16880         return ret_val;
16881 }
16882
16883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16884         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
16885         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
16886         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
16887         return (int64_t)ret_conv;
16888 }
16889
16890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
16891         LDKCVec_u8Z _res_ref;
16892         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
16893         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
16894         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
16895         CVec_u8Z_free(_res_ref);
16896 }
16897
16898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16899         LDKCVec_CVec_u8ZZ _res_constr;
16900         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16901         if (_res_constr.datalen > 0)
16902                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
16903         else
16904                 _res_constr.data = NULL;
16905         for (size_t i = 0; i < _res_constr.datalen; i++) {
16906                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16907                 LDKCVec_u8Z _res_conv_8_ref;
16908                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
16909                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
16910                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
16911                 _res_constr.data[i] = _res_conv_8_ref;
16912         }
16913         CVec_CVec_u8ZZ_free(_res_constr);
16914 }
16915
16916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
16917         LDKCVec_CVec_u8ZZ o_constr;
16918         o_constr.datalen = (*env)->GetArrayLength(env, o);
16919         if (o_constr.datalen > 0)
16920                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
16921         else
16922                 o_constr.data = NULL;
16923         for (size_t i = 0; i < o_constr.datalen; i++) {
16924                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
16925                 LDKCVec_u8Z o_conv_8_ref;
16926                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
16927                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
16928                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
16929                 o_constr.data[i] = o_conv_8_ref;
16930         }
16931         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16932         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
16933         return (int64_t)ret_conv;
16934 }
16935
16936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
16937         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16938         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
16939         return (int64_t)ret_conv;
16940 }
16941
16942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16943         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
16944         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
16945         return ret_val;
16946 }
16947
16948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16949         if ((_res & 1) != 0) return;
16950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16951         CHECK_ACCESS(_res_ptr);
16952         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
16953         FREE((void*)_res);
16954         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
16955 }
16956
16957 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
16958         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16959         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
16960         return (int64_t)ret_conv;
16961 }
16962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16963         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
16964         int64_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
16965         return ret_val;
16966 }
16967
16968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16969         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
16970         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16971         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
16972         return (int64_t)ret_conv;
16973 }
16974
16975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16976         LDKInMemorySigner o_conv;
16977         o_conv.inner = (void*)(o & (~1));
16978         o_conv.is_owned = (o & 1) || (o == 0);
16979         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16980         o_conv = InMemorySigner_clone(&o_conv);
16981         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16982         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
16983         return (int64_t)ret_conv;
16984 }
16985
16986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16987         LDKDecodeError e_conv;
16988         e_conv.inner = (void*)(e & (~1));
16989         e_conv.is_owned = (e & 1) || (e == 0);
16990         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16991         e_conv = DecodeError_clone(&e_conv);
16992         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16993         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
16994         return (int64_t)ret_conv;
16995 }
16996
16997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16998         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
16999         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
17000         return ret_val;
17001 }
17002
17003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17004         if ((_res & 1) != 0) return;
17005         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17006         CHECK_ACCESS(_res_ptr);
17007         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
17008         FREE((void*)_res);
17009         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
17010 }
17011
17012 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
17013         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17014         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
17015         return (int64_t)ret_conv;
17016 }
17017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17018         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
17019         int64_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
17020         return ret_val;
17021 }
17022
17023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17024         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
17025         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17026         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
17027         return (int64_t)ret_conv;
17028 }
17029
17030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17031         LDKCVec_TxOutZ _res_constr;
17032         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17033         if (_res_constr.datalen > 0)
17034                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
17035         else
17036                 _res_constr.data = NULL;
17037         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17038         for (size_t h = 0; h < _res_constr.datalen; h++) {
17039                 int64_t _res_conv_7 = _res_vals[h];
17040                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17041                 CHECK_ACCESS(_res_conv_7_ptr);
17042                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
17043                 FREE((void*)_res_conv_7);
17044                 _res_constr.data[h] = _res_conv_7_conv;
17045         }
17046         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17047         CVec_TxOutZ_free(_res_constr);
17048 }
17049
17050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17051         LDKTransaction o_ref;
17052         o_ref.datalen = (*env)->GetArrayLength(env, o);
17053         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
17054         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
17055         o_ref.data_is_owned = true;
17056         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17057         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
17058         return (int64_t)ret_conv;
17059 }
17060
17061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
17062         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17063         *ret_conv = CResult_TransactionNoneZ_err();
17064         return (int64_t)ret_conv;
17065 }
17066
17067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17068         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
17069         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
17070         return ret_val;
17071 }
17072
17073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17074         if ((_res & 1) != 0) return;
17075         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17076         CHECK_ACCESS(_res_ptr);
17077         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
17078         FREE((void*)_res);
17079         CResult_TransactionNoneZ_free(_res_conv);
17080 }
17081
17082 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
17083         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17084         *ret_conv = CResult_TransactionNoneZ_clone(arg);
17085         return (int64_t)ret_conv;
17086 }
17087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17088         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
17089         int64_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
17090         return ret_val;
17091 }
17092
17093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17094         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
17095         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17096         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
17097         return (int64_t)ret_conv;
17098 }
17099
17100 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
17101         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17102         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
17103         return ((int64_t)ret_conv);
17104 }
17105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17106         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
17107         int64_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
17108         return ret_val;
17109 }
17110
17111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17112         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
17113         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17114         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
17115         return ((int64_t)ret_conv);
17116 }
17117
17118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
17119         LDKThirtyTwoBytes a_ref;
17120         CHECK((*env)->GetArrayLength(env, a) == 32);
17121         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17122         LDKChannelMonitor b_conv;
17123         b_conv.inner = (void*)(b & (~1));
17124         b_conv.is_owned = (b & 1) || (b == 0);
17125         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17126         b_conv = ChannelMonitor_clone(&b_conv);
17127         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17128         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
17129         return ((int64_t)ret_conv);
17130 }
17131
17132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17133         if ((_res & 1) != 0) return;
17134         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17135         CHECK_ACCESS(_res_ptr);
17136         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
17137         FREE((void*)_res);
17138         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
17139 }
17140
17141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17142         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
17143         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17144         if (_res_constr.datalen > 0)
17145                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17146         else
17147                 _res_constr.data = NULL;
17148         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17149         for (size_t j = 0; j < _res_constr.datalen; j++) {
17150                 int64_t _res_conv_35 = _res_vals[j];
17151                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
17152                 CHECK_ACCESS(_res_conv_35_ptr);
17153                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
17154                 FREE((void*)_res_conv_35);
17155                 _res_constr.data[j] = _res_conv_35_conv;
17156         }
17157         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17158         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
17159 }
17160
17161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
17162         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
17163         o_constr.datalen = (*env)->GetArrayLength(env, o);
17164         if (o_constr.datalen > 0)
17165                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17166         else
17167                 o_constr.data = NULL;
17168         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17169         for (size_t j = 0; j < o_constr.datalen; j++) {
17170                 int64_t o_conv_35 = o_vals[j];
17171                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
17172                 CHECK_ACCESS(o_conv_35_ptr);
17173                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
17174                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
17175                 o_constr.data[j] = o_conv_35_conv;
17176         }
17177         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17178         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17179         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
17180         return (int64_t)ret_conv;
17181 }
17182
17183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17184         LDKIOError e_conv = LDKIOError_from_java(env, e);
17185         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17186         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
17187         return (int64_t)ret_conv;
17188 }
17189
17190 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17191         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
17192         jboolean ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
17193         return ret_val;
17194 }
17195
17196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17197         if ((_res & 1) != 0) return;
17198         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17199         CHECK_ACCESS(_res_ptr);
17200         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
17201         FREE((void*)_res);
17202         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
17203 }
17204
17205 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
17206         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17207         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
17208         return (int64_t)ret_conv;
17209 }
17210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17211         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
17212         int64_t ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
17213         return ret_val;
17214 }
17215
17216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17217         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
17218         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17219         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
17220         return (int64_t)ret_conv;
17221 }
17222
17223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
17224         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17225         *ret_copy = COption_u16Z_some(o);
17226         int64_t ret_ref = (uintptr_t)ret_copy;
17227         return ret_ref;
17228 }
17229
17230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
17231         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17232         *ret_copy = COption_u16Z_none();
17233         int64_t ret_ref = (uintptr_t)ret_copy;
17234         return ret_ref;
17235 }
17236
17237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17238         if ((_res & 1) != 0) return;
17239         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17240         CHECK_ACCESS(_res_ptr);
17241         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
17242         FREE((void*)_res);
17243         COption_u16Z_free(_res_conv);
17244 }
17245
17246 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
17247         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17248         *ret_copy = COption_u16Z_clone(arg);
17249 int64_t ret_ref = (uintptr_t)ret_copy;
17250         return ret_ref;
17251 }
17252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17253         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
17254         int64_t ret_val = COption_u16Z_clone_ptr(arg_conv);
17255         return ret_val;
17256 }
17257
17258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17259         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
17260         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17261         *ret_copy = COption_u16Z_clone(orig_conv);
17262         int64_t ret_ref = (uintptr_t)ret_copy;
17263         return ret_ref;
17264 }
17265
17266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
17267         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17268         *ret_conv = CResult_NoneAPIErrorZ_ok();
17269         return (int64_t)ret_conv;
17270 }
17271
17272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17273         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17274         CHECK_ACCESS(e_ptr);
17275         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17276         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17277         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17278         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
17279         return (int64_t)ret_conv;
17280 }
17281
17282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17283         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
17284         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
17285         return ret_val;
17286 }
17287
17288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17289         if ((_res & 1) != 0) return;
17290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17291         CHECK_ACCESS(_res_ptr);
17292         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
17293         FREE((void*)_res);
17294         CResult_NoneAPIErrorZ_free(_res_conv);
17295 }
17296
17297 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
17298         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17299         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
17300         return (int64_t)ret_conv;
17301 }
17302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17303         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
17304         int64_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
17305         return ret_val;
17306 }
17307
17308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17309         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
17310         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17311         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
17312         return (int64_t)ret_conv;
17313 }
17314
17315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17316         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
17317         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17318         if (_res_constr.datalen > 0)
17319                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17320         else
17321                 _res_constr.data = NULL;
17322         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17323         for (size_t w = 0; w < _res_constr.datalen; w++) {
17324                 int64_t _res_conv_22 = _res_vals[w];
17325                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
17326                 CHECK_ACCESS(_res_conv_22_ptr);
17327                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
17328                 FREE((void*)_res_conv_22);
17329                 _res_constr.data[w] = _res_conv_22_conv;
17330         }
17331         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17332         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
17333 }
17334
17335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17336         LDKCVec_APIErrorZ _res_constr;
17337         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17338         if (_res_constr.datalen > 0)
17339                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
17340         else
17341                 _res_constr.data = NULL;
17342         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17343         for (size_t k = 0; k < _res_constr.datalen; k++) {
17344                 int64_t _res_conv_10 = _res_vals[k];
17345                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
17346                 CHECK_ACCESS(_res_conv_10_ptr);
17347                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
17348                 FREE((void*)_res_conv_10);
17349                 _res_constr.data[k] = _res_conv_10_conv;
17350         }
17351         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17352         CVec_APIErrorZ_free(_res_constr);
17353 }
17354
17355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17356         LDKThirtyTwoBytes o_ref;
17357         CHECK((*env)->GetArrayLength(env, o) == 32);
17358         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17359         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17360         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
17361         return (int64_t)ret_conv;
17362 }
17363
17364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17365         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17366         CHECK_ACCESS(e_ptr);
17367         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17368         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17369         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17370         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
17371         return (int64_t)ret_conv;
17372 }
17373
17374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17375         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
17376         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
17377         return ret_val;
17378 }
17379
17380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17381         if ((_res & 1) != 0) return;
17382         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17383         CHECK_ACCESS(_res_ptr);
17384         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
17385         FREE((void*)_res);
17386         CResult__u832APIErrorZ_free(_res_conv);
17387 }
17388
17389 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
17390         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17391         *ret_conv = CResult__u832APIErrorZ_clone(arg);
17392         return (int64_t)ret_conv;
17393 }
17394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17395         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
17396         int64_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
17397         return ret_val;
17398 }
17399
17400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17401         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
17402         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17403         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
17404         return (int64_t)ret_conv;
17405 }
17406
17407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17408         LDKThirtyTwoBytes o_ref;
17409         CHECK((*env)->GetArrayLength(env, o) == 32);
17410         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17411         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17412         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
17413         return (int64_t)ret_conv;
17414 }
17415
17416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17417         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17418         CHECK_ACCESS(e_ptr);
17419         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17420         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17421         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17422         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
17423         return (int64_t)ret_conv;
17424 }
17425
17426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17427         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
17428         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
17429         return ret_val;
17430 }
17431
17432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17433         if ((_res & 1) != 0) return;
17434         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17435         CHECK_ACCESS(_res_ptr);
17436         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
17437         FREE((void*)_res);
17438         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
17439 }
17440
17441 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
17442         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17443         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
17444         return (int64_t)ret_conv;
17445 }
17446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17447         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
17448         int64_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
17449         return ret_val;
17450 }
17451
17452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17453         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
17454         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17455         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
17456         return (int64_t)ret_conv;
17457 }
17458
17459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
17460         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17461         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
17462         return (int64_t)ret_conv;
17463 }
17464
17465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17466         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17467         CHECK_ACCESS(e_ptr);
17468         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17469         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17470         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17471         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
17472         return (int64_t)ret_conv;
17473 }
17474
17475 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17476         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
17477         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
17478         return ret_val;
17479 }
17480
17481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17482         if ((_res & 1) != 0) return;
17483         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17484         CHECK_ACCESS(_res_ptr);
17485         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
17486         FREE((void*)_res);
17487         CResult_NonePaymentSendFailureZ_free(_res_conv);
17488 }
17489
17490 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
17491         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17492         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
17493         return (int64_t)ret_conv;
17494 }
17495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17496         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
17497         int64_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
17498         return ret_val;
17499 }
17500
17501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17502         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
17503         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17504         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
17505         return (int64_t)ret_conv;
17506 }
17507
17508 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
17509         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17510         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
17511         return ((int64_t)ret_conv);
17512 }
17513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17514         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
17515         int64_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
17516         return ret_val;
17517 }
17518
17519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17520         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
17521         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17522         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
17523         return ((int64_t)ret_conv);
17524 }
17525
17526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17527         LDKThirtyTwoBytes a_ref;
17528         CHECK((*env)->GetArrayLength(env, a) == 32);
17529         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17530         LDKThirtyTwoBytes b_ref;
17531         CHECK((*env)->GetArrayLength(env, b) == 32);
17532         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17533         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17534         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
17535         return ((int64_t)ret_conv);
17536 }
17537
17538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17539         if ((_res & 1) != 0) return;
17540         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17541         CHECK_ACCESS(_res_ptr);
17542         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
17543         FREE((void*)_res);
17544         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
17545 }
17546
17547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17548         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17549         CHECK_ACCESS(o_ptr);
17550         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
17551         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
17552         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17553         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
17554         return (int64_t)ret_conv;
17555 }
17556
17557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17558         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17559         CHECK_ACCESS(e_ptr);
17560         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17561         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17562         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17563         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
17564         return (int64_t)ret_conv;
17565 }
17566
17567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17568         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
17569         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
17570         return ret_val;
17571 }
17572
17573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17574         if ((_res & 1) != 0) return;
17575         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17576         CHECK_ACCESS(_res_ptr);
17577         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
17578         FREE((void*)_res);
17579         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
17580 }
17581
17582 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
17583         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17584         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
17585         return (int64_t)ret_conv;
17586 }
17587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17588         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
17589         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
17590         return ret_val;
17591 }
17592
17593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17594         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
17595         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17596         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
17597         return (int64_t)ret_conv;
17598 }
17599
17600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17601         LDKCVec_NetAddressZ _res_constr;
17602         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17603         if (_res_constr.datalen > 0)
17604                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17605         else
17606                 _res_constr.data = NULL;
17607         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17608         for (size_t m = 0; m < _res_constr.datalen; m++) {
17609                 int64_t _res_conv_12 = _res_vals[m];
17610                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
17611                 CHECK_ACCESS(_res_conv_12_ptr);
17612                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
17613                 FREE((void*)_res_conv_12);
17614                 _res_constr.data[m] = _res_conv_12_conv;
17615         }
17616         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17617         CVec_NetAddressZ_free(_res_constr);
17618 }
17619
17620 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
17621         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17622         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
17623         return ((int64_t)ret_conv);
17624 }
17625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17626         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
17627         int64_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
17628         return ret_val;
17629 }
17630
17631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17632         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
17633         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17634         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
17635         return ((int64_t)ret_conv);
17636 }
17637
17638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17639         LDKThirtyTwoBytes a_ref;
17640         CHECK((*env)->GetArrayLength(env, a) == 32);
17641         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17642         LDKThirtyTwoBytes b_ref;
17643         CHECK((*env)->GetArrayLength(env, b) == 32);
17644         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17645         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17646         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
17647         return ((int64_t)ret_conv);
17648 }
17649
17650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17651         if ((_res & 1) != 0) return;
17652         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17653         CHECK_ACCESS(_res_ptr);
17654         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
17655         FREE((void*)_res);
17656         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
17657 }
17658
17659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17660         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17661         CHECK_ACCESS(o_ptr);
17662         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
17663         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
17664         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17665         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
17666         return (int64_t)ret_conv;
17667 }
17668
17669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
17670         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17671         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
17672         return (int64_t)ret_conv;
17673 }
17674
17675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17676         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
17677         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
17678         return ret_val;
17679 }
17680
17681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17682         if ((_res & 1) != 0) return;
17683         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17684         CHECK_ACCESS(_res_ptr);
17685         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
17686         FREE((void*)_res);
17687         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
17688 }
17689
17690 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
17691         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17692         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
17693         return (int64_t)ret_conv;
17694 }
17695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17696         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
17697         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
17698         return ret_val;
17699 }
17700
17701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17702         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
17703         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17704         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
17705         return (int64_t)ret_conv;
17706 }
17707
17708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17709         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17710         CHECK_ACCESS(o_ptr);
17711         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
17712         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
17713         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
17714         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
17715         return (int64_t)ret_conv;
17716 }
17717
17718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17719         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17720         CHECK_ACCESS(e_ptr);
17721         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17722         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17723         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
17724         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
17725         return (int64_t)ret_conv;
17726 }
17727
17728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17729         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
17730         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
17731         return ret_val;
17732 }
17733
17734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17735         if ((_res & 1) != 0) return;
17736         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17737         CHECK_ACCESS(_res_ptr);
17738         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
17739         FREE((void*)_res);
17740         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
17741 }
17742
17743 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
17744         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
17745         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
17746         return (int64_t)ret_conv;
17747 }
17748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17749         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
17750         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
17751         return ret_val;
17752 }
17753
17754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17755         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
17756         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
17757         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
17758         return (int64_t)ret_conv;
17759 }
17760
17761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17762         LDKThirtyTwoBytes o_ref;
17763         CHECK((*env)->GetArrayLength(env, o) == 32);
17764         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17765         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
17766         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
17767         return (int64_t)ret_conv;
17768 }
17769
17770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
17771         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
17772         *ret_conv = CResult_PaymentSecretNoneZ_err();
17773         return (int64_t)ret_conv;
17774 }
17775
17776 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17777         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
17778         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
17779         return ret_val;
17780 }
17781
17782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17783         if ((_res & 1) != 0) return;
17784         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17785         CHECK_ACCESS(_res_ptr);
17786         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
17787         FREE((void*)_res);
17788         CResult_PaymentSecretNoneZ_free(_res_conv);
17789 }
17790
17791 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
17792         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
17793         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
17794         return (int64_t)ret_conv;
17795 }
17796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17797         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
17798         int64_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
17799         return ret_val;
17800 }
17801
17802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17803         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
17804         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
17805         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
17806         return (int64_t)ret_conv;
17807 }
17808
17809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17810         LDKThirtyTwoBytes o_ref;
17811         CHECK((*env)->GetArrayLength(env, o) == 32);
17812         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17813         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17814         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
17815         return (int64_t)ret_conv;
17816 }
17817
17818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17819         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17820         CHECK_ACCESS(e_ptr);
17821         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17822         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17823         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17824         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
17825         return (int64_t)ret_conv;
17826 }
17827
17828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17829         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
17830         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
17831         return ret_val;
17832 }
17833
17834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17835         if ((_res & 1) != 0) return;
17836         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17837         CHECK_ACCESS(_res_ptr);
17838         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
17839         FREE((void*)_res);
17840         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
17841 }
17842
17843 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
17844         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17845         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
17846         return (int64_t)ret_conv;
17847 }
17848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17849         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
17850         int64_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
17851         return ret_val;
17852 }
17853
17854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17855         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
17856         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17857         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
17858         return (int64_t)ret_conv;
17859 }
17860
17861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17862         LDKThirtyTwoBytes o_ref;
17863         CHECK((*env)->GetArrayLength(env, o) == 32);
17864         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17865         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
17866         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
17867         return (int64_t)ret_conv;
17868 }
17869
17870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17871         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17872         CHECK_ACCESS(e_ptr);
17873         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17874         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17875         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
17876         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
17877         return (int64_t)ret_conv;
17878 }
17879
17880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17881         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
17882         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
17883         return ret_val;
17884 }
17885
17886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17887         if ((_res & 1) != 0) return;
17888         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17889         CHECK_ACCESS(_res_ptr);
17890         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
17891         FREE((void*)_res);
17892         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
17893 }
17894
17895 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
17896         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
17897         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
17898         return (int64_t)ret_conv;
17899 }
17900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17901         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
17902         int64_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
17903         return ret_val;
17904 }
17905
17906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17907         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
17908         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
17909         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
17910         return (int64_t)ret_conv;
17911 }
17912
17913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17914         LDKCounterpartyForwardingInfo o_conv;
17915         o_conv.inner = (void*)(o & (~1));
17916         o_conv.is_owned = (o & 1) || (o == 0);
17917         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17918         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
17919         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
17920         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
17921         return (int64_t)ret_conv;
17922 }
17923
17924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17925         LDKDecodeError e_conv;
17926         e_conv.inner = (void*)(e & (~1));
17927         e_conv.is_owned = (e & 1) || (e == 0);
17928         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17929         e_conv = DecodeError_clone(&e_conv);
17930         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
17931         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
17932         return (int64_t)ret_conv;
17933 }
17934
17935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17936         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
17937         jboolean ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
17938         return ret_val;
17939 }
17940
17941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17942         if ((_res & 1) != 0) return;
17943         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17944         CHECK_ACCESS(_res_ptr);
17945         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
17946         FREE((void*)_res);
17947         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
17948 }
17949
17950 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
17951         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
17952         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
17953         return (int64_t)ret_conv;
17954 }
17955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17956         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
17957         int64_t ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
17958         return ret_val;
17959 }
17960
17961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17962         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
17963         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
17964         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
17965         return (int64_t)ret_conv;
17966 }
17967
17968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17969         LDKChannelCounterparty o_conv;
17970         o_conv.inner = (void*)(o & (~1));
17971         o_conv.is_owned = (o & 1) || (o == 0);
17972         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17973         o_conv = ChannelCounterparty_clone(&o_conv);
17974         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
17975         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
17976         return (int64_t)ret_conv;
17977 }
17978
17979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17980         LDKDecodeError e_conv;
17981         e_conv.inner = (void*)(e & (~1));
17982         e_conv.is_owned = (e & 1) || (e == 0);
17983         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17984         e_conv = DecodeError_clone(&e_conv);
17985         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
17986         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
17987         return (int64_t)ret_conv;
17988 }
17989
17990 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17991         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
17992         jboolean ret_val = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
17993         return ret_val;
17994 }
17995
17996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17997         if ((_res & 1) != 0) return;
17998         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17999         CHECK_ACCESS(_res_ptr);
18000         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
18001         FREE((void*)_res);
18002         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
18003 }
18004
18005 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
18006         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18007         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
18008         return (int64_t)ret_conv;
18009 }
18010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18011         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
18012         int64_t ret_val = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
18013         return ret_val;
18014 }
18015
18016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18017         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
18018         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18019         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
18020         return (int64_t)ret_conv;
18021 }
18022
18023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18024         LDKChannelDetails o_conv;
18025         o_conv.inner = (void*)(o & (~1));
18026         o_conv.is_owned = (o & 1) || (o == 0);
18027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18028         o_conv = ChannelDetails_clone(&o_conv);
18029         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18030         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
18031         return (int64_t)ret_conv;
18032 }
18033
18034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18035         LDKDecodeError e_conv;
18036         e_conv.inner = (void*)(e & (~1));
18037         e_conv.is_owned = (e & 1) || (e == 0);
18038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18039         e_conv = DecodeError_clone(&e_conv);
18040         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18041         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
18042         return (int64_t)ret_conv;
18043 }
18044
18045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18046         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
18047         jboolean ret_val = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
18048         return ret_val;
18049 }
18050
18051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18052         if ((_res & 1) != 0) return;
18053         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18054         CHECK_ACCESS(_res_ptr);
18055         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
18056         FREE((void*)_res);
18057         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
18058 }
18059
18060 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
18061         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18062         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
18063         return (int64_t)ret_conv;
18064 }
18065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18066         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
18067         int64_t ret_val = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
18068         return ret_val;
18069 }
18070
18071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18072         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
18073         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18074         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
18075         return (int64_t)ret_conv;
18076 }
18077
18078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18079         LDKPhantomRouteHints o_conv;
18080         o_conv.inner = (void*)(o & (~1));
18081         o_conv.is_owned = (o & 1) || (o == 0);
18082         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18083         o_conv = PhantomRouteHints_clone(&o_conv);
18084         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18085         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
18086         return (int64_t)ret_conv;
18087 }
18088
18089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18090         LDKDecodeError e_conv;
18091         e_conv.inner = (void*)(e & (~1));
18092         e_conv.is_owned = (e & 1) || (e == 0);
18093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18094         e_conv = DecodeError_clone(&e_conv);
18095         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18096         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
18097         return (int64_t)ret_conv;
18098 }
18099
18100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18101         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
18102         jboolean ret_val = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
18103         return ret_val;
18104 }
18105
18106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18107         if ((_res & 1) != 0) return;
18108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18109         CHECK_ACCESS(_res_ptr);
18110         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
18111         FREE((void*)_res);
18112         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
18113 }
18114
18115 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
18116         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18117         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
18118         return (int64_t)ret_conv;
18119 }
18120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18121         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
18122         int64_t ret_val = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
18123         return ret_val;
18124 }
18125
18126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18127         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
18128         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18129         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
18130         return (int64_t)ret_conv;
18131 }
18132
18133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18134         LDKCVec_ChannelMonitorZ _res_constr;
18135         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18136         if (_res_constr.datalen > 0)
18137                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
18138         else
18139                 _res_constr.data = NULL;
18140         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18141         for (size_t q = 0; q < _res_constr.datalen; q++) {
18142                 int64_t _res_conv_16 = _res_vals[q];
18143                 LDKChannelMonitor _res_conv_16_conv;
18144                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
18145                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18146                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18147                 _res_constr.data[q] = _res_conv_16_conv;
18148         }
18149         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18150         CVec_ChannelMonitorZ_free(_res_constr);
18151 }
18152
18153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18154         LDKThirtyTwoBytes a_ref;
18155         CHECK((*env)->GetArrayLength(env, a) == 32);
18156         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18157         LDKChannelManager b_conv;
18158         b_conv.inner = (void*)(b & (~1));
18159         b_conv.is_owned = (b & 1) || (b == 0);
18160         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18161         // WARNING: we need a move here but no clone is available for LDKChannelManager
18162         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
18163         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
18164         return ((int64_t)ret_conv);
18165 }
18166
18167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18168         if ((_res & 1) != 0) return;
18169         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18170         CHECK_ACCESS(_res_ptr);
18171         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
18172         FREE((void*)_res);
18173         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
18174 }
18175
18176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18177         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18178         CHECK_ACCESS(o_ptr);
18179         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
18180         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
18181         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18182         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
18183         return (int64_t)ret_conv;
18184 }
18185
18186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18187         LDKDecodeError e_conv;
18188         e_conv.inner = (void*)(e & (~1));
18189         e_conv.is_owned = (e & 1) || (e == 0);
18190         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18191         e_conv = DecodeError_clone(&e_conv);
18192         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18193         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
18194         return (int64_t)ret_conv;
18195 }
18196
18197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18198         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
18199         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
18200         return ret_val;
18201 }
18202
18203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18204         if ((_res & 1) != 0) return;
18205         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18206         CHECK_ACCESS(_res_ptr);
18207         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
18208         FREE((void*)_res);
18209         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
18210 }
18211
18212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18213         LDKChannelConfig o_conv;
18214         o_conv.inner = (void*)(o & (~1));
18215         o_conv.is_owned = (o & 1) || (o == 0);
18216         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18217         o_conv = ChannelConfig_clone(&o_conv);
18218         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18219         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
18220         return (int64_t)ret_conv;
18221 }
18222
18223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18224         LDKDecodeError e_conv;
18225         e_conv.inner = (void*)(e & (~1));
18226         e_conv.is_owned = (e & 1) || (e == 0);
18227         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18228         e_conv = DecodeError_clone(&e_conv);
18229         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18230         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
18231         return (int64_t)ret_conv;
18232 }
18233
18234 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18235         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
18236         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
18237         return ret_val;
18238 }
18239
18240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18241         if ((_res & 1) != 0) return;
18242         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18243         CHECK_ACCESS(_res_ptr);
18244         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
18245         FREE((void*)_res);
18246         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
18247 }
18248
18249 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
18250         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18251         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
18252         return (int64_t)ret_conv;
18253 }
18254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18255         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
18256         int64_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
18257         return ret_val;
18258 }
18259
18260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18261         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
18262         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18263         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
18264         return (int64_t)ret_conv;
18265 }
18266
18267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18268         LDKOutPoint o_conv;
18269         o_conv.inner = (void*)(o & (~1));
18270         o_conv.is_owned = (o & 1) || (o == 0);
18271         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18272         o_conv = OutPoint_clone(&o_conv);
18273         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18274         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
18275         return (int64_t)ret_conv;
18276 }
18277
18278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18279         LDKDecodeError e_conv;
18280         e_conv.inner = (void*)(e & (~1));
18281         e_conv.is_owned = (e & 1) || (e == 0);
18282         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18283         e_conv = DecodeError_clone(&e_conv);
18284         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18285         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
18286         return (int64_t)ret_conv;
18287 }
18288
18289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18290         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
18291         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
18292         return ret_val;
18293 }
18294
18295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18296         if ((_res & 1) != 0) return;
18297         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18298         CHECK_ACCESS(_res_ptr);
18299         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
18300         FREE((void*)_res);
18301         CResult_OutPointDecodeErrorZ_free(_res_conv);
18302 }
18303
18304 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
18305         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18306         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
18307         return (int64_t)ret_conv;
18308 }
18309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18310         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
18311         int64_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
18312         return ret_val;
18313 }
18314
18315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18316         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
18317         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18318         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
18319         return (int64_t)ret_conv;
18320 }
18321
18322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18323         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18324         CHECK_ACCESS(o_ptr);
18325         LDKType o_conv = *(LDKType*)(o_ptr);
18326         if (o_conv.free == LDKType_JCalls_free) {
18327                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18328                 LDKType_JCalls_cloned(&o_conv);
18329         }
18330         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18331         *ret_copy = COption_TypeZ_some(o_conv);
18332         int64_t ret_ref = (uintptr_t)ret_copy;
18333         return ret_ref;
18334 }
18335
18336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
18337         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18338         *ret_copy = COption_TypeZ_none();
18339         int64_t ret_ref = (uintptr_t)ret_copy;
18340         return ret_ref;
18341 }
18342
18343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18344         if ((_res & 1) != 0) return;
18345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18346         CHECK_ACCESS(_res_ptr);
18347         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
18348         FREE((void*)_res);
18349         COption_TypeZ_free(_res_conv);
18350 }
18351
18352 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
18353         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18354         *ret_copy = COption_TypeZ_clone(arg);
18355 int64_t ret_ref = (uintptr_t)ret_copy;
18356         return ret_ref;
18357 }
18358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18359         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
18360         int64_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
18361         return ret_val;
18362 }
18363
18364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18365         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
18366         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18367         *ret_copy = COption_TypeZ_clone(orig_conv);
18368         int64_t ret_ref = (uintptr_t)ret_copy;
18369         return ret_ref;
18370 }
18371
18372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18373         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18374         CHECK_ACCESS(o_ptr);
18375         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
18376         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
18377         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18378         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
18379         return (int64_t)ret_conv;
18380 }
18381
18382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18383         LDKDecodeError e_conv;
18384         e_conv.inner = (void*)(e & (~1));
18385         e_conv.is_owned = (e & 1) || (e == 0);
18386         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18387         e_conv = DecodeError_clone(&e_conv);
18388         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18389         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
18390         return (int64_t)ret_conv;
18391 }
18392
18393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18394         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
18395         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
18396         return ret_val;
18397 }
18398
18399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18400         if ((_res & 1) != 0) return;
18401         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18402         CHECK_ACCESS(_res_ptr);
18403         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
18404         FREE((void*)_res);
18405         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
18406 }
18407
18408 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
18409         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18410         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
18411         return (int64_t)ret_conv;
18412 }
18413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18414         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
18415         int64_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
18416         return ret_val;
18417 }
18418
18419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18420         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
18421         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18422         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
18423         return (int64_t)ret_conv;
18424 }
18425
18426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18427         LDKThirtyTwoBytes o_ref;
18428         CHECK((*env)->GetArrayLength(env, o) == 32);
18429         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18430         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18431         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
18432         return (int64_t)ret_conv;
18433 }
18434
18435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18436         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18437         CHECK_ACCESS(e_ptr);
18438         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
18439         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
18440         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18441         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
18442         return (int64_t)ret_conv;
18443 }
18444
18445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18446         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
18447         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
18448         return ret_val;
18449 }
18450
18451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18452         if ((_res & 1) != 0) return;
18453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18454         CHECK_ACCESS(_res_ptr);
18455         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
18456         FREE((void*)_res);
18457         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
18458 }
18459
18460 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
18461         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18462         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
18463         return (int64_t)ret_conv;
18464 }
18465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18466         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
18467         int64_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
18468         return ret_val;
18469 }
18470
18471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18472         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
18473         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18474         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
18475         return (int64_t)ret_conv;
18476 }
18477
18478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
18479         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
18480         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
18481         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
18482         return (int64_t)ret_conv;
18483 }
18484
18485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
18486         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
18487         *ret_conv = CResult_SiPrefixNoneZ_err();
18488         return (int64_t)ret_conv;
18489 }
18490
18491 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18492         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
18493         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
18494         return ret_val;
18495 }
18496
18497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18498         if ((_res & 1) != 0) return;
18499         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18500         CHECK_ACCESS(_res_ptr);
18501         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
18502         FREE((void*)_res);
18503         CResult_SiPrefixNoneZ_free(_res_conv);
18504 }
18505
18506 static inline uintptr_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
18507         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
18508         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
18509         return (int64_t)ret_conv;
18510 }
18511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18512         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
18513         int64_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
18514         return ret_val;
18515 }
18516
18517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18518         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
18519         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
18520         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
18521         return (int64_t)ret_conv;
18522 }
18523
18524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18525         LDKInvoice o_conv;
18526         o_conv.inner = (void*)(o & (~1));
18527         o_conv.is_owned = (o & 1) || (o == 0);
18528         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18529         o_conv = Invoice_clone(&o_conv);
18530         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
18531         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
18532         return (int64_t)ret_conv;
18533 }
18534
18535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
18536         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
18537         *ret_conv = CResult_InvoiceNoneZ_err();
18538         return (int64_t)ret_conv;
18539 }
18540
18541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18542         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
18543         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
18544         return ret_val;
18545 }
18546
18547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18548         if ((_res & 1) != 0) return;
18549         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18550         CHECK_ACCESS(_res_ptr);
18551         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
18552         FREE((void*)_res);
18553         CResult_InvoiceNoneZ_free(_res_conv);
18554 }
18555
18556 static inline uintptr_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
18557         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
18558         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
18559         return (int64_t)ret_conv;
18560 }
18561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18562         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
18563         int64_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
18564         return ret_val;
18565 }
18566
18567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18568         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
18569         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
18570         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
18571         return (int64_t)ret_conv;
18572 }
18573
18574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18575         LDKSignedRawInvoice o_conv;
18576         o_conv.inner = (void*)(o & (~1));
18577         o_conv.is_owned = (o & 1) || (o == 0);
18578         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18579         o_conv = SignedRawInvoice_clone(&o_conv);
18580         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
18581         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
18582         return (int64_t)ret_conv;
18583 }
18584
18585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
18586         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
18587         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
18588         return (int64_t)ret_conv;
18589 }
18590
18591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18592         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
18593         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
18594         return ret_val;
18595 }
18596
18597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18598         if ((_res & 1) != 0) return;
18599         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18600         CHECK_ACCESS(_res_ptr);
18601         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
18602         FREE((void*)_res);
18603         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
18604 }
18605
18606 static inline uintptr_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
18607         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
18608         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
18609         return (int64_t)ret_conv;
18610 }
18611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18612         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
18613         int64_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
18614         return ret_val;
18615 }
18616
18617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18618         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
18619         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
18620         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
18621         return (int64_t)ret_conv;
18622 }
18623
18624 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
18625         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18626         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
18627         return ((int64_t)ret_conv);
18628 }
18629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18630         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
18631         int64_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
18632         return ret_val;
18633 }
18634
18635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18636         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
18637         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18638         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
18639         return ((int64_t)ret_conv);
18640 }
18641
18642 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) {
18643         LDKRawInvoice a_conv;
18644         a_conv.inner = (void*)(a & (~1));
18645         a_conv.is_owned = (a & 1) || (a == 0);
18646         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18647         a_conv = RawInvoice_clone(&a_conv);
18648         LDKThirtyTwoBytes b_ref;
18649         CHECK((*env)->GetArrayLength(env, b) == 32);
18650         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18651         LDKInvoiceSignature c_conv;
18652         c_conv.inner = (void*)(c & (~1));
18653         c_conv.is_owned = (c & 1) || (c == 0);
18654         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
18655         c_conv = InvoiceSignature_clone(&c_conv);
18656         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18657         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
18658         return ((int64_t)ret_conv);
18659 }
18660
18661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18662         if ((_res & 1) != 0) return;
18663         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18664         CHECK_ACCESS(_res_ptr);
18665         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
18666         FREE((void*)_res);
18667         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
18668 }
18669
18670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18671         LDKPayeePubKey o_conv;
18672         o_conv.inner = (void*)(o & (~1));
18673         o_conv.is_owned = (o & 1) || (o == 0);
18674         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18675         o_conv = PayeePubKey_clone(&o_conv);
18676         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18677         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
18678         return (int64_t)ret_conv;
18679 }
18680
18681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18682         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
18683         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18684         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
18685         return (int64_t)ret_conv;
18686 }
18687
18688 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18689         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
18690         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
18691         return ret_val;
18692 }
18693
18694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18695         if ((_res & 1) != 0) return;
18696         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18697         CHECK_ACCESS(_res_ptr);
18698         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
18699         FREE((void*)_res);
18700         CResult_PayeePubKeyErrorZ_free(_res_conv);
18701 }
18702
18703 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
18704         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18705         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
18706         return (int64_t)ret_conv;
18707 }
18708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18709         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
18710         int64_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
18711         return ret_val;
18712 }
18713
18714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18715         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
18716         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18717         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
18718         return (int64_t)ret_conv;
18719 }
18720
18721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18722         LDKCVec_PrivateRouteZ _res_constr;
18723         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18724         if (_res_constr.datalen > 0)
18725                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
18726         else
18727                 _res_constr.data = NULL;
18728         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18729         for (size_t o = 0; o < _res_constr.datalen; o++) {
18730                 int64_t _res_conv_14 = _res_vals[o];
18731                 LDKPrivateRoute _res_conv_14_conv;
18732                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
18733                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
18734                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
18735                 _res_constr.data[o] = _res_conv_14_conv;
18736         }
18737         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18738         CVec_PrivateRouteZ_free(_res_constr);
18739 }
18740
18741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18742         LDKPositiveTimestamp o_conv;
18743         o_conv.inner = (void*)(o & (~1));
18744         o_conv.is_owned = (o & 1) || (o == 0);
18745         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18746         o_conv = PositiveTimestamp_clone(&o_conv);
18747         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
18748         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
18749         return (int64_t)ret_conv;
18750 }
18751
18752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18753         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
18754         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
18755         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
18756         return (int64_t)ret_conv;
18757 }
18758
18759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18760         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
18761         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
18762         return ret_val;
18763 }
18764
18765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18766         if ((_res & 1) != 0) return;
18767         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18768         CHECK_ACCESS(_res_ptr);
18769         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
18770         FREE((void*)_res);
18771         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
18772 }
18773
18774 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
18775         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
18776         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
18777         return (int64_t)ret_conv;
18778 }
18779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18780         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
18781         int64_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
18782         return ret_val;
18783 }
18784
18785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18786         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
18787         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
18788         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
18789         return (int64_t)ret_conv;
18790 }
18791
18792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
18793         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
18794         *ret_conv = CResult_NoneSemanticErrorZ_ok();
18795         return (int64_t)ret_conv;
18796 }
18797
18798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18799         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
18800         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
18801         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
18802         return (int64_t)ret_conv;
18803 }
18804
18805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18806         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
18807         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
18808         return ret_val;
18809 }
18810
18811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18812         if ((_res & 1) != 0) return;
18813         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18814         CHECK_ACCESS(_res_ptr);
18815         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
18816         FREE((void*)_res);
18817         CResult_NoneSemanticErrorZ_free(_res_conv);
18818 }
18819
18820 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
18821         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
18822         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
18823         return (int64_t)ret_conv;
18824 }
18825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18826         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
18827         int64_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
18828         return ret_val;
18829 }
18830
18831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18832         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
18833         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
18834         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
18835         return (int64_t)ret_conv;
18836 }
18837
18838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18839         LDKInvoice o_conv;
18840         o_conv.inner = (void*)(o & (~1));
18841         o_conv.is_owned = (o & 1) || (o == 0);
18842         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18843         o_conv = Invoice_clone(&o_conv);
18844         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
18845         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
18846         return (int64_t)ret_conv;
18847 }
18848
18849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18850         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
18851         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
18852         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
18853         return (int64_t)ret_conv;
18854 }
18855
18856 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18857         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
18858         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
18859         return ret_val;
18860 }
18861
18862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18863         if ((_res & 1) != 0) return;
18864         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18865         CHECK_ACCESS(_res_ptr);
18866         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
18867         FREE((void*)_res);
18868         CResult_InvoiceSemanticErrorZ_free(_res_conv);
18869 }
18870
18871 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
18872         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
18873         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
18874         return (int64_t)ret_conv;
18875 }
18876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18877         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
18878         int64_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
18879         return ret_val;
18880 }
18881
18882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18883         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
18884         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
18885         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
18886         return (int64_t)ret_conv;
18887 }
18888
18889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18890         LDKDescription o_conv;
18891         o_conv.inner = (void*)(o & (~1));
18892         o_conv.is_owned = (o & 1) || (o == 0);
18893         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18894         o_conv = Description_clone(&o_conv);
18895         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
18896         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
18897         return (int64_t)ret_conv;
18898 }
18899
18900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18901         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
18902         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
18903         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
18904         return (int64_t)ret_conv;
18905 }
18906
18907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18908         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
18909         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
18910         return ret_val;
18911 }
18912
18913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18914         if ((_res & 1) != 0) return;
18915         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18916         CHECK_ACCESS(_res_ptr);
18917         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
18918         FREE((void*)_res);
18919         CResult_DescriptionCreationErrorZ_free(_res_conv);
18920 }
18921
18922 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
18923         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
18924         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
18925         return (int64_t)ret_conv;
18926 }
18927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18928         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
18929         int64_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
18930         return ret_val;
18931 }
18932
18933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18934         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
18935         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
18936         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
18937         return (int64_t)ret_conv;
18938 }
18939
18940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18941         LDKPrivateRoute o_conv;
18942         o_conv.inner = (void*)(o & (~1));
18943         o_conv.is_owned = (o & 1) || (o == 0);
18944         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18945         o_conv = PrivateRoute_clone(&o_conv);
18946         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
18947         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
18948         return (int64_t)ret_conv;
18949 }
18950
18951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18952         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
18953         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
18954         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
18955         return (int64_t)ret_conv;
18956 }
18957
18958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18959         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
18960         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
18961         return ret_val;
18962 }
18963
18964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18965         if ((_res & 1) != 0) return;
18966         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18967         CHECK_ACCESS(_res_ptr);
18968         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
18969         FREE((void*)_res);
18970         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
18971 }
18972
18973 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
18974         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
18975         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
18976         return (int64_t)ret_conv;
18977 }
18978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18979         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
18980         int64_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
18981         return ret_val;
18982 }
18983
18984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18985         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
18986         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
18987         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
18988         return (int64_t)ret_conv;
18989 }
18990
18991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
18992         LDKStr o_conv = java_to_owned_str(env, o);
18993         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
18994         *ret_conv = CResult_StringErrorZ_ok(o_conv);
18995         return (int64_t)ret_conv;
18996 }
18997
18998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18999         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19000         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19001         *ret_conv = CResult_StringErrorZ_err(e_conv);
19002         return (int64_t)ret_conv;
19003 }
19004
19005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19006         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
19007         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
19008         return ret_val;
19009 }
19010
19011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_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_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
19016         FREE((void*)_res);
19017         CResult_StringErrorZ_free(_res_conv);
19018 }
19019
19020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19021         LDKChannelMonitorUpdate o_conv;
19022         o_conv.inner = (void*)(o & (~1));
19023         o_conv.is_owned = (o & 1) || (o == 0);
19024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19025         o_conv = ChannelMonitorUpdate_clone(&o_conv);
19026         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19027         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
19028         return (int64_t)ret_conv;
19029 }
19030
19031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19032         LDKDecodeError e_conv;
19033         e_conv.inner = (void*)(e & (~1));
19034         e_conv.is_owned = (e & 1) || (e == 0);
19035         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19036         e_conv = DecodeError_clone(&e_conv);
19037         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19038         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
19039         return (int64_t)ret_conv;
19040 }
19041
19042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19043         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
19044         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
19045         return ret_val;
19046 }
19047
19048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19049         if ((_res & 1) != 0) return;
19050         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19051         CHECK_ACCESS(_res_ptr);
19052         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
19053         FREE((void*)_res);
19054         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
19055 }
19056
19057 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
19058         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19059         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
19060         return (int64_t)ret_conv;
19061 }
19062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19063         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
19064         int64_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
19065         return ret_val;
19066 }
19067
19068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19069         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
19070         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19071         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
19072         return (int64_t)ret_conv;
19073 }
19074
19075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19076         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19077         CHECK_ACCESS(o_ptr);
19078         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
19079         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
19080         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19081         *ret_copy = COption_MonitorEventZ_some(o_conv);
19082         int64_t ret_ref = (uintptr_t)ret_copy;
19083         return ret_ref;
19084 }
19085
19086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
19087         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19088         *ret_copy = COption_MonitorEventZ_none();
19089         int64_t ret_ref = (uintptr_t)ret_copy;
19090         return ret_ref;
19091 }
19092
19093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19094         if ((_res & 1) != 0) return;
19095         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19096         CHECK_ACCESS(_res_ptr);
19097         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
19098         FREE((void*)_res);
19099         COption_MonitorEventZ_free(_res_conv);
19100 }
19101
19102 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
19103         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19104         *ret_copy = COption_MonitorEventZ_clone(arg);
19105 int64_t ret_ref = (uintptr_t)ret_copy;
19106         return ret_ref;
19107 }
19108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19109         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
19110         int64_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
19111         return ret_val;
19112 }
19113
19114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19115         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
19116         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19117         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
19118         int64_t ret_ref = (uintptr_t)ret_copy;
19119         return ret_ref;
19120 }
19121
19122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19123         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19124         CHECK_ACCESS(o_ptr);
19125         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
19126         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
19127         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19128         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
19129         return (int64_t)ret_conv;
19130 }
19131
19132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19133         LDKDecodeError e_conv;
19134         e_conv.inner = (void*)(e & (~1));
19135         e_conv.is_owned = (e & 1) || (e == 0);
19136         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19137         e_conv = DecodeError_clone(&e_conv);
19138         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19139         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
19140         return (int64_t)ret_conv;
19141 }
19142
19143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19144         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
19145         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
19146         return ret_val;
19147 }
19148
19149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19150         if ((_res & 1) != 0) return;
19151         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19152         CHECK_ACCESS(_res_ptr);
19153         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
19154         FREE((void*)_res);
19155         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
19156 }
19157
19158 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
19159         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19160         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
19161         return (int64_t)ret_conv;
19162 }
19163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19164         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
19165         int64_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
19166         return ret_val;
19167 }
19168
19169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19170         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
19171         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19172         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
19173         return (int64_t)ret_conv;
19174 }
19175
19176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19177         LDKHTLCUpdate o_conv;
19178         o_conv.inner = (void*)(o & (~1));
19179         o_conv.is_owned = (o & 1) || (o == 0);
19180         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19181         o_conv = HTLCUpdate_clone(&o_conv);
19182         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19183         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
19184         return (int64_t)ret_conv;
19185 }
19186
19187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19188         LDKDecodeError e_conv;
19189         e_conv.inner = (void*)(e & (~1));
19190         e_conv.is_owned = (e & 1) || (e == 0);
19191         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19192         e_conv = DecodeError_clone(&e_conv);
19193         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19194         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
19195         return (int64_t)ret_conv;
19196 }
19197
19198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19199         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
19200         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
19201         return ret_val;
19202 }
19203
19204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19205         if ((_res & 1) != 0) return;
19206         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19207         CHECK_ACCESS(_res_ptr);
19208         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
19209         FREE((void*)_res);
19210         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
19211 }
19212
19213 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
19214         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19215         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
19216         return (int64_t)ret_conv;
19217 }
19218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19219         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
19220         int64_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
19221         return ret_val;
19222 }
19223
19224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19225         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
19226         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19227         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
19228         return (int64_t)ret_conv;
19229 }
19230
19231 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
19232         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19233         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
19234         return ((int64_t)ret_conv);
19235 }
19236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19237         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
19238         int64_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
19239         return ret_val;
19240 }
19241
19242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19243         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
19244         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19245         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
19246         return ((int64_t)ret_conv);
19247 }
19248
19249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
19250         LDKOutPoint a_conv;
19251         a_conv.inner = (void*)(a & (~1));
19252         a_conv.is_owned = (a & 1) || (a == 0);
19253         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19254         a_conv = OutPoint_clone(&a_conv);
19255         LDKCVec_u8Z b_ref;
19256         b_ref.datalen = (*env)->GetArrayLength(env, b);
19257         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19258         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19259         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19260         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
19261         return ((int64_t)ret_conv);
19262 }
19263
19264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19265         if ((_res & 1) != 0) return;
19266         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19267         CHECK_ACCESS(_res_ptr);
19268         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
19269         FREE((void*)_res);
19270         C2Tuple_OutPointScriptZ_free(_res_conv);
19271 }
19272
19273 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
19274         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19275         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
19276         return ((int64_t)ret_conv);
19277 }
19278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19279         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
19280         int64_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
19281         return ret_val;
19282 }
19283
19284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19285         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
19286         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19287         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
19288         return ((int64_t)ret_conv);
19289 }
19290
19291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
19292         LDKCVec_u8Z b_ref;
19293         b_ref.datalen = (*env)->GetArrayLength(env, b);
19294         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19295         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19296         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19297         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
19298         return ((int64_t)ret_conv);
19299 }
19300
19301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19302         if ((_res & 1) != 0) return;
19303         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19304         CHECK_ACCESS(_res_ptr);
19305         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
19306         FREE((void*)_res);
19307         C2Tuple_u32ScriptZ_free(_res_conv);
19308 }
19309
19310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19311         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
19312         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19313         if (_res_constr.datalen > 0)
19314                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19315         else
19316                 _res_constr.data = NULL;
19317         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19318         for (size_t v = 0; v < _res_constr.datalen; v++) {
19319                 int64_t _res_conv_21 = _res_vals[v];
19320                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
19321                 CHECK_ACCESS(_res_conv_21_ptr);
19322                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
19323                 FREE((void*)_res_conv_21);
19324                 _res_constr.data[v] = _res_conv_21_conv;
19325         }
19326         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19327         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
19328 }
19329
19330 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
19331         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19332         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
19333         return ((int64_t)ret_conv);
19334 }
19335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19336         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
19337         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
19338         return ret_val;
19339 }
19340
19341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19342         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
19343         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19344         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
19345         return ((int64_t)ret_conv);
19346 }
19347
19348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19349         LDKThirtyTwoBytes a_ref;
19350         CHECK((*env)->GetArrayLength(env, a) == 32);
19351         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19352         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
19353         b_constr.datalen = (*env)->GetArrayLength(env, b);
19354         if (b_constr.datalen > 0)
19355                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19356         else
19357                 b_constr.data = NULL;
19358         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19359         for (size_t v = 0; v < b_constr.datalen; v++) {
19360                 int64_t b_conv_21 = b_vals[v];
19361                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
19362                 CHECK_ACCESS(b_conv_21_ptr);
19363                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
19364                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
19365                 b_constr.data[v] = b_conv_21_conv;
19366         }
19367         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19368         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19369         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
19370         return ((int64_t)ret_conv);
19371 }
19372
19373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19374         if ((_res & 1) != 0) return;
19375         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19376         CHECK_ACCESS(_res_ptr);
19377         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
19378         FREE((void*)_res);
19379         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
19380 }
19381
19382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19383         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
19384         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19385         if (_res_constr.datalen > 0)
19386                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
19387         else
19388                 _res_constr.data = NULL;
19389         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19390         for (size_t o = 0; o < _res_constr.datalen; o++) {
19391                 int64_t _res_conv_40 = _res_vals[o];
19392                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
19393                 CHECK_ACCESS(_res_conv_40_ptr);
19394                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
19395                 FREE((void*)_res_conv_40);
19396                 _res_constr.data[o] = _res_conv_40_conv;
19397         }
19398         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19399         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
19400 }
19401
19402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19403         LDKCVec_EventZ _res_constr;
19404         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19405         if (_res_constr.datalen > 0)
19406                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
19407         else
19408                 _res_constr.data = NULL;
19409         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19410         for (size_t h = 0; h < _res_constr.datalen; h++) {
19411                 int64_t _res_conv_7 = _res_vals[h];
19412                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
19413                 CHECK_ACCESS(_res_conv_7_ptr);
19414                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
19415                 FREE((void*)_res_conv_7);
19416                 _res_constr.data[h] = _res_conv_7_conv;
19417         }
19418         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19419         CVec_EventZ_free(_res_constr);
19420 }
19421
19422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19423         LDKCVec_TransactionZ _res_constr;
19424         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19425         if (_res_constr.datalen > 0)
19426                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
19427         else
19428                 _res_constr.data = NULL;
19429         for (size_t i = 0; i < _res_constr.datalen; i++) {
19430                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19431                 LDKTransaction _res_conv_8_ref;
19432                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19433                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
19434                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19435                 _res_conv_8_ref.data_is_owned = true;
19436                 _res_constr.data[i] = _res_conv_8_ref;
19437         }
19438         CVec_TransactionZ_free(_res_constr);
19439 }
19440
19441 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
19442         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19443         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
19444         return ((int64_t)ret_conv);
19445 }
19446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19447         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
19448         int64_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
19449         return ret_val;
19450 }
19451
19452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19453         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
19454         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19455         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
19456         return ((int64_t)ret_conv);
19457 }
19458
19459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
19460         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
19461         CHECK_ACCESS(b_ptr);
19462         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
19463         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
19464         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19465         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
19466         return ((int64_t)ret_conv);
19467 }
19468
19469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19470         if ((_res & 1) != 0) return;
19471         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19472         CHECK_ACCESS(_res_ptr);
19473         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
19474         FREE((void*)_res);
19475         C2Tuple_u32TxOutZ_free(_res_conv);
19476 }
19477
19478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19479         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
19480         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19481         if (_res_constr.datalen > 0)
19482                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19483         else
19484                 _res_constr.data = NULL;
19485         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19486         for (size_t u = 0; u < _res_constr.datalen; u++) {
19487                 int64_t _res_conv_20 = _res_vals[u];
19488                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
19489                 CHECK_ACCESS(_res_conv_20_ptr);
19490                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
19491                 FREE((void*)_res_conv_20);
19492                 _res_constr.data[u] = _res_conv_20_conv;
19493         }
19494         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19495         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
19496 }
19497
19498 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
19499         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19500         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
19501         return ((int64_t)ret_conv);
19502 }
19503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19504         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
19505         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
19506         return ret_val;
19507 }
19508
19509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19510         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
19511         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19512         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
19513         return ((int64_t)ret_conv);
19514 }
19515
19516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19517         LDKThirtyTwoBytes a_ref;
19518         CHECK((*env)->GetArrayLength(env, a) == 32);
19519         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19520         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
19521         b_constr.datalen = (*env)->GetArrayLength(env, b);
19522         if (b_constr.datalen > 0)
19523                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19524         else
19525                 b_constr.data = NULL;
19526         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19527         for (size_t u = 0; u < b_constr.datalen; u++) {
19528                 int64_t b_conv_20 = b_vals[u];
19529                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
19530                 CHECK_ACCESS(b_conv_20_ptr);
19531                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
19532                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
19533                 b_constr.data[u] = b_conv_20_conv;
19534         }
19535         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19536         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19537         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
19538         return ((int64_t)ret_conv);
19539 }
19540
19541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19542         if ((_res & 1) != 0) return;
19543         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19544         CHECK_ACCESS(_res_ptr);
19545         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
19546         FREE((void*)_res);
19547         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
19548 }
19549
19550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19551         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
19552         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19553         if (_res_constr.datalen > 0)
19554                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
19555         else
19556                 _res_constr.data = NULL;
19557         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19558         for (size_t n = 0; n < _res_constr.datalen; n++) {
19559                 int64_t _res_conv_39 = _res_vals[n];
19560                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
19561                 CHECK_ACCESS(_res_conv_39_ptr);
19562                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
19563                 FREE((void*)_res_conv_39);
19564                 _res_constr.data[n] = _res_conv_39_conv;
19565         }
19566         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19567         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
19568 }
19569
19570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19571         LDKCVec_BalanceZ _res_constr;
19572         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19573         if (_res_constr.datalen > 0)
19574                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
19575         else
19576                 _res_constr.data = NULL;
19577         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19578         for (size_t j = 0; j < _res_constr.datalen; j++) {
19579                 int64_t _res_conv_9 = _res_vals[j];
19580                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
19581                 CHECK_ACCESS(_res_conv_9_ptr);
19582                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
19583                 FREE((void*)_res_conv_9);
19584                 _res_constr.data[j] = _res_conv_9_conv;
19585         }
19586         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19587         CVec_BalanceZ_free(_res_constr);
19588 }
19589
19590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19591         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19592         CHECK_ACCESS(o_ptr);
19593         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
19594         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
19595         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19596         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
19597         return (int64_t)ret_conv;
19598 }
19599
19600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19601         LDKDecodeError e_conv;
19602         e_conv.inner = (void*)(e & (~1));
19603         e_conv.is_owned = (e & 1) || (e == 0);
19604         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19605         e_conv = DecodeError_clone(&e_conv);
19606         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19607         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
19608         return (int64_t)ret_conv;
19609 }
19610
19611 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19612         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
19613         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
19614         return ret_val;
19615 }
19616
19617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19618         if ((_res & 1) != 0) return;
19619         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19620         CHECK_ACCESS(_res_ptr);
19621         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
19622         FREE((void*)_res);
19623         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
19624 }
19625
19626 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
19627         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19628         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
19629         return (int64_t)ret_conv;
19630 }
19631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19632         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
19633         int64_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
19634         return ret_val;
19635 }
19636
19637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19638         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
19639         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19640         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
19641         return (int64_t)ret_conv;
19642 }
19643
19644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
19645         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19646         *ret_conv = CResult_NoneLightningErrorZ_ok();
19647         return (int64_t)ret_conv;
19648 }
19649
19650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19651         LDKLightningError e_conv;
19652         e_conv.inner = (void*)(e & (~1));
19653         e_conv.is_owned = (e & 1) || (e == 0);
19654         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19655         e_conv = LightningError_clone(&e_conv);
19656         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19657         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
19658         return (int64_t)ret_conv;
19659 }
19660
19661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19662         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
19663         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
19664         return ret_val;
19665 }
19666
19667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19668         if ((_res & 1) != 0) return;
19669         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19670         CHECK_ACCESS(_res_ptr);
19671         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
19672         FREE((void*)_res);
19673         CResult_NoneLightningErrorZ_free(_res_conv);
19674 }
19675
19676 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
19677         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19678         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
19679         return (int64_t)ret_conv;
19680 }
19681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19682         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
19683         int64_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
19684         return ret_val;
19685 }
19686
19687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19688         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
19689         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19690         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
19691         return (int64_t)ret_conv;
19692 }
19693
19694 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
19695         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
19696         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
19697         return ((int64_t)ret_conv);
19698 }
19699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19700         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
19701         int64_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
19702         return ret_val;
19703 }
19704
19705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19706         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
19707         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
19708         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
19709         return ((int64_t)ret_conv);
19710 }
19711
19712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19713         LDKPublicKey a_ref;
19714         CHECK((*env)->GetArrayLength(env, a) == 33);
19715         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
19716         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
19717         CHECK_ACCESS(b_ptr);
19718         LDKType b_conv = *(LDKType*)(b_ptr);
19719         if (b_conv.free == LDKType_JCalls_free) {
19720                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19721                 LDKType_JCalls_cloned(&b_conv);
19722         }
19723         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
19724         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
19725         return ((int64_t)ret_conv);
19726 }
19727
19728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19729         if ((_res & 1) != 0) return;
19730         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19731         CHECK_ACCESS(_res_ptr);
19732         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
19733         FREE((void*)_res);
19734         C2Tuple_PublicKeyTypeZ_free(_res_conv);
19735 }
19736
19737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19738         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
19739         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19740         if (_res_constr.datalen > 0)
19741                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
19742         else
19743                 _res_constr.data = NULL;
19744         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19745         for (size_t z = 0; z < _res_constr.datalen; z++) {
19746                 int64_t _res_conv_25 = _res_vals[z];
19747                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
19748                 CHECK_ACCESS(_res_conv_25_ptr);
19749                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
19750                 FREE((void*)_res_conv_25);
19751                 _res_constr.data[z] = _res_conv_25_conv;
19752         }
19753         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19754         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
19755 }
19756
19757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
19758         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19759         *ret_conv = CResult_boolLightningErrorZ_ok(o);
19760         return (int64_t)ret_conv;
19761 }
19762
19763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19764         LDKLightningError e_conv;
19765         e_conv.inner = (void*)(e & (~1));
19766         e_conv.is_owned = (e & 1) || (e == 0);
19767         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19768         e_conv = LightningError_clone(&e_conv);
19769         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19770         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
19771         return (int64_t)ret_conv;
19772 }
19773
19774 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19775         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
19776         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
19777         return ret_val;
19778 }
19779
19780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19781         if ((_res & 1) != 0) return;
19782         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19783         CHECK_ACCESS(_res_ptr);
19784         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
19785         FREE((void*)_res);
19786         CResult_boolLightningErrorZ_free(_res_conv);
19787 }
19788
19789 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
19790         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19791         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
19792         return (int64_t)ret_conv;
19793 }
19794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19795         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
19796         int64_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
19797         return ret_val;
19798 }
19799
19800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19801         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
19802         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19803         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
19804         return (int64_t)ret_conv;
19805 }
19806
19807 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
19808         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19809         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
19810         return ((int64_t)ret_conv);
19811 }
19812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19813         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
19814         int64_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
19815         return ret_val;
19816 }
19817
19818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19819         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
19820         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19821         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
19822         return ((int64_t)ret_conv);
19823 }
19824
19825 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) {
19826         LDKChannelAnnouncement a_conv;
19827         a_conv.inner = (void*)(a & (~1));
19828         a_conv.is_owned = (a & 1) || (a == 0);
19829         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19830         a_conv = ChannelAnnouncement_clone(&a_conv);
19831         LDKChannelUpdate b_conv;
19832         b_conv.inner = (void*)(b & (~1));
19833         b_conv.is_owned = (b & 1) || (b == 0);
19834         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19835         b_conv = ChannelUpdate_clone(&b_conv);
19836         LDKChannelUpdate c_conv;
19837         c_conv.inner = (void*)(c & (~1));
19838         c_conv.is_owned = (c & 1) || (c == 0);
19839         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19840         c_conv = ChannelUpdate_clone(&c_conv);
19841         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19842         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
19843         return ((int64_t)ret_conv);
19844 }
19845
19846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19847         if ((_res & 1) != 0) return;
19848         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19849         CHECK_ACCESS(_res_ptr);
19850         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
19851         FREE((void*)_res);
19852         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
19853 }
19854
19855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19856         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
19857         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19858         if (_res_constr.datalen > 0)
19859                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
19860         else
19861                 _res_constr.data = NULL;
19862         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19863         for (size_t h = 0; h < _res_constr.datalen; h++) {
19864                 int64_t _res_conv_59 = _res_vals[h];
19865                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
19866                 CHECK_ACCESS(_res_conv_59_ptr);
19867                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
19868                 FREE((void*)_res_conv_59);
19869                 _res_constr.data[h] = _res_conv_59_conv;
19870         }
19871         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19872         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
19873 }
19874
19875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19876         LDKCVec_NodeAnnouncementZ _res_constr;
19877         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19878         if (_res_constr.datalen > 0)
19879                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
19880         else
19881                 _res_constr.data = NULL;
19882         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19883         for (size_t s = 0; s < _res_constr.datalen; s++) {
19884                 int64_t _res_conv_18 = _res_vals[s];
19885                 LDKNodeAnnouncement _res_conv_18_conv;
19886                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
19887                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
19888                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
19889                 _res_constr.data[s] = _res_conv_18_conv;
19890         }
19891         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19892         CVec_NodeAnnouncementZ_free(_res_constr);
19893 }
19894
19895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19896         LDKCVec_PublicKeyZ _res_constr;
19897         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19898         if (_res_constr.datalen > 0)
19899                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
19900         else
19901                 _res_constr.data = NULL;
19902         for (size_t i = 0; i < _res_constr.datalen; i++) {
19903                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19904                 LDKPublicKey _res_conv_8_ref;
19905                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
19906                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
19907                 _res_constr.data[i] = _res_conv_8_ref;
19908         }
19909         CVec_PublicKeyZ_free(_res_constr);
19910 }
19911
19912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19913         LDKCVec_u8Z o_ref;
19914         o_ref.datalen = (*env)->GetArrayLength(env, o);
19915         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
19916         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
19917         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
19918         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
19919         return (int64_t)ret_conv;
19920 }
19921
19922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19923         LDKPeerHandleError e_conv;
19924         e_conv.inner = (void*)(e & (~1));
19925         e_conv.is_owned = (e & 1) || (e == 0);
19926         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19927         e_conv = PeerHandleError_clone(&e_conv);
19928         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
19929         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
19930         return (int64_t)ret_conv;
19931 }
19932
19933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19934         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
19935         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
19936         return ret_val;
19937 }
19938
19939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19940         if ((_res & 1) != 0) return;
19941         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19942         CHECK_ACCESS(_res_ptr);
19943         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
19944         FREE((void*)_res);
19945         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
19946 }
19947
19948 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
19949         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
19950         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
19951         return (int64_t)ret_conv;
19952 }
19953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19954         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
19955         int64_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
19956         return ret_val;
19957 }
19958
19959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19960         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
19961         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
19962         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
19963         return (int64_t)ret_conv;
19964 }
19965
19966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
19967         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
19968         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
19969         return (int64_t)ret_conv;
19970 }
19971
19972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19973         LDKPeerHandleError e_conv;
19974         e_conv.inner = (void*)(e & (~1));
19975         e_conv.is_owned = (e & 1) || (e == 0);
19976         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19977         e_conv = PeerHandleError_clone(&e_conv);
19978         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
19979         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
19980         return (int64_t)ret_conv;
19981 }
19982
19983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19984         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
19985         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
19986         return ret_val;
19987 }
19988
19989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19990         if ((_res & 1) != 0) return;
19991         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19992         CHECK_ACCESS(_res_ptr);
19993         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
19994         FREE((void*)_res);
19995         CResult_NonePeerHandleErrorZ_free(_res_conv);
19996 }
19997
19998 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
19999         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20000         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
20001         return (int64_t)ret_conv;
20002 }
20003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20004         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
20005         int64_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
20006         return ret_val;
20007 }
20008
20009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20010         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
20011         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20012         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
20013         return (int64_t)ret_conv;
20014 }
20015
20016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
20017         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20018         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
20019         return (int64_t)ret_conv;
20020 }
20021
20022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20023         LDKPeerHandleError e_conv;
20024         e_conv.inner = (void*)(e & (~1));
20025         e_conv.is_owned = (e & 1) || (e == 0);
20026         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20027         e_conv = PeerHandleError_clone(&e_conv);
20028         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20029         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
20030         return (int64_t)ret_conv;
20031 }
20032
20033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20034         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
20035         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
20036         return ret_val;
20037 }
20038
20039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20040         if ((_res & 1) != 0) return;
20041         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20042         CHECK_ACCESS(_res_ptr);
20043         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
20044         FREE((void*)_res);
20045         CResult_boolPeerHandleErrorZ_free(_res_conv);
20046 }
20047
20048 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
20049         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20050         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
20051         return (int64_t)ret_conv;
20052 }
20053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20054         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
20055         int64_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
20056         return ret_val;
20057 }
20058
20059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20060         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
20061         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20062         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
20063         return (int64_t)ret_conv;
20064 }
20065
20066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20067         LDKNodeId o_conv;
20068         o_conv.inner = (void*)(o & (~1));
20069         o_conv.is_owned = (o & 1) || (o == 0);
20070         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20071         o_conv = NodeId_clone(&o_conv);
20072         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20073         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
20074         return (int64_t)ret_conv;
20075 }
20076
20077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20078         LDKDecodeError e_conv;
20079         e_conv.inner = (void*)(e & (~1));
20080         e_conv.is_owned = (e & 1) || (e == 0);
20081         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20082         e_conv = DecodeError_clone(&e_conv);
20083         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20084         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
20085         return (int64_t)ret_conv;
20086 }
20087
20088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20089         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
20090         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
20091         return ret_val;
20092 }
20093
20094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20095         if ((_res & 1) != 0) return;
20096         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20097         CHECK_ACCESS(_res_ptr);
20098         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
20099         FREE((void*)_res);
20100         CResult_NodeIdDecodeErrorZ_free(_res_conv);
20101 }
20102
20103 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
20104         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20105         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
20106         return (int64_t)ret_conv;
20107 }
20108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20109         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
20110         int64_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
20111         return ret_val;
20112 }
20113
20114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20115         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
20116         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20117         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
20118         return (int64_t)ret_conv;
20119 }
20120
20121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20122         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20123         CHECK_ACCESS(o_ptr);
20124         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
20125         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
20126         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20127         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
20128         return (int64_t)ret_conv;
20129 }
20130
20131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20132         LDKDecodeError e_conv;
20133         e_conv.inner = (void*)(e & (~1));
20134         e_conv.is_owned = (e & 1) || (e == 0);
20135         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20136         e_conv = DecodeError_clone(&e_conv);
20137         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20138         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
20139         return (int64_t)ret_conv;
20140 }
20141
20142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20143         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
20144         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
20145         return ret_val;
20146 }
20147
20148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20149         if ((_res & 1) != 0) return;
20150         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20151         CHECK_ACCESS(_res_ptr);
20152         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
20153         FREE((void*)_res);
20154         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
20155 }
20156
20157 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
20158         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20159         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
20160         return (int64_t)ret_conv;
20161 }
20162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20163         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
20164         int64_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
20165         return ret_val;
20166 }
20167
20168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20169         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
20170         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20171         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
20172         return (int64_t)ret_conv;
20173 }
20174
20175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20176         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20177         CHECK_ACCESS(o_ptr);
20178         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
20179         if (o_conv.free == LDKAccess_JCalls_free) {
20180                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20181                 LDKAccess_JCalls_cloned(&o_conv);
20182         }
20183         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20184         *ret_copy = COption_AccessZ_some(o_conv);
20185         int64_t ret_ref = (uintptr_t)ret_copy;
20186         return ret_ref;
20187 }
20188
20189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
20190         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20191         *ret_copy = COption_AccessZ_none();
20192         int64_t ret_ref = (uintptr_t)ret_copy;
20193         return ret_ref;
20194 }
20195
20196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20197         if ((_res & 1) != 0) return;
20198         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20199         CHECK_ACCESS(_res_ptr);
20200         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
20201         FREE((void*)_res);
20202         COption_AccessZ_free(_res_conv);
20203 }
20204
20205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20206         LDKChannelUpdateInfo o_conv;
20207         o_conv.inner = (void*)(o & (~1));
20208         o_conv.is_owned = (o & 1) || (o == 0);
20209         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20210         o_conv = ChannelUpdateInfo_clone(&o_conv);
20211         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20212         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
20213         return (int64_t)ret_conv;
20214 }
20215
20216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20217         LDKDecodeError e_conv;
20218         e_conv.inner = (void*)(e & (~1));
20219         e_conv.is_owned = (e & 1) || (e == 0);
20220         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20221         e_conv = DecodeError_clone(&e_conv);
20222         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20223         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
20224         return (int64_t)ret_conv;
20225 }
20226
20227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20228         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
20229         jboolean ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
20230         return ret_val;
20231 }
20232
20233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20234         if ((_res & 1) != 0) return;
20235         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20236         CHECK_ACCESS(_res_ptr);
20237         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
20238         FREE((void*)_res);
20239         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
20240 }
20241
20242 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
20243         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20244         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
20245         return (int64_t)ret_conv;
20246 }
20247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20248         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
20249         int64_t ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
20250         return ret_val;
20251 }
20252
20253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20254         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
20255         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20256         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
20257         return (int64_t)ret_conv;
20258 }
20259
20260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20261         LDKChannelInfo o_conv;
20262         o_conv.inner = (void*)(o & (~1));
20263         o_conv.is_owned = (o & 1) || (o == 0);
20264         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20265         o_conv = ChannelInfo_clone(&o_conv);
20266         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20267         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
20268         return (int64_t)ret_conv;
20269 }
20270
20271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20272         LDKDecodeError e_conv;
20273         e_conv.inner = (void*)(e & (~1));
20274         e_conv.is_owned = (e & 1) || (e == 0);
20275         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20276         e_conv = DecodeError_clone(&e_conv);
20277         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20278         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
20279         return (int64_t)ret_conv;
20280 }
20281
20282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20283         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
20284         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
20285         return ret_val;
20286 }
20287
20288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20289         if ((_res & 1) != 0) return;
20290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20291         CHECK_ACCESS(_res_ptr);
20292         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
20293         FREE((void*)_res);
20294         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
20295 }
20296
20297 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
20298         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20299         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
20300         return (int64_t)ret_conv;
20301 }
20302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20303         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
20304         int64_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
20305         return ret_val;
20306 }
20307
20308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20309         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
20310         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20311         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
20312         return (int64_t)ret_conv;
20313 }
20314
20315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20316         LDKRoutingFees o_conv;
20317         o_conv.inner = (void*)(o & (~1));
20318         o_conv.is_owned = (o & 1) || (o == 0);
20319         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20320         o_conv = RoutingFees_clone(&o_conv);
20321         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20322         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
20323         return (int64_t)ret_conv;
20324 }
20325
20326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20327         LDKDecodeError e_conv;
20328         e_conv.inner = (void*)(e & (~1));
20329         e_conv.is_owned = (e & 1) || (e == 0);
20330         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20331         e_conv = DecodeError_clone(&e_conv);
20332         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20333         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
20334         return (int64_t)ret_conv;
20335 }
20336
20337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20338         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
20339         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
20340         return ret_val;
20341 }
20342
20343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20344         if ((_res & 1) != 0) return;
20345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20346         CHECK_ACCESS(_res_ptr);
20347         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
20348         FREE((void*)_res);
20349         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
20350 }
20351
20352 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
20353         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20354         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
20355         return (int64_t)ret_conv;
20356 }
20357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20358         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
20359         int64_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
20360         return ret_val;
20361 }
20362
20363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20364         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
20365         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20366         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
20367         return (int64_t)ret_conv;
20368 }
20369
20370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20371         LDKNodeAnnouncementInfo o_conv;
20372         o_conv.inner = (void*)(o & (~1));
20373         o_conv.is_owned = (o & 1) || (o == 0);
20374         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20375         o_conv = NodeAnnouncementInfo_clone(&o_conv);
20376         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20377         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
20378         return (int64_t)ret_conv;
20379 }
20380
20381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20382         LDKDecodeError e_conv;
20383         e_conv.inner = (void*)(e & (~1));
20384         e_conv.is_owned = (e & 1) || (e == 0);
20385         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20386         e_conv = DecodeError_clone(&e_conv);
20387         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20388         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
20389         return (int64_t)ret_conv;
20390 }
20391
20392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20393         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
20394         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
20395         return ret_val;
20396 }
20397
20398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20399         if ((_res & 1) != 0) return;
20400         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20401         CHECK_ACCESS(_res_ptr);
20402         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
20403         FREE((void*)_res);
20404         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
20405 }
20406
20407 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
20408         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20409         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
20410         return (int64_t)ret_conv;
20411 }
20412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20413         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
20414         int64_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
20415         return ret_val;
20416 }
20417
20418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20419         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
20420         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20421         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
20422         return (int64_t)ret_conv;
20423 }
20424
20425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20426         LDKCVec_u64Z _res_constr;
20427         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20428         if (_res_constr.datalen > 0)
20429                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20430         else
20431                 _res_constr.data = NULL;
20432         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20433         for (size_t g = 0; g < _res_constr.datalen; g++) {
20434                 int64_t _res_conv_6 = _res_vals[g];
20435                 _res_constr.data[g] = _res_conv_6;
20436         }
20437         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20438         CVec_u64Z_free(_res_constr);
20439 }
20440
20441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20442         LDKNodeInfo o_conv;
20443         o_conv.inner = (void*)(o & (~1));
20444         o_conv.is_owned = (o & 1) || (o == 0);
20445         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20446         o_conv = NodeInfo_clone(&o_conv);
20447         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20448         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
20449         return (int64_t)ret_conv;
20450 }
20451
20452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20453         LDKDecodeError e_conv;
20454         e_conv.inner = (void*)(e & (~1));
20455         e_conv.is_owned = (e & 1) || (e == 0);
20456         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20457         e_conv = DecodeError_clone(&e_conv);
20458         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20459         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
20460         return (int64_t)ret_conv;
20461 }
20462
20463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20464         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
20465         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
20466         return ret_val;
20467 }
20468
20469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20470         if ((_res & 1) != 0) return;
20471         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20472         CHECK_ACCESS(_res_ptr);
20473         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
20474         FREE((void*)_res);
20475         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
20476 }
20477
20478 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
20479         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20480         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
20481         return (int64_t)ret_conv;
20482 }
20483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20484         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
20485         int64_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
20486         return ret_val;
20487 }
20488
20489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20490         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
20491         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20492         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
20493         return (int64_t)ret_conv;
20494 }
20495
20496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20497         LDKNetworkGraph o_conv;
20498         o_conv.inner = (void*)(o & (~1));
20499         o_conv.is_owned = (o & 1) || (o == 0);
20500         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20501         o_conv = NetworkGraph_clone(&o_conv);
20502         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20503         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
20504         return (int64_t)ret_conv;
20505 }
20506
20507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20508         LDKDecodeError e_conv;
20509         e_conv.inner = (void*)(e & (~1));
20510         e_conv.is_owned = (e & 1) || (e == 0);
20511         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20512         e_conv = DecodeError_clone(&e_conv);
20513         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20514         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
20515         return (int64_t)ret_conv;
20516 }
20517
20518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20519         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
20520         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
20521         return ret_val;
20522 }
20523
20524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20525         if ((_res & 1) != 0) return;
20526         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20527         CHECK_ACCESS(_res_ptr);
20528         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
20529         FREE((void*)_res);
20530         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
20531 }
20532
20533 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
20534         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20535         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
20536         return (int64_t)ret_conv;
20537 }
20538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20539         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
20540         int64_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
20541         return ret_val;
20542 }
20543
20544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20545         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
20546         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20547         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
20548         return (int64_t)ret_conv;
20549 }
20550
20551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
20552         LDKCVec_NetAddressZ o_constr;
20553         o_constr.datalen = (*env)->GetArrayLength(env, o);
20554         if (o_constr.datalen > 0)
20555                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20556         else
20557                 o_constr.data = NULL;
20558         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20559         for (size_t m = 0; m < o_constr.datalen; m++) {
20560                 int64_t o_conv_12 = o_vals[m];
20561                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
20562                 CHECK_ACCESS(o_conv_12_ptr);
20563                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
20564                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
20565                 o_constr.data[m] = o_conv_12_conv;
20566         }
20567         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20568         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20569         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
20570         int64_t ret_ref = (uintptr_t)ret_copy;
20571         return ret_ref;
20572 }
20573
20574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
20575         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20576         *ret_copy = COption_CVec_NetAddressZZ_none();
20577         int64_t ret_ref = (uintptr_t)ret_copy;
20578         return ret_ref;
20579 }
20580
20581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20582         if ((_res & 1) != 0) return;
20583         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20584         CHECK_ACCESS(_res_ptr);
20585         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
20586         FREE((void*)_res);
20587         COption_CVec_NetAddressZZ_free(_res_conv);
20588 }
20589
20590 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
20591         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20592         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
20593 int64_t ret_ref = (uintptr_t)ret_copy;
20594         return ret_ref;
20595 }
20596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20597         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
20598         int64_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
20599         return ret_val;
20600 }
20601
20602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20603         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
20604         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20605         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
20606         int64_t ret_ref = (uintptr_t)ret_copy;
20607         return ret_ref;
20608 }
20609
20610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20611         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20612         CHECK_ACCESS(o_ptr);
20613         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
20614         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
20615         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20616         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
20617         return (int64_t)ret_conv;
20618 }
20619
20620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20621         LDKDecodeError e_conv;
20622         e_conv.inner = (void*)(e & (~1));
20623         e_conv.is_owned = (e & 1) || (e == 0);
20624         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20625         e_conv = DecodeError_clone(&e_conv);
20626         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20627         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
20628         return (int64_t)ret_conv;
20629 }
20630
20631 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20632         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
20633         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
20634         return ret_val;
20635 }
20636
20637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20638         if ((_res & 1) != 0) return;
20639         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20640         CHECK_ACCESS(_res_ptr);
20641         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
20642         FREE((void*)_res);
20643         CResult_NetAddressDecodeErrorZ_free(_res_conv);
20644 }
20645
20646 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
20647         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20648         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
20649         return (int64_t)ret_conv;
20650 }
20651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20652         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
20653         int64_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
20654         return ret_val;
20655 }
20656
20657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20658         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
20659         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20660         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
20661         return (int64_t)ret_conv;
20662 }
20663
20664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20665         LDKCVec_UpdateAddHTLCZ _res_constr;
20666         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20667         if (_res_constr.datalen > 0)
20668                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20669         else
20670                 _res_constr.data = NULL;
20671         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20672         for (size_t p = 0; p < _res_constr.datalen; p++) {
20673                 int64_t _res_conv_15 = _res_vals[p];
20674                 LDKUpdateAddHTLC _res_conv_15_conv;
20675                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
20676                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
20677                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
20678                 _res_constr.data[p] = _res_conv_15_conv;
20679         }
20680         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20681         CVec_UpdateAddHTLCZ_free(_res_constr);
20682 }
20683
20684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20685         LDKCVec_UpdateFulfillHTLCZ _res_constr;
20686         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20687         if (_res_constr.datalen > 0)
20688                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20689         else
20690                 _res_constr.data = NULL;
20691         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20692         for (size_t t = 0; t < _res_constr.datalen; t++) {
20693                 int64_t _res_conv_19 = _res_vals[t];
20694                 LDKUpdateFulfillHTLC _res_conv_19_conv;
20695                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
20696                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
20697                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
20698                 _res_constr.data[t] = _res_conv_19_conv;
20699         }
20700         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20701         CVec_UpdateFulfillHTLCZ_free(_res_constr);
20702 }
20703
20704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20705         LDKCVec_UpdateFailHTLCZ _res_constr;
20706         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20707         if (_res_constr.datalen > 0)
20708                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20709         else
20710                 _res_constr.data = NULL;
20711         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20712         for (size_t q = 0; q < _res_constr.datalen; q++) {
20713                 int64_t _res_conv_16 = _res_vals[q];
20714                 LDKUpdateFailHTLC _res_conv_16_conv;
20715                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
20716                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
20717                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
20718                 _res_constr.data[q] = _res_conv_16_conv;
20719         }
20720         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20721         CVec_UpdateFailHTLCZ_free(_res_constr);
20722 }
20723
20724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20725         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
20726         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20727         if (_res_constr.datalen > 0)
20728                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20729         else
20730                 _res_constr.data = NULL;
20731         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20732         for (size_t z = 0; z < _res_constr.datalen; z++) {
20733                 int64_t _res_conv_25 = _res_vals[z];
20734                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
20735                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
20736                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
20737                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
20738                 _res_constr.data[z] = _res_conv_25_conv;
20739         }
20740         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20741         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
20742 }
20743
20744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20745         LDKAcceptChannel o_conv;
20746         o_conv.inner = (void*)(o & (~1));
20747         o_conv.is_owned = (o & 1) || (o == 0);
20748         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20749         o_conv = AcceptChannel_clone(&o_conv);
20750         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20751         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
20752         return (int64_t)ret_conv;
20753 }
20754
20755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20756         LDKDecodeError e_conv;
20757         e_conv.inner = (void*)(e & (~1));
20758         e_conv.is_owned = (e & 1) || (e == 0);
20759         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20760         e_conv = DecodeError_clone(&e_conv);
20761         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20762         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
20763         return (int64_t)ret_conv;
20764 }
20765
20766 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20767         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
20768         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
20769         return ret_val;
20770 }
20771
20772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20773         if ((_res & 1) != 0) return;
20774         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20775         CHECK_ACCESS(_res_ptr);
20776         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
20777         FREE((void*)_res);
20778         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
20779 }
20780
20781 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
20782         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20783         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
20784         return (int64_t)ret_conv;
20785 }
20786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20787         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
20788         int64_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
20789         return ret_val;
20790 }
20791
20792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20793         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
20794         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20795         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
20796         return (int64_t)ret_conv;
20797 }
20798
20799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20800         LDKAnnouncementSignatures o_conv;
20801         o_conv.inner = (void*)(o & (~1));
20802         o_conv.is_owned = (o & 1) || (o == 0);
20803         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20804         o_conv = AnnouncementSignatures_clone(&o_conv);
20805         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20806         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
20807         return (int64_t)ret_conv;
20808 }
20809
20810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20811         LDKDecodeError e_conv;
20812         e_conv.inner = (void*)(e & (~1));
20813         e_conv.is_owned = (e & 1) || (e == 0);
20814         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20815         e_conv = DecodeError_clone(&e_conv);
20816         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20817         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
20818         return (int64_t)ret_conv;
20819 }
20820
20821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20822         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
20823         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
20824         return ret_val;
20825 }
20826
20827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20828         if ((_res & 1) != 0) return;
20829         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20830         CHECK_ACCESS(_res_ptr);
20831         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
20832         FREE((void*)_res);
20833         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
20834 }
20835
20836 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
20837         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20838         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
20839         return (int64_t)ret_conv;
20840 }
20841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20842         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
20843         int64_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
20844         return ret_val;
20845 }
20846
20847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20848         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
20849         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20850         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
20851         return (int64_t)ret_conv;
20852 }
20853
20854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20855         LDKChannelReestablish o_conv;
20856         o_conv.inner = (void*)(o & (~1));
20857         o_conv.is_owned = (o & 1) || (o == 0);
20858         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20859         o_conv = ChannelReestablish_clone(&o_conv);
20860         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20861         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
20862         return (int64_t)ret_conv;
20863 }
20864
20865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20866         LDKDecodeError e_conv;
20867         e_conv.inner = (void*)(e & (~1));
20868         e_conv.is_owned = (e & 1) || (e == 0);
20869         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20870         e_conv = DecodeError_clone(&e_conv);
20871         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20872         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
20873         return (int64_t)ret_conv;
20874 }
20875
20876 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20877         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
20878         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
20879         return ret_val;
20880 }
20881
20882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20883         if ((_res & 1) != 0) return;
20884         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20885         CHECK_ACCESS(_res_ptr);
20886         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
20887         FREE((void*)_res);
20888         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
20889 }
20890
20891 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
20892         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20893         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
20894         return (int64_t)ret_conv;
20895 }
20896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20897         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
20898         int64_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
20899         return ret_val;
20900 }
20901
20902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20903         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
20904         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20905         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
20906         return (int64_t)ret_conv;
20907 }
20908
20909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20910         LDKClosingSigned o_conv;
20911         o_conv.inner = (void*)(o & (~1));
20912         o_conv.is_owned = (o & 1) || (o == 0);
20913         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20914         o_conv = ClosingSigned_clone(&o_conv);
20915         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20916         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
20917         return (int64_t)ret_conv;
20918 }
20919
20920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20921         LDKDecodeError e_conv;
20922         e_conv.inner = (void*)(e & (~1));
20923         e_conv.is_owned = (e & 1) || (e == 0);
20924         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20925         e_conv = DecodeError_clone(&e_conv);
20926         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20927         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
20928         return (int64_t)ret_conv;
20929 }
20930
20931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20932         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
20933         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
20934         return ret_val;
20935 }
20936
20937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20938         if ((_res & 1) != 0) return;
20939         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20940         CHECK_ACCESS(_res_ptr);
20941         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
20942         FREE((void*)_res);
20943         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
20944 }
20945
20946 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
20947         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20948         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
20949         return (int64_t)ret_conv;
20950 }
20951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20952         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
20953         int64_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
20954         return ret_val;
20955 }
20956
20957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20958         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
20959         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20960         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
20961         return (int64_t)ret_conv;
20962 }
20963
20964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20965         LDKClosingSignedFeeRange o_conv;
20966         o_conv.inner = (void*)(o & (~1));
20967         o_conv.is_owned = (o & 1) || (o == 0);
20968         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20969         o_conv = ClosingSignedFeeRange_clone(&o_conv);
20970         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
20971         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
20972         return (int64_t)ret_conv;
20973 }
20974
20975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20976         LDKDecodeError e_conv;
20977         e_conv.inner = (void*)(e & (~1));
20978         e_conv.is_owned = (e & 1) || (e == 0);
20979         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20980         e_conv = DecodeError_clone(&e_conv);
20981         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
20982         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
20983         return (int64_t)ret_conv;
20984 }
20985
20986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20987         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
20988         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
20989         return ret_val;
20990 }
20991
20992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20993         if ((_res & 1) != 0) return;
20994         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20995         CHECK_ACCESS(_res_ptr);
20996         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
20997         FREE((void*)_res);
20998         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
20999 }
21000
21001 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
21002         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21003         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
21004         return (int64_t)ret_conv;
21005 }
21006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21007         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
21008         int64_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
21009         return ret_val;
21010 }
21011
21012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21013         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
21014         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21015         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
21016         return (int64_t)ret_conv;
21017 }
21018
21019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21020         LDKCommitmentSigned o_conv;
21021         o_conv.inner = (void*)(o & (~1));
21022         o_conv.is_owned = (o & 1) || (o == 0);
21023         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21024         o_conv = CommitmentSigned_clone(&o_conv);
21025         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21026         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
21027         return (int64_t)ret_conv;
21028 }
21029
21030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21031         LDKDecodeError e_conv;
21032         e_conv.inner = (void*)(e & (~1));
21033         e_conv.is_owned = (e & 1) || (e == 0);
21034         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21035         e_conv = DecodeError_clone(&e_conv);
21036         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21037         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
21038         return (int64_t)ret_conv;
21039 }
21040
21041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21042         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
21043         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
21044         return ret_val;
21045 }
21046
21047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21048         if ((_res & 1) != 0) return;
21049         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21050         CHECK_ACCESS(_res_ptr);
21051         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
21052         FREE((void*)_res);
21053         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
21054 }
21055
21056 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
21057         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21058         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
21059         return (int64_t)ret_conv;
21060 }
21061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21062         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
21063         int64_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
21064         return ret_val;
21065 }
21066
21067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21068         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
21069         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21070         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
21071         return (int64_t)ret_conv;
21072 }
21073
21074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21075         LDKFundingCreated o_conv;
21076         o_conv.inner = (void*)(o & (~1));
21077         o_conv.is_owned = (o & 1) || (o == 0);
21078         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21079         o_conv = FundingCreated_clone(&o_conv);
21080         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21081         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
21082         return (int64_t)ret_conv;
21083 }
21084
21085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21086         LDKDecodeError e_conv;
21087         e_conv.inner = (void*)(e & (~1));
21088         e_conv.is_owned = (e & 1) || (e == 0);
21089         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21090         e_conv = DecodeError_clone(&e_conv);
21091         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21092         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
21093         return (int64_t)ret_conv;
21094 }
21095
21096 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21097         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
21098         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
21099         return ret_val;
21100 }
21101
21102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21103         if ((_res & 1) != 0) return;
21104         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21105         CHECK_ACCESS(_res_ptr);
21106         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
21107         FREE((void*)_res);
21108         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
21109 }
21110
21111 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
21112         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21113         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
21114         return (int64_t)ret_conv;
21115 }
21116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21117         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
21118         int64_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
21119         return ret_val;
21120 }
21121
21122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21123         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
21124         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21125         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
21126         return (int64_t)ret_conv;
21127 }
21128
21129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21130         LDKFundingSigned o_conv;
21131         o_conv.inner = (void*)(o & (~1));
21132         o_conv.is_owned = (o & 1) || (o == 0);
21133         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21134         o_conv = FundingSigned_clone(&o_conv);
21135         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21136         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
21137         return (int64_t)ret_conv;
21138 }
21139
21140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21141         LDKDecodeError e_conv;
21142         e_conv.inner = (void*)(e & (~1));
21143         e_conv.is_owned = (e & 1) || (e == 0);
21144         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21145         e_conv = DecodeError_clone(&e_conv);
21146         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21147         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
21148         return (int64_t)ret_conv;
21149 }
21150
21151 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21152         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
21153         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
21154         return ret_val;
21155 }
21156
21157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21158         if ((_res & 1) != 0) return;
21159         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21160         CHECK_ACCESS(_res_ptr);
21161         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
21162         FREE((void*)_res);
21163         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
21164 }
21165
21166 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
21167         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21168         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
21169         return (int64_t)ret_conv;
21170 }
21171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21172         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
21173         int64_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
21174         return ret_val;
21175 }
21176
21177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21178         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
21179         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21180         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
21181         return (int64_t)ret_conv;
21182 }
21183
21184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21185         LDKFundingLocked o_conv;
21186         o_conv.inner = (void*)(o & (~1));
21187         o_conv.is_owned = (o & 1) || (o == 0);
21188         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21189         o_conv = FundingLocked_clone(&o_conv);
21190         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21191         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
21192         return (int64_t)ret_conv;
21193 }
21194
21195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21196         LDKDecodeError e_conv;
21197         e_conv.inner = (void*)(e & (~1));
21198         e_conv.is_owned = (e & 1) || (e == 0);
21199         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21200         e_conv = DecodeError_clone(&e_conv);
21201         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21202         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
21203         return (int64_t)ret_conv;
21204 }
21205
21206 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21207         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
21208         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
21209         return ret_val;
21210 }
21211
21212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21213         if ((_res & 1) != 0) return;
21214         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21215         CHECK_ACCESS(_res_ptr);
21216         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
21217         FREE((void*)_res);
21218         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
21219 }
21220
21221 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
21222         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21223         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
21224         return (int64_t)ret_conv;
21225 }
21226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21227         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
21228         int64_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
21229         return ret_val;
21230 }
21231
21232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21233         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
21234         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21235         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
21236         return (int64_t)ret_conv;
21237 }
21238
21239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21240         LDKInit o_conv;
21241         o_conv.inner = (void*)(o & (~1));
21242         o_conv.is_owned = (o & 1) || (o == 0);
21243         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21244         o_conv = Init_clone(&o_conv);
21245         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21246         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
21247         return (int64_t)ret_conv;
21248 }
21249
21250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21251         LDKDecodeError e_conv;
21252         e_conv.inner = (void*)(e & (~1));
21253         e_conv.is_owned = (e & 1) || (e == 0);
21254         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21255         e_conv = DecodeError_clone(&e_conv);
21256         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21257         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
21258         return (int64_t)ret_conv;
21259 }
21260
21261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21262         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
21263         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
21264         return ret_val;
21265 }
21266
21267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21268         if ((_res & 1) != 0) return;
21269         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21270         CHECK_ACCESS(_res_ptr);
21271         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
21272         FREE((void*)_res);
21273         CResult_InitDecodeErrorZ_free(_res_conv);
21274 }
21275
21276 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
21277         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21278         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
21279         return (int64_t)ret_conv;
21280 }
21281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21282         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
21283         int64_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
21284         return ret_val;
21285 }
21286
21287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21288         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
21289         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21290         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
21291         return (int64_t)ret_conv;
21292 }
21293
21294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21295         LDKOpenChannel o_conv;
21296         o_conv.inner = (void*)(o & (~1));
21297         o_conv.is_owned = (o & 1) || (o == 0);
21298         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21299         o_conv = OpenChannel_clone(&o_conv);
21300         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21301         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
21302         return (int64_t)ret_conv;
21303 }
21304
21305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21306         LDKDecodeError e_conv;
21307         e_conv.inner = (void*)(e & (~1));
21308         e_conv.is_owned = (e & 1) || (e == 0);
21309         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21310         e_conv = DecodeError_clone(&e_conv);
21311         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21312         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
21313         return (int64_t)ret_conv;
21314 }
21315
21316 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21317         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
21318         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
21319         return ret_val;
21320 }
21321
21322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21323         if ((_res & 1) != 0) return;
21324         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21325         CHECK_ACCESS(_res_ptr);
21326         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
21327         FREE((void*)_res);
21328         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
21329 }
21330
21331 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
21332         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21333         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
21334         return (int64_t)ret_conv;
21335 }
21336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21337         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
21338         int64_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
21339         return ret_val;
21340 }
21341
21342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21343         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
21344         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21345         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
21346         return (int64_t)ret_conv;
21347 }
21348
21349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21350         LDKRevokeAndACK o_conv;
21351         o_conv.inner = (void*)(o & (~1));
21352         o_conv.is_owned = (o & 1) || (o == 0);
21353         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21354         o_conv = RevokeAndACK_clone(&o_conv);
21355         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21356         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
21357         return (int64_t)ret_conv;
21358 }
21359
21360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21361         LDKDecodeError e_conv;
21362         e_conv.inner = (void*)(e & (~1));
21363         e_conv.is_owned = (e & 1) || (e == 0);
21364         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21365         e_conv = DecodeError_clone(&e_conv);
21366         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21367         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
21368         return (int64_t)ret_conv;
21369 }
21370
21371 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21372         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
21373         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
21374         return ret_val;
21375 }
21376
21377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21378         if ((_res & 1) != 0) return;
21379         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21380         CHECK_ACCESS(_res_ptr);
21381         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
21382         FREE((void*)_res);
21383         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
21384 }
21385
21386 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
21387         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21388         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
21389         return (int64_t)ret_conv;
21390 }
21391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21392         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
21393         int64_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
21394         return ret_val;
21395 }
21396
21397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21398         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
21399         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21400         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
21401         return (int64_t)ret_conv;
21402 }
21403
21404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21405         LDKShutdown o_conv;
21406         o_conv.inner = (void*)(o & (~1));
21407         o_conv.is_owned = (o & 1) || (o == 0);
21408         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21409         o_conv = Shutdown_clone(&o_conv);
21410         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21411         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
21412         return (int64_t)ret_conv;
21413 }
21414
21415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21416         LDKDecodeError e_conv;
21417         e_conv.inner = (void*)(e & (~1));
21418         e_conv.is_owned = (e & 1) || (e == 0);
21419         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21420         e_conv = DecodeError_clone(&e_conv);
21421         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21422         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
21423         return (int64_t)ret_conv;
21424 }
21425
21426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21427         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
21428         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
21429         return ret_val;
21430 }
21431
21432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21433         if ((_res & 1) != 0) return;
21434         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21435         CHECK_ACCESS(_res_ptr);
21436         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
21437         FREE((void*)_res);
21438         CResult_ShutdownDecodeErrorZ_free(_res_conv);
21439 }
21440
21441 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
21442         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21443         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
21444         return (int64_t)ret_conv;
21445 }
21446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21447         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
21448         int64_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
21449         return ret_val;
21450 }
21451
21452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21453         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
21454         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21455         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
21456         return (int64_t)ret_conv;
21457 }
21458
21459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21460         LDKUpdateFailHTLC o_conv;
21461         o_conv.inner = (void*)(o & (~1));
21462         o_conv.is_owned = (o & 1) || (o == 0);
21463         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21464         o_conv = UpdateFailHTLC_clone(&o_conv);
21465         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21466         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
21467         return (int64_t)ret_conv;
21468 }
21469
21470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21471         LDKDecodeError e_conv;
21472         e_conv.inner = (void*)(e & (~1));
21473         e_conv.is_owned = (e & 1) || (e == 0);
21474         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21475         e_conv = DecodeError_clone(&e_conv);
21476         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21477         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
21478         return (int64_t)ret_conv;
21479 }
21480
21481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21482         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
21483         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
21484         return ret_val;
21485 }
21486
21487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21488         if ((_res & 1) != 0) return;
21489         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21490         CHECK_ACCESS(_res_ptr);
21491         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
21492         FREE((void*)_res);
21493         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
21494 }
21495
21496 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
21497         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21498         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
21499         return (int64_t)ret_conv;
21500 }
21501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21502         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
21503         int64_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
21504         return ret_val;
21505 }
21506
21507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21508         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
21509         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21510         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
21511         return (int64_t)ret_conv;
21512 }
21513
21514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21515         LDKUpdateFailMalformedHTLC o_conv;
21516         o_conv.inner = (void*)(o & (~1));
21517         o_conv.is_owned = (o & 1) || (o == 0);
21518         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21519         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
21520         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21521         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
21522         return (int64_t)ret_conv;
21523 }
21524
21525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21526         LDKDecodeError e_conv;
21527         e_conv.inner = (void*)(e & (~1));
21528         e_conv.is_owned = (e & 1) || (e == 0);
21529         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21530         e_conv = DecodeError_clone(&e_conv);
21531         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21532         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
21533         return (int64_t)ret_conv;
21534 }
21535
21536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21537         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
21538         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
21539         return ret_val;
21540 }
21541
21542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21543         if ((_res & 1) != 0) return;
21544         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21545         CHECK_ACCESS(_res_ptr);
21546         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
21547         FREE((void*)_res);
21548         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
21549 }
21550
21551 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
21552         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21553         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
21554         return (int64_t)ret_conv;
21555 }
21556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21557         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
21558         int64_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
21559         return ret_val;
21560 }
21561
21562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21563         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
21564         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21565         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
21566         return (int64_t)ret_conv;
21567 }
21568
21569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21570         LDKUpdateFee o_conv;
21571         o_conv.inner = (void*)(o & (~1));
21572         o_conv.is_owned = (o & 1) || (o == 0);
21573         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21574         o_conv = UpdateFee_clone(&o_conv);
21575         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21576         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
21577         return (int64_t)ret_conv;
21578 }
21579
21580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21581         LDKDecodeError e_conv;
21582         e_conv.inner = (void*)(e & (~1));
21583         e_conv.is_owned = (e & 1) || (e == 0);
21584         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21585         e_conv = DecodeError_clone(&e_conv);
21586         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21587         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
21588         return (int64_t)ret_conv;
21589 }
21590
21591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21592         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
21593         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
21594         return ret_val;
21595 }
21596
21597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21598         if ((_res & 1) != 0) return;
21599         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21600         CHECK_ACCESS(_res_ptr);
21601         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
21602         FREE((void*)_res);
21603         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
21604 }
21605
21606 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
21607         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21608         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
21609         return (int64_t)ret_conv;
21610 }
21611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21612         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
21613         int64_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
21614         return ret_val;
21615 }
21616
21617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21618         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
21619         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21620         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
21621         return (int64_t)ret_conv;
21622 }
21623
21624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21625         LDKUpdateFulfillHTLC o_conv;
21626         o_conv.inner = (void*)(o & (~1));
21627         o_conv.is_owned = (o & 1) || (o == 0);
21628         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21629         o_conv = UpdateFulfillHTLC_clone(&o_conv);
21630         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21631         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
21632         return (int64_t)ret_conv;
21633 }
21634
21635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21636         LDKDecodeError e_conv;
21637         e_conv.inner = (void*)(e & (~1));
21638         e_conv.is_owned = (e & 1) || (e == 0);
21639         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21640         e_conv = DecodeError_clone(&e_conv);
21641         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21642         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
21643         return (int64_t)ret_conv;
21644 }
21645
21646 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21647         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
21648         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
21649         return ret_val;
21650 }
21651
21652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21653         if ((_res & 1) != 0) return;
21654         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21655         CHECK_ACCESS(_res_ptr);
21656         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
21657         FREE((void*)_res);
21658         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
21659 }
21660
21661 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
21662         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21663         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
21664         return (int64_t)ret_conv;
21665 }
21666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21667         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
21668         int64_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
21669         return ret_val;
21670 }
21671
21672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21673         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
21674         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21675         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
21676         return (int64_t)ret_conv;
21677 }
21678
21679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21680         LDKUpdateAddHTLC o_conv;
21681         o_conv.inner = (void*)(o & (~1));
21682         o_conv.is_owned = (o & 1) || (o == 0);
21683         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21684         o_conv = UpdateAddHTLC_clone(&o_conv);
21685         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21686         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
21687         return (int64_t)ret_conv;
21688 }
21689
21690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21691         LDKDecodeError e_conv;
21692         e_conv.inner = (void*)(e & (~1));
21693         e_conv.is_owned = (e & 1) || (e == 0);
21694         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21695         e_conv = DecodeError_clone(&e_conv);
21696         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21697         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
21698         return (int64_t)ret_conv;
21699 }
21700
21701 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21702         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
21703         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
21704         return ret_val;
21705 }
21706
21707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21708         if ((_res & 1) != 0) return;
21709         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21710         CHECK_ACCESS(_res_ptr);
21711         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
21712         FREE((void*)_res);
21713         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
21714 }
21715
21716 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
21717         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21718         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
21719         return (int64_t)ret_conv;
21720 }
21721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21722         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
21723         int64_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
21724         return ret_val;
21725 }
21726
21727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21728         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
21729         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21730         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
21731         return (int64_t)ret_conv;
21732 }
21733
21734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21735         LDKPing o_conv;
21736         o_conv.inner = (void*)(o & (~1));
21737         o_conv.is_owned = (o & 1) || (o == 0);
21738         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21739         o_conv = Ping_clone(&o_conv);
21740         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21741         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
21742         return (int64_t)ret_conv;
21743 }
21744
21745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21746         LDKDecodeError e_conv;
21747         e_conv.inner = (void*)(e & (~1));
21748         e_conv.is_owned = (e & 1) || (e == 0);
21749         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21750         e_conv = DecodeError_clone(&e_conv);
21751         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21752         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
21753         return (int64_t)ret_conv;
21754 }
21755
21756 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21757         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
21758         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
21759         return ret_val;
21760 }
21761
21762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21763         if ((_res & 1) != 0) return;
21764         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21765         CHECK_ACCESS(_res_ptr);
21766         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
21767         FREE((void*)_res);
21768         CResult_PingDecodeErrorZ_free(_res_conv);
21769 }
21770
21771 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
21772         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21773         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
21774         return (int64_t)ret_conv;
21775 }
21776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21777         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
21778         int64_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
21779         return ret_val;
21780 }
21781
21782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21783         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
21784         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21785         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
21786         return (int64_t)ret_conv;
21787 }
21788
21789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21790         LDKPong o_conv;
21791         o_conv.inner = (void*)(o & (~1));
21792         o_conv.is_owned = (o & 1) || (o == 0);
21793         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21794         o_conv = Pong_clone(&o_conv);
21795         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21796         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
21797         return (int64_t)ret_conv;
21798 }
21799
21800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21801         LDKDecodeError e_conv;
21802         e_conv.inner = (void*)(e & (~1));
21803         e_conv.is_owned = (e & 1) || (e == 0);
21804         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21805         e_conv = DecodeError_clone(&e_conv);
21806         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21807         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
21808         return (int64_t)ret_conv;
21809 }
21810
21811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21812         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
21813         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
21814         return ret_val;
21815 }
21816
21817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21818         if ((_res & 1) != 0) return;
21819         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21820         CHECK_ACCESS(_res_ptr);
21821         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
21822         FREE((void*)_res);
21823         CResult_PongDecodeErrorZ_free(_res_conv);
21824 }
21825
21826 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
21827         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21828         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
21829         return (int64_t)ret_conv;
21830 }
21831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21832         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
21833         int64_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
21834         return ret_val;
21835 }
21836
21837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21838         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
21839         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21840         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
21841         return (int64_t)ret_conv;
21842 }
21843
21844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21845         LDKUnsignedChannelAnnouncement o_conv;
21846         o_conv.inner = (void*)(o & (~1));
21847         o_conv.is_owned = (o & 1) || (o == 0);
21848         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21849         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
21850         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21851         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
21852         return (int64_t)ret_conv;
21853 }
21854
21855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21856         LDKDecodeError e_conv;
21857         e_conv.inner = (void*)(e & (~1));
21858         e_conv.is_owned = (e & 1) || (e == 0);
21859         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21860         e_conv = DecodeError_clone(&e_conv);
21861         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21862         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
21863         return (int64_t)ret_conv;
21864 }
21865
21866 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21867         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
21868         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
21869         return ret_val;
21870 }
21871
21872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21873         if ((_res & 1) != 0) return;
21874         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21875         CHECK_ACCESS(_res_ptr);
21876         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
21877         FREE((void*)_res);
21878         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
21879 }
21880
21881 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
21882         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21883         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
21884         return (int64_t)ret_conv;
21885 }
21886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21887         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
21888         int64_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
21889         return ret_val;
21890 }
21891
21892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21893         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
21894         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21895         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
21896         return (int64_t)ret_conv;
21897 }
21898
21899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21900         LDKChannelAnnouncement o_conv;
21901         o_conv.inner = (void*)(o & (~1));
21902         o_conv.is_owned = (o & 1) || (o == 0);
21903         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21904         o_conv = ChannelAnnouncement_clone(&o_conv);
21905         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21906         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
21907         return (int64_t)ret_conv;
21908 }
21909
21910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21911         LDKDecodeError e_conv;
21912         e_conv.inner = (void*)(e & (~1));
21913         e_conv.is_owned = (e & 1) || (e == 0);
21914         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21915         e_conv = DecodeError_clone(&e_conv);
21916         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21917         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
21918         return (int64_t)ret_conv;
21919 }
21920
21921 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21922         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
21923         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
21924         return ret_val;
21925 }
21926
21927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21928         if ((_res & 1) != 0) return;
21929         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21930         CHECK_ACCESS(_res_ptr);
21931         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
21932         FREE((void*)_res);
21933         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
21934 }
21935
21936 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
21937         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21938         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
21939         return (int64_t)ret_conv;
21940 }
21941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21942         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
21943         int64_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
21944         return ret_val;
21945 }
21946
21947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21948         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
21949         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21950         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
21951         return (int64_t)ret_conv;
21952 }
21953
21954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21955         LDKUnsignedChannelUpdate o_conv;
21956         o_conv.inner = (void*)(o & (~1));
21957         o_conv.is_owned = (o & 1) || (o == 0);
21958         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21959         o_conv = UnsignedChannelUpdate_clone(&o_conv);
21960         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21961         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
21962         return (int64_t)ret_conv;
21963 }
21964
21965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21966         LDKDecodeError e_conv;
21967         e_conv.inner = (void*)(e & (~1));
21968         e_conv.is_owned = (e & 1) || (e == 0);
21969         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21970         e_conv = DecodeError_clone(&e_conv);
21971         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21972         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
21973         return (int64_t)ret_conv;
21974 }
21975
21976 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21977         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
21978         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
21979         return ret_val;
21980 }
21981
21982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21983         if ((_res & 1) != 0) return;
21984         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21985         CHECK_ACCESS(_res_ptr);
21986         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
21987         FREE((void*)_res);
21988         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
21989 }
21990
21991 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
21992         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21993         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
21994         return (int64_t)ret_conv;
21995 }
21996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21997         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
21998         int64_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
21999         return ret_val;
22000 }
22001
22002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22003         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
22004         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22005         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
22006         return (int64_t)ret_conv;
22007 }
22008
22009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22010         LDKChannelUpdate o_conv;
22011         o_conv.inner = (void*)(o & (~1));
22012         o_conv.is_owned = (o & 1) || (o == 0);
22013         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22014         o_conv = ChannelUpdate_clone(&o_conv);
22015         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22016         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
22017         return (int64_t)ret_conv;
22018 }
22019
22020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22021         LDKDecodeError e_conv;
22022         e_conv.inner = (void*)(e & (~1));
22023         e_conv.is_owned = (e & 1) || (e == 0);
22024         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22025         e_conv = DecodeError_clone(&e_conv);
22026         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22027         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
22028         return (int64_t)ret_conv;
22029 }
22030
22031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22032         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
22033         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
22034         return ret_val;
22035 }
22036
22037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22038         if ((_res & 1) != 0) return;
22039         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22040         CHECK_ACCESS(_res_ptr);
22041         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
22042         FREE((void*)_res);
22043         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
22044 }
22045
22046 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22047         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22048         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
22049         return (int64_t)ret_conv;
22050 }
22051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22052         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
22053         int64_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22054         return ret_val;
22055 }
22056
22057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22058         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
22059         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22060         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
22061         return (int64_t)ret_conv;
22062 }
22063
22064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22065         LDKErrorMessage o_conv;
22066         o_conv.inner = (void*)(o & (~1));
22067         o_conv.is_owned = (o & 1) || (o == 0);
22068         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22069         o_conv = ErrorMessage_clone(&o_conv);
22070         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22071         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
22072         return (int64_t)ret_conv;
22073 }
22074
22075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22076         LDKDecodeError e_conv;
22077         e_conv.inner = (void*)(e & (~1));
22078         e_conv.is_owned = (e & 1) || (e == 0);
22079         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22080         e_conv = DecodeError_clone(&e_conv);
22081         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22082         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
22083         return (int64_t)ret_conv;
22084 }
22085
22086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22087         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
22088         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
22089         return ret_val;
22090 }
22091
22092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22093         if ((_res & 1) != 0) return;
22094         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22095         CHECK_ACCESS(_res_ptr);
22096         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
22097         FREE((void*)_res);
22098         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
22099 }
22100
22101 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
22102         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22103         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
22104         return (int64_t)ret_conv;
22105 }
22106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22107         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
22108         int64_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
22109         return ret_val;
22110 }
22111
22112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22113         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
22114         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22115         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
22116         return (int64_t)ret_conv;
22117 }
22118
22119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22120         LDKWarningMessage o_conv;
22121         o_conv.inner = (void*)(o & (~1));
22122         o_conv.is_owned = (o & 1) || (o == 0);
22123         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22124         o_conv = WarningMessage_clone(&o_conv);
22125         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22126         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
22127         return (int64_t)ret_conv;
22128 }
22129
22130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22131         LDKDecodeError e_conv;
22132         e_conv.inner = (void*)(e & (~1));
22133         e_conv.is_owned = (e & 1) || (e == 0);
22134         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22135         e_conv = DecodeError_clone(&e_conv);
22136         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22137         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
22138         return (int64_t)ret_conv;
22139 }
22140
22141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22142         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
22143         jboolean ret_val = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
22144         return ret_val;
22145 }
22146
22147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22148         if ((_res & 1) != 0) return;
22149         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22150         CHECK_ACCESS(_res_ptr);
22151         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
22152         FREE((void*)_res);
22153         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
22154 }
22155
22156 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
22157         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22158         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
22159         return (int64_t)ret_conv;
22160 }
22161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22162         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
22163         int64_t ret_val = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
22164         return ret_val;
22165 }
22166
22167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22168         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
22169         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22170         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
22171         return (int64_t)ret_conv;
22172 }
22173
22174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22175         LDKUnsignedNodeAnnouncement o_conv;
22176         o_conv.inner = (void*)(o & (~1));
22177         o_conv.is_owned = (o & 1) || (o == 0);
22178         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22179         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
22180         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22181         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
22182         return (int64_t)ret_conv;
22183 }
22184
22185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22186         LDKDecodeError e_conv;
22187         e_conv.inner = (void*)(e & (~1));
22188         e_conv.is_owned = (e & 1) || (e == 0);
22189         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22190         e_conv = DecodeError_clone(&e_conv);
22191         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22192         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
22193         return (int64_t)ret_conv;
22194 }
22195
22196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22197         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
22198         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22199         return ret_val;
22200 }
22201
22202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22203         if ((_res & 1) != 0) return;
22204         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22205         CHECK_ACCESS(_res_ptr);
22206         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
22207         FREE((void*)_res);
22208         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
22209 }
22210
22211 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22212         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22213         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
22214         return (int64_t)ret_conv;
22215 }
22216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22217         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
22218         int64_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22219         return ret_val;
22220 }
22221
22222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22223         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
22224         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22225         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
22226         return (int64_t)ret_conv;
22227 }
22228
22229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22230         LDKNodeAnnouncement o_conv;
22231         o_conv.inner = (void*)(o & (~1));
22232         o_conv.is_owned = (o & 1) || (o == 0);
22233         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22234         o_conv = NodeAnnouncement_clone(&o_conv);
22235         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22236         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
22237         return (int64_t)ret_conv;
22238 }
22239
22240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22241         LDKDecodeError e_conv;
22242         e_conv.inner = (void*)(e & (~1));
22243         e_conv.is_owned = (e & 1) || (e == 0);
22244         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22245         e_conv = DecodeError_clone(&e_conv);
22246         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22247         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
22248         return (int64_t)ret_conv;
22249 }
22250
22251 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22252         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
22253         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22254         return ret_val;
22255 }
22256
22257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22258         if ((_res & 1) != 0) return;
22259         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22260         CHECK_ACCESS(_res_ptr);
22261         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
22262         FREE((void*)_res);
22263         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
22264 }
22265
22266 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22267         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22268         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
22269         return (int64_t)ret_conv;
22270 }
22271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22272         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
22273         int64_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22274         return ret_val;
22275 }
22276
22277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22278         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
22279         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22280         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
22281         return (int64_t)ret_conv;
22282 }
22283
22284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22285         LDKQueryShortChannelIds o_conv;
22286         o_conv.inner = (void*)(o & (~1));
22287         o_conv.is_owned = (o & 1) || (o == 0);
22288         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22289         o_conv = QueryShortChannelIds_clone(&o_conv);
22290         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22291         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
22292         return (int64_t)ret_conv;
22293 }
22294
22295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22296         LDKDecodeError e_conv;
22297         e_conv.inner = (void*)(e & (~1));
22298         e_conv.is_owned = (e & 1) || (e == 0);
22299         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22300         e_conv = DecodeError_clone(&e_conv);
22301         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22302         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
22303         return (int64_t)ret_conv;
22304 }
22305
22306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22307         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
22308         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
22309         return ret_val;
22310 }
22311
22312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22313         if ((_res & 1) != 0) return;
22314         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22315         CHECK_ACCESS(_res_ptr);
22316         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
22317         FREE((void*)_res);
22318         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
22319 }
22320
22321 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
22322         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22323         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
22324         return (int64_t)ret_conv;
22325 }
22326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22327         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
22328         int64_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
22329         return ret_val;
22330 }
22331
22332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22333         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
22334         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22335         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
22336         return (int64_t)ret_conv;
22337 }
22338
22339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22340         LDKReplyShortChannelIdsEnd o_conv;
22341         o_conv.inner = (void*)(o & (~1));
22342         o_conv.is_owned = (o & 1) || (o == 0);
22343         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22344         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
22345         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22346         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
22347         return (int64_t)ret_conv;
22348 }
22349
22350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22351         LDKDecodeError e_conv;
22352         e_conv.inner = (void*)(e & (~1));
22353         e_conv.is_owned = (e & 1) || (e == 0);
22354         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22355         e_conv = DecodeError_clone(&e_conv);
22356         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22357         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
22358         return (int64_t)ret_conv;
22359 }
22360
22361 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22362         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
22363         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
22364         return ret_val;
22365 }
22366
22367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22368         if ((_res & 1) != 0) return;
22369         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22370         CHECK_ACCESS(_res_ptr);
22371         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
22372         FREE((void*)_res);
22373         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
22374 }
22375
22376 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
22377         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22378         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
22379         return (int64_t)ret_conv;
22380 }
22381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22382         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
22383         int64_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
22384         return ret_val;
22385 }
22386
22387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22388         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
22389         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22390         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
22391         return (int64_t)ret_conv;
22392 }
22393
22394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22395         LDKQueryChannelRange o_conv;
22396         o_conv.inner = (void*)(o & (~1));
22397         o_conv.is_owned = (o & 1) || (o == 0);
22398         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22399         o_conv = QueryChannelRange_clone(&o_conv);
22400         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22401         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
22402         return (int64_t)ret_conv;
22403 }
22404
22405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22406         LDKDecodeError e_conv;
22407         e_conv.inner = (void*)(e & (~1));
22408         e_conv.is_owned = (e & 1) || (e == 0);
22409         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22410         e_conv = DecodeError_clone(&e_conv);
22411         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22412         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
22413         return (int64_t)ret_conv;
22414 }
22415
22416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22417         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
22418         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
22419         return ret_val;
22420 }
22421
22422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22423         if ((_res & 1) != 0) return;
22424         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22425         CHECK_ACCESS(_res_ptr);
22426         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
22427         FREE((void*)_res);
22428         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
22429 }
22430
22431 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22432         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22433         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
22434         return (int64_t)ret_conv;
22435 }
22436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22437         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
22438         int64_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22439         return ret_val;
22440 }
22441
22442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22443         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
22444         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22445         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
22446         return (int64_t)ret_conv;
22447 }
22448
22449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22450         LDKReplyChannelRange o_conv;
22451         o_conv.inner = (void*)(o & (~1));
22452         o_conv.is_owned = (o & 1) || (o == 0);
22453         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22454         o_conv = ReplyChannelRange_clone(&o_conv);
22455         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22456         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
22457         return (int64_t)ret_conv;
22458 }
22459
22460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22461         LDKDecodeError e_conv;
22462         e_conv.inner = (void*)(e & (~1));
22463         e_conv.is_owned = (e & 1) || (e == 0);
22464         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22465         e_conv = DecodeError_clone(&e_conv);
22466         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22467         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
22468         return (int64_t)ret_conv;
22469 }
22470
22471 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22472         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
22473         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
22474         return ret_val;
22475 }
22476
22477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22478         if ((_res & 1) != 0) return;
22479         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22480         CHECK_ACCESS(_res_ptr);
22481         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
22482         FREE((void*)_res);
22483         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
22484 }
22485
22486 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22487         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22488         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
22489         return (int64_t)ret_conv;
22490 }
22491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22492         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
22493         int64_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22494         return ret_val;
22495 }
22496
22497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22498         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
22499         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22500         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
22501         return (int64_t)ret_conv;
22502 }
22503
22504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22505         LDKGossipTimestampFilter o_conv;
22506         o_conv.inner = (void*)(o & (~1));
22507         o_conv.is_owned = (o & 1) || (o == 0);
22508         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22509         o_conv = GossipTimestampFilter_clone(&o_conv);
22510         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22511         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
22512         return (int64_t)ret_conv;
22513 }
22514
22515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22516         LDKDecodeError e_conv;
22517         e_conv.inner = (void*)(e & (~1));
22518         e_conv.is_owned = (e & 1) || (e == 0);
22519         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22520         e_conv = DecodeError_clone(&e_conv);
22521         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22522         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
22523         return (int64_t)ret_conv;
22524 }
22525
22526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22527         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
22528         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
22529         return ret_val;
22530 }
22531
22532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22533         if ((_res & 1) != 0) return;
22534         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22535         CHECK_ACCESS(_res_ptr);
22536         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
22537         FREE((void*)_res);
22538         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
22539 }
22540
22541 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
22542         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22543         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
22544         return (int64_t)ret_conv;
22545 }
22546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22547         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
22548         int64_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
22549         return ret_val;
22550 }
22551
22552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22553         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
22554         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22555         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
22556         return (int64_t)ret_conv;
22557 }
22558
22559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22560         LDKCVec_PhantomRouteHintsZ _res_constr;
22561         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22562         if (_res_constr.datalen > 0)
22563                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
22564         else
22565                 _res_constr.data = NULL;
22566         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22567         for (size_t t = 0; t < _res_constr.datalen; t++) {
22568                 int64_t _res_conv_19 = _res_vals[t];
22569                 LDKPhantomRouteHints _res_conv_19_conv;
22570                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
22571                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
22572                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22573                 _res_constr.data[t] = _res_conv_19_conv;
22574         }
22575         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22576         CVec_PhantomRouteHintsZ_free(_res_constr);
22577 }
22578
22579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22580         LDKInvoice o_conv;
22581         o_conv.inner = (void*)(o & (~1));
22582         o_conv.is_owned = (o & 1) || (o == 0);
22583         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22584         o_conv = Invoice_clone(&o_conv);
22585         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22586         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
22587         return (int64_t)ret_conv;
22588 }
22589
22590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22591         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
22592         CHECK_ACCESS(e_ptr);
22593         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
22594         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
22595         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22596         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
22597         return (int64_t)ret_conv;
22598 }
22599
22600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22601         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
22602         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
22603         return ret_val;
22604 }
22605
22606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22607         if ((_res & 1) != 0) return;
22608         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22609         CHECK_ACCESS(_res_ptr);
22610         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
22611         FREE((void*)_res);
22612         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
22613 }
22614
22615 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
22616         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22617         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
22618         return (int64_t)ret_conv;
22619 }
22620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22621         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
22622         int64_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
22623         return ret_val;
22624 }
22625
22626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22627         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
22628         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22629         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
22630         return (int64_t)ret_conv;
22631 }
22632
22633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22634         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
22635         CHECK_ACCESS(o_ptr);
22636         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
22637         if (o_conv.free == LDKFilter_JCalls_free) {
22638                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22639                 LDKFilter_JCalls_cloned(&o_conv);
22640         }
22641         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
22642         *ret_copy = COption_FilterZ_some(o_conv);
22643         int64_t ret_ref = (uintptr_t)ret_copy;
22644         return ret_ref;
22645 }
22646
22647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
22648         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
22649         *ret_copy = COption_FilterZ_none();
22650         int64_t ret_ref = (uintptr_t)ret_copy;
22651         return ret_ref;
22652 }
22653
22654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22655         if ((_res & 1) != 0) return;
22656         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22657         CHECK_ACCESS(_res_ptr);
22658         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
22659         FREE((void*)_res);
22660         COption_FilterZ_free(_res_conv);
22661 }
22662
22663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22664         LDKLockedChannelMonitor o_conv;
22665         o_conv.inner = (void*)(o & (~1));
22666         o_conv.is_owned = (o & 1) || (o == 0);
22667         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22668         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
22669         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22670         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
22671         return (int64_t)ret_conv;
22672 }
22673
22674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
22675         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22676         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
22677         return (int64_t)ret_conv;
22678 }
22679
22680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22681         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
22682         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
22683         return ret_val;
22684 }
22685
22686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22687         if ((_res & 1) != 0) return;
22688         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22689         CHECK_ACCESS(_res_ptr);
22690         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
22691         FREE((void*)_res);
22692         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
22693 }
22694
22695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22696         LDKCVec_OutPointZ _res_constr;
22697         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22698         if (_res_constr.datalen > 0)
22699                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
22700         else
22701                 _res_constr.data = NULL;
22702         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22703         for (size_t k = 0; k < _res_constr.datalen; k++) {
22704                 int64_t _res_conv_10 = _res_vals[k];
22705                 LDKOutPoint _res_conv_10_conv;
22706                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
22707                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
22708                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
22709                 _res_constr.data[k] = _res_conv_10_conv;
22710         }
22711         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22712         CVec_OutPointZ_free(_res_constr);
22713 }
22714
22715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22716         if ((this_ptr & 1) != 0) return;
22717         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22718         CHECK_ACCESS(this_ptr_ptr);
22719         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
22720         FREE((void*)this_ptr);
22721         PaymentPurpose_free(this_ptr_conv);
22722 }
22723
22724 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
22725         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
22726         *ret_copy = PaymentPurpose_clone(arg);
22727 int64_t ret_ref = (uintptr_t)ret_copy;
22728         return ret_ref;
22729 }
22730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22731         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
22732         int64_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
22733         return ret_val;
22734 }
22735
22736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22737         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
22738         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
22739         *ret_copy = PaymentPurpose_clone(orig_conv);
22740         int64_t ret_ref = (uintptr_t)ret_copy;
22741         return ret_ref;
22742 }
22743
22744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
22745         LDKThirtyTwoBytes payment_preimage_ref;
22746         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
22747         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
22748         LDKThirtyTwoBytes payment_secret_ref;
22749         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
22750         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
22751         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
22752         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
22753         int64_t ret_ref = (uintptr_t)ret_copy;
22754         return ret_ref;
22755 }
22756
22757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
22758         LDKThirtyTwoBytes a_ref;
22759         CHECK((*env)->GetArrayLength(env, a) == 32);
22760         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22761         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
22762         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
22763         int64_t ret_ref = (uintptr_t)ret_copy;
22764         return ret_ref;
22765 }
22766
22767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22768         if ((this_ptr & 1) != 0) return;
22769         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22770         CHECK_ACCESS(this_ptr_ptr);
22771         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
22772         FREE((void*)this_ptr);
22773         ClosureReason_free(this_ptr_conv);
22774 }
22775
22776 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
22777         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22778         *ret_copy = ClosureReason_clone(arg);
22779 int64_t ret_ref = (uintptr_t)ret_copy;
22780         return ret_ref;
22781 }
22782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22783         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
22784         int64_t ret_val = ClosureReason_clone_ptr(arg_conv);
22785         return ret_val;
22786 }
22787
22788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22789         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
22790         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22791         *ret_copy = ClosureReason_clone(orig_conv);
22792         int64_t ret_ref = (uintptr_t)ret_copy;
22793         return ret_ref;
22794 }
22795
22796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
22797         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
22798         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22799         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
22800         int64_t ret_ref = (uintptr_t)ret_copy;
22801         return ret_ref;
22802 }
22803
22804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
22805         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22806         *ret_copy = ClosureReason_holder_force_closed();
22807         int64_t ret_ref = (uintptr_t)ret_copy;
22808         return ret_ref;
22809 }
22810
22811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
22812         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22813         *ret_copy = ClosureReason_cooperative_closure();
22814         int64_t ret_ref = (uintptr_t)ret_copy;
22815         return ret_ref;
22816 }
22817
22818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
22819         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22820         *ret_copy = ClosureReason_commitment_tx_confirmed();
22821         int64_t ret_ref = (uintptr_t)ret_copy;
22822         return ret_ref;
22823 }
22824
22825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
22826         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22827         *ret_copy = ClosureReason_funding_timed_out();
22828         int64_t ret_ref = (uintptr_t)ret_copy;
22829         return ret_ref;
22830 }
22831
22832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
22833         LDKStr err_conv = java_to_owned_str(env, err);
22834         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22835         *ret_copy = ClosureReason_processing_error(err_conv);
22836         int64_t ret_ref = (uintptr_t)ret_copy;
22837         return ret_ref;
22838 }
22839
22840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
22841         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22842         *ret_copy = ClosureReason_disconnected_peer();
22843         int64_t ret_ref = (uintptr_t)ret_copy;
22844         return ret_ref;
22845 }
22846
22847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
22848         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22849         *ret_copy = ClosureReason_outdated_channel_manager();
22850         int64_t ret_ref = (uintptr_t)ret_copy;
22851         return ret_ref;
22852 }
22853
22854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
22855         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
22856         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
22857         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22858         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22859         CVec_u8Z_free(ret_var);
22860         return ret_arr;
22861 }
22862
22863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22864         LDKu8slice ser_ref;
22865         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22866         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22867         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
22868         *ret_conv = ClosureReason_read(ser_ref);
22869         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22870         return (int64_t)ret_conv;
22871 }
22872
22873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22874         if ((this_ptr & 1) != 0) return;
22875         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22876         CHECK_ACCESS(this_ptr_ptr);
22877         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
22878         FREE((void*)this_ptr);
22879         Event_free(this_ptr_conv);
22880 }
22881
22882 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
22883         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22884         *ret_copy = Event_clone(arg);
22885 int64_t ret_ref = (uintptr_t)ret_copy;
22886         return ret_ref;
22887 }
22888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22889         LDKEvent* arg_conv = (LDKEvent*)arg;
22890         int64_t ret_val = Event_clone_ptr(arg_conv);
22891         return ret_val;
22892 }
22893
22894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22895         LDKEvent* orig_conv = (LDKEvent*)orig;
22896         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22897         *ret_copy = Event_clone(orig_conv);
22898         int64_t ret_ref = (uintptr_t)ret_copy;
22899         return ret_ref;
22900 }
22901
22902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
22903         LDKThirtyTwoBytes temporary_channel_id_ref;
22904         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
22905         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
22906         LDKCVec_u8Z output_script_ref;
22907         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
22908         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
22909         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
22910         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22911         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
22912         int64_t ret_ref = (uintptr_t)ret_copy;
22913         return ret_ref;
22914 }
22915
22916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
22917         LDKThirtyTwoBytes payment_hash_ref;
22918         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
22919         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
22920         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
22921         CHECK_ACCESS(purpose_ptr);
22922         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
22923         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
22924         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22925         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
22926         int64_t ret_ref = (uintptr_t)ret_copy;
22927         return ret_ref;
22928 }
22929
22930 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) {
22931         LDKThirtyTwoBytes payment_id_ref;
22932         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
22933         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
22934         LDKThirtyTwoBytes payment_preimage_ref;
22935         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
22936         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
22937         LDKThirtyTwoBytes payment_hash_ref;
22938         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
22939         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
22940         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
22941         CHECK_ACCESS(fee_paid_msat_ptr);
22942         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
22943         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
22944         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22945         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
22946         int64_t ret_ref = (uintptr_t)ret_copy;
22947         return ret_ref;
22948 }
22949
22950 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) {
22951         LDKThirtyTwoBytes payment_id_ref;
22952         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
22953         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
22954         LDKThirtyTwoBytes payment_hash_ref;
22955         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
22956         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
22957         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
22958         CHECK_ACCESS(network_update_ptr);
22959         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
22960         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
22961         LDKCVec_RouteHopZ path_constr;
22962         path_constr.datalen = (*env)->GetArrayLength(env, path);
22963         if (path_constr.datalen > 0)
22964                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
22965         else
22966                 path_constr.data = NULL;
22967         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
22968         for (size_t k = 0; k < path_constr.datalen; k++) {
22969                 int64_t path_conv_10 = path_vals[k];
22970                 LDKRouteHop path_conv_10_conv;
22971                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
22972                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
22973                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
22974                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
22975                 path_constr.data[k] = path_conv_10_conv;
22976         }
22977         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
22978         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
22979         CHECK_ACCESS(short_channel_id_ptr);
22980         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
22981         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
22982         LDKRouteParameters retry_conv;
22983         retry_conv.inner = (void*)(retry & (~1));
22984         retry_conv.is_owned = (retry & 1) || (retry == 0);
22985         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
22986         retry_conv = RouteParameters_clone(&retry_conv);
22987         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22988         *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);
22989         int64_t ret_ref = (uintptr_t)ret_copy;
22990         return ret_ref;
22991 }
22992
22993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
22994         LDKThirtyTwoBytes payment_id_ref;
22995         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
22996         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
22997         LDKThirtyTwoBytes payment_hash_ref;
22998         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
22999         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23000         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23001         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
23002         int64_t ret_ref = (uintptr_t)ret_copy;
23003         return ret_ref;
23004 }
23005
23006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
23007         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23008         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
23009         int64_t ret_ref = (uintptr_t)ret_copy;
23010         return ret_ref;
23011 }
23012
23013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
23014         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
23015         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
23016         if (outputs_constr.datalen > 0)
23017                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23018         else
23019                 outputs_constr.data = NULL;
23020         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
23021         for (size_t b = 0; b < outputs_constr.datalen; b++) {
23022                 int64_t outputs_conv_27 = outputs_vals[b];
23023                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
23024                 CHECK_ACCESS(outputs_conv_27_ptr);
23025                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
23026                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
23027                 outputs_constr.data[b] = outputs_conv_27_conv;
23028         }
23029         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
23030         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23031         *ret_copy = Event_spendable_outputs(outputs_constr);
23032         int64_t ret_ref = (uintptr_t)ret_copy;
23033         return ret_ref;
23034 }
23035
23036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
23037         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
23038         CHECK_ACCESS(fee_earned_msat_ptr);
23039         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
23040         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
23041         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23042         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
23043         int64_t ret_ref = (uintptr_t)ret_copy;
23044         return ret_ref;
23045 }
23046
23047 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) {
23048         LDKThirtyTwoBytes channel_id_ref;
23049         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23050         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23051         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
23052         CHECK_ACCESS(reason_ptr);
23053         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
23054         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
23055         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23056         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
23057         int64_t ret_ref = (uintptr_t)ret_copy;
23058         return ret_ref;
23059 }
23060
23061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
23062         LDKThirtyTwoBytes channel_id_ref;
23063         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23064         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23065         LDKTransaction transaction_ref;
23066         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
23067         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
23068         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
23069         transaction_ref.data_is_owned = true;
23070         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23071         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
23072         int64_t ret_ref = (uintptr_t)ret_copy;
23073         return ret_ref;
23074 }
23075
23076 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) {
23077         LDKThirtyTwoBytes payment_id_ref;
23078         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23079         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23080         LDKThirtyTwoBytes payment_hash_ref;
23081         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23082         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23083         LDKCVec_RouteHopZ path_constr;
23084         path_constr.datalen = (*env)->GetArrayLength(env, path);
23085         if (path_constr.datalen > 0)
23086                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23087         else
23088                 path_constr.data = NULL;
23089         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23090         for (size_t k = 0; k < path_constr.datalen; k++) {
23091                 int64_t path_conv_10 = path_vals[k];
23092                 LDKRouteHop path_conv_10_conv;
23093                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
23094                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
23095                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23096                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23097                 path_constr.data[k] = path_conv_10_conv;
23098         }
23099         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23100         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23101         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
23102         int64_t ret_ref = (uintptr_t)ret_copy;
23103         return ret_ref;
23104 }
23105
23106 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) {
23107         LDKThirtyTwoBytes temporary_channel_id_ref;
23108         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23109         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23110         LDKPublicKey counterparty_node_id_ref;
23111         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
23112         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
23113         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23114         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat);
23115         int64_t ret_ref = (uintptr_t)ret_copy;
23116         return ret_ref;
23117 }
23118
23119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
23120         LDKEvent* obj_conv = (LDKEvent*)obj;
23121         LDKCVec_u8Z ret_var = Event_write(obj_conv);
23122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23124         CVec_u8Z_free(ret_var);
23125         return ret_arr;
23126 }
23127
23128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23129         LDKu8slice ser_ref;
23130         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23131         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23132         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
23133         *ret_conv = Event_read(ser_ref);
23134         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23135         return (int64_t)ret_conv;
23136 }
23137
23138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23139         if ((this_ptr & 1) != 0) return;
23140         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23141         CHECK_ACCESS(this_ptr_ptr);
23142         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
23143         FREE((void*)this_ptr);
23144         MessageSendEvent_free(this_ptr_conv);
23145 }
23146
23147 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
23148         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23149         *ret_copy = MessageSendEvent_clone(arg);
23150 int64_t ret_ref = (uintptr_t)ret_copy;
23151         return ret_ref;
23152 }
23153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23154         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
23155         int64_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
23156         return ret_val;
23157 }
23158
23159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23160         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
23161         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23162         *ret_copy = MessageSendEvent_clone(orig_conv);
23163         int64_t ret_ref = (uintptr_t)ret_copy;
23164         return ret_ref;
23165 }
23166
23167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23168         LDKPublicKey node_id_ref;
23169         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23170         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23171         LDKAcceptChannel msg_conv;
23172         msg_conv.inner = (void*)(msg & (~1));
23173         msg_conv.is_owned = (msg & 1) || (msg == 0);
23174         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23175         msg_conv = AcceptChannel_clone(&msg_conv);
23176         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23177         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
23178         int64_t ret_ref = (uintptr_t)ret_copy;
23179         return ret_ref;
23180 }
23181
23182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23183         LDKPublicKey node_id_ref;
23184         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23185         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23186         LDKOpenChannel msg_conv;
23187         msg_conv.inner = (void*)(msg & (~1));
23188         msg_conv.is_owned = (msg & 1) || (msg == 0);
23189         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23190         msg_conv = OpenChannel_clone(&msg_conv);
23191         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23192         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
23193         int64_t ret_ref = (uintptr_t)ret_copy;
23194         return ret_ref;
23195 }
23196
23197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23198         LDKPublicKey node_id_ref;
23199         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23200         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23201         LDKFundingCreated msg_conv;
23202         msg_conv.inner = (void*)(msg & (~1));
23203         msg_conv.is_owned = (msg & 1) || (msg == 0);
23204         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23205         msg_conv = FundingCreated_clone(&msg_conv);
23206         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23207         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
23208         int64_t ret_ref = (uintptr_t)ret_copy;
23209         return ret_ref;
23210 }
23211
23212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23213         LDKPublicKey node_id_ref;
23214         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23215         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23216         LDKFundingSigned msg_conv;
23217         msg_conv.inner = (void*)(msg & (~1));
23218         msg_conv.is_owned = (msg & 1) || (msg == 0);
23219         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23220         msg_conv = FundingSigned_clone(&msg_conv);
23221         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23222         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
23223         int64_t ret_ref = (uintptr_t)ret_copy;
23224         return ret_ref;
23225 }
23226
23227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23228         LDKPublicKey node_id_ref;
23229         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23230         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23231         LDKFundingLocked msg_conv;
23232         msg_conv.inner = (void*)(msg & (~1));
23233         msg_conv.is_owned = (msg & 1) || (msg == 0);
23234         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23235         msg_conv = FundingLocked_clone(&msg_conv);
23236         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23237         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
23238         int64_t ret_ref = (uintptr_t)ret_copy;
23239         return ret_ref;
23240 }
23241
23242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23243         LDKPublicKey node_id_ref;
23244         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23245         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23246         LDKAnnouncementSignatures msg_conv;
23247         msg_conv.inner = (void*)(msg & (~1));
23248         msg_conv.is_owned = (msg & 1) || (msg == 0);
23249         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23250         msg_conv = AnnouncementSignatures_clone(&msg_conv);
23251         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23252         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
23253         int64_t ret_ref = (uintptr_t)ret_copy;
23254         return ret_ref;
23255 }
23256
23257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
23258         LDKPublicKey node_id_ref;
23259         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23260         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23261         LDKCommitmentUpdate updates_conv;
23262         updates_conv.inner = (void*)(updates & (~1));
23263         updates_conv.is_owned = (updates & 1) || (updates == 0);
23264         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23265         updates_conv = CommitmentUpdate_clone(&updates_conv);
23266         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23267         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
23268         int64_t ret_ref = (uintptr_t)ret_copy;
23269         return ret_ref;
23270 }
23271
23272 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) {
23273         LDKPublicKey node_id_ref;
23274         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23275         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23276         LDKRevokeAndACK msg_conv;
23277         msg_conv.inner = (void*)(msg & (~1));
23278         msg_conv.is_owned = (msg & 1) || (msg == 0);
23279         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23280         msg_conv = RevokeAndACK_clone(&msg_conv);
23281         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23282         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
23283         int64_t ret_ref = (uintptr_t)ret_copy;
23284         return ret_ref;
23285 }
23286
23287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23288         LDKPublicKey node_id_ref;
23289         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23290         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23291         LDKClosingSigned msg_conv;
23292         msg_conv.inner = (void*)(msg & (~1));
23293         msg_conv.is_owned = (msg & 1) || (msg == 0);
23294         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23295         msg_conv = ClosingSigned_clone(&msg_conv);
23296         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23297         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
23298         int64_t ret_ref = (uintptr_t)ret_copy;
23299         return ret_ref;
23300 }
23301
23302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23303         LDKPublicKey node_id_ref;
23304         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23305         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23306         LDKShutdown msg_conv;
23307         msg_conv.inner = (void*)(msg & (~1));
23308         msg_conv.is_owned = (msg & 1) || (msg == 0);
23309         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23310         msg_conv = Shutdown_clone(&msg_conv);
23311         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23312         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
23313         int64_t ret_ref = (uintptr_t)ret_copy;
23314         return ret_ref;
23315 }
23316
23317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23318         LDKPublicKey node_id_ref;
23319         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23320         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23321         LDKChannelReestablish msg_conv;
23322         msg_conv.inner = (void*)(msg & (~1));
23323         msg_conv.is_owned = (msg & 1) || (msg == 0);
23324         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23325         msg_conv = ChannelReestablish_clone(&msg_conv);
23326         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23327         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
23328         int64_t ret_ref = (uintptr_t)ret_copy;
23329         return ret_ref;
23330 }
23331
23332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
23333         LDKChannelAnnouncement msg_conv;
23334         msg_conv.inner = (void*)(msg & (~1));
23335         msg_conv.is_owned = (msg & 1) || (msg == 0);
23336         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23337         msg_conv = ChannelAnnouncement_clone(&msg_conv);
23338         LDKChannelUpdate update_msg_conv;
23339         update_msg_conv.inner = (void*)(update_msg & (~1));
23340         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
23341         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
23342         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
23343         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23344         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
23345         int64_t ret_ref = (uintptr_t)ret_copy;
23346         return ret_ref;
23347 }
23348
23349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
23350         LDKNodeAnnouncement msg_conv;
23351         msg_conv.inner = (void*)(msg & (~1));
23352         msg_conv.is_owned = (msg & 1) || (msg == 0);
23353         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23354         msg_conv = NodeAnnouncement_clone(&msg_conv);
23355         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23356         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
23357         int64_t ret_ref = (uintptr_t)ret_copy;
23358         return ret_ref;
23359 }
23360
23361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
23362         LDKChannelUpdate msg_conv;
23363         msg_conv.inner = (void*)(msg & (~1));
23364         msg_conv.is_owned = (msg & 1) || (msg == 0);
23365         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23366         msg_conv = ChannelUpdate_clone(&msg_conv);
23367         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23368         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
23369         int64_t ret_ref = (uintptr_t)ret_copy;
23370         return ret_ref;
23371 }
23372
23373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23374         LDKPublicKey node_id_ref;
23375         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23376         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23377         LDKChannelUpdate msg_conv;
23378         msg_conv.inner = (void*)(msg & (~1));
23379         msg_conv.is_owned = (msg & 1) || (msg == 0);
23380         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23381         msg_conv = ChannelUpdate_clone(&msg_conv);
23382         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23383         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
23384         int64_t ret_ref = (uintptr_t)ret_copy;
23385         return ret_ref;
23386 }
23387
23388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
23389         LDKPublicKey node_id_ref;
23390         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23391         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23392         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
23393         CHECK_ACCESS(action_ptr);
23394         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
23395         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
23396         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23397         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
23398         int64_t ret_ref = (uintptr_t)ret_copy;
23399         return ret_ref;
23400 }
23401
23402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1range_1query(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23403         LDKPublicKey node_id_ref;
23404         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23405         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23406         LDKQueryChannelRange msg_conv;
23407         msg_conv.inner = (void*)(msg & (~1));
23408         msg_conv.is_owned = (msg & 1) || (msg == 0);
23409         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23410         msg_conv = QueryChannelRange_clone(&msg_conv);
23411         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23412         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
23413         int64_t ret_ref = (uintptr_t)ret_copy;
23414         return ret_ref;
23415 }
23416
23417 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) {
23418         LDKPublicKey node_id_ref;
23419         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23420         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23421         LDKQueryShortChannelIds msg_conv;
23422         msg_conv.inner = (void*)(msg & (~1));
23423         msg_conv.is_owned = (msg & 1) || (msg == 0);
23424         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23425         msg_conv = QueryShortChannelIds_clone(&msg_conv);
23426         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23427         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
23428         int64_t ret_ref = (uintptr_t)ret_copy;
23429         return ret_ref;
23430 }
23431
23432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1reply_1channel_1range(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23433         LDKPublicKey node_id_ref;
23434         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23435         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23436         LDKReplyChannelRange msg_conv;
23437         msg_conv.inner = (void*)(msg & (~1));
23438         msg_conv.is_owned = (msg & 1) || (msg == 0);
23439         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23440         msg_conv = ReplyChannelRange_clone(&msg_conv);
23441         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23442         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
23443         int64_t ret_ref = (uintptr_t)ret_copy;
23444         return ret_ref;
23445 }
23446
23447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23448         if ((this_ptr & 1) != 0) return;
23449         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23450         CHECK_ACCESS(this_ptr_ptr);
23451         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
23452         FREE((void*)this_ptr);
23453         MessageSendEventsProvider_free(this_ptr_conv);
23454 }
23455
23456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23457         if ((this_ptr & 1) != 0) return;
23458         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23459         CHECK_ACCESS(this_ptr_ptr);
23460         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
23461         FREE((void*)this_ptr);
23462         EventsProvider_free(this_ptr_conv);
23463 }
23464
23465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23466         if ((this_ptr & 1) != 0) return;
23467         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23468         CHECK_ACCESS(this_ptr_ptr);
23469         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
23470         FREE((void*)this_ptr);
23471         EventHandler_free(this_ptr_conv);
23472 }
23473
23474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23475         if ((this_ptr & 1) != 0) return;
23476         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23477         CHECK_ACCESS(this_ptr_ptr);
23478         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
23479         FREE((void*)this_ptr);
23480         APIError_free(this_ptr_conv);
23481 }
23482
23483 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
23484         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23485         *ret_copy = APIError_clone(arg);
23486 int64_t ret_ref = (uintptr_t)ret_copy;
23487         return ret_ref;
23488 }
23489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23490         LDKAPIError* arg_conv = (LDKAPIError*)arg;
23491         int64_t ret_val = APIError_clone_ptr(arg_conv);
23492         return ret_val;
23493 }
23494
23495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23496         LDKAPIError* orig_conv = (LDKAPIError*)orig;
23497         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23498         *ret_copy = APIError_clone(orig_conv);
23499         int64_t ret_ref = (uintptr_t)ret_copy;
23500         return ret_ref;
23501 }
23502
23503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
23504         LDKStr err_conv = java_to_owned_str(env, err);
23505         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23506         *ret_copy = APIError_apimisuse_error(err_conv);
23507         int64_t ret_ref = (uintptr_t)ret_copy;
23508         return ret_ref;
23509 }
23510
23511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
23512         LDKStr err_conv = java_to_owned_str(env, err);
23513         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23514         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
23515         int64_t ret_ref = (uintptr_t)ret_copy;
23516         return ret_ref;
23517 }
23518
23519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
23520         LDKStr err_conv = java_to_owned_str(env, err);
23521         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23522         *ret_copy = APIError_route_error(err_conv);
23523         int64_t ret_ref = (uintptr_t)ret_copy;
23524         return ret_ref;
23525 }
23526
23527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
23528         LDKStr err_conv = java_to_owned_str(env, err);
23529         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23530         *ret_copy = APIError_channel_unavailable(err_conv);
23531         int64_t ret_ref = (uintptr_t)ret_copy;
23532         return ret_ref;
23533 }
23534
23535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
23536         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23537         *ret_copy = APIError_monitor_update_failed();
23538         int64_t ret_ref = (uintptr_t)ret_copy;
23539         return ret_ref;
23540 }
23541
23542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
23543         LDKShutdownScript script_conv;
23544         script_conv.inner = (void*)(script & (~1));
23545         script_conv.is_owned = (script & 1) || (script == 0);
23546         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
23547         script_conv = ShutdownScript_clone(&script_conv);
23548         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23549         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
23550         int64_t ret_ref = (uintptr_t)ret_copy;
23551         return ret_ref;
23552 }
23553
23554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
23555         LDKu8slice msg_ref;
23556         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23557         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23558         unsigned char sk_arr[32];
23559         CHECK((*env)->GetArrayLength(env, sk) == 32);
23560         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
23561         unsigned char (*sk_ref)[32] = &sk_arr;
23562         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
23563         *ret_conv = sign(msg_ref, sk_ref);
23564         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23565         return (int64_t)ret_conv;
23566 }
23567
23568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
23569         LDKu8slice msg_ref;
23570         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23571         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23572         LDKStr sig_conv = java_to_owned_str(env, sig);
23573         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
23574         *ret_conv = recover_pk(msg_ref, sig_conv);
23575         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23576         return (int64_t)ret_conv;
23577 }
23578
23579 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
23580         LDKu8slice msg_ref;
23581         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23582         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23583         LDKStr sig_conv = java_to_owned_str(env, sig);
23584         LDKPublicKey pk_ref;
23585         CHECK((*env)->GetArrayLength(env, pk) == 33);
23586         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
23587         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
23588         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23589         return ret_val;
23590 }
23591
23592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
23593         LDKu8slice hrp_bytes_ref;
23594         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
23595         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
23596         LDKCVec_u5Z data_without_signature_constr;
23597         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
23598         if (data_without_signature_constr.datalen > 0)
23599                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
23600         else
23601                 data_without_signature_constr.data = NULL;
23602         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
23603         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
23604                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
23605                 
23606                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
23607         }
23608         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
23609         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
23610         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23611         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23612         CVec_u8Z_free(ret_var);
23613         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
23614         return ret_arr;
23615 }
23616
23617 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23618         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
23619         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
23620         return ret_conv;
23621 }
23622
23623 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
23624         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
23625         return ret_conv;
23626 }
23627
23628 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
23629         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
23630         return ret_conv;
23631 }
23632
23633 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
23634         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
23635         return ret_conv;
23636 }
23637
23638 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
23639         jclass ret_conv = LDKLevel_to_java(env, Level_info());
23640         return ret_conv;
23641 }
23642
23643 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
23644         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
23645         return ret_conv;
23646 }
23647
23648 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
23649         jclass ret_conv = LDKLevel_to_java(env, Level_error());
23650         return ret_conv;
23651 }
23652
23653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23654         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
23655         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
23656         jboolean ret_val = Level_eq(a_conv, b_conv);
23657         return ret_val;
23658 }
23659
23660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
23661         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
23662         int64_t ret_val = Level_hash(o_conv);
23663         return ret_val;
23664 }
23665
23666 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
23667         jclass ret_conv = LDKLevel_to_java(env, Level_max());
23668         return ret_conv;
23669 }
23670
23671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23672         LDKRecord this_obj_conv;
23673         this_obj_conv.inner = (void*)(this_obj & (~1));
23674         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23676         Record_free(this_obj_conv);
23677 }
23678
23679 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
23680         LDKRecord this_ptr_conv;
23681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23682         this_ptr_conv.is_owned = false;
23683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23684         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
23685         return ret_conv;
23686 }
23687
23688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
23689         LDKRecord this_ptr_conv;
23690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23691         this_ptr_conv.is_owned = false;
23692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23693         LDKLevel val_conv = LDKLevel_from_java(env, val);
23694         Record_set_level(&this_ptr_conv, val_conv);
23695 }
23696
23697 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
23698         LDKRecord this_ptr_conv;
23699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23700         this_ptr_conv.is_owned = false;
23701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23702         LDKStr ret_str = Record_get_args(&this_ptr_conv);
23703         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
23704         Str_free(ret_str);
23705         return ret_conv;
23706 }
23707
23708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
23709         LDKRecord this_ptr_conv;
23710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23711         this_ptr_conv.is_owned = false;
23712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23713         LDKStr val_conv = java_to_owned_str(env, val);
23714         Record_set_args(&this_ptr_conv, val_conv);
23715 }
23716
23717 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
23718         LDKRecord this_ptr_conv;
23719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23720         this_ptr_conv.is_owned = false;
23721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23722         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
23723         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
23724         Str_free(ret_str);
23725         return ret_conv;
23726 }
23727
23728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
23729         LDKRecord this_ptr_conv;
23730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23731         this_ptr_conv.is_owned = false;
23732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23733         LDKStr val_conv = java_to_owned_str(env, val);
23734         Record_set_module_path(&this_ptr_conv, val_conv);
23735 }
23736
23737 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
23738         LDKRecord this_ptr_conv;
23739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23740         this_ptr_conv.is_owned = false;
23741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23742         LDKStr ret_str = Record_get_file(&this_ptr_conv);
23743         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
23744         Str_free(ret_str);
23745         return ret_conv;
23746 }
23747
23748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
23749         LDKRecord this_ptr_conv;
23750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23751         this_ptr_conv.is_owned = false;
23752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23753         LDKStr val_conv = java_to_owned_str(env, val);
23754         Record_set_file(&this_ptr_conv, val_conv);
23755 }
23756
23757 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
23758         LDKRecord this_ptr_conv;
23759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23760         this_ptr_conv.is_owned = false;
23761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23762         int32_t ret_val = Record_get_line(&this_ptr_conv);
23763         return ret_val;
23764 }
23765
23766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23767         LDKRecord this_ptr_conv;
23768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23769         this_ptr_conv.is_owned = false;
23770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23771         Record_set_line(&this_ptr_conv, val);
23772 }
23773
23774 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
23775         LDKRecord ret_var = Record_clone(arg);
23776 int64_t ret_ref = 0;
23777 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23778 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23779 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23780 ret_ref = (uintptr_t)ret_var.inner;
23781 if (ret_var.is_owned) {
23782         ret_ref |= 1;
23783 }
23784         return ret_ref;
23785 }
23786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23787         LDKRecord arg_conv;
23788         arg_conv.inner = (void*)(arg & (~1));
23789         arg_conv.is_owned = false;
23790         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23791         int64_t ret_val = Record_clone_ptr(&arg_conv);
23792         return ret_val;
23793 }
23794
23795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23796         LDKRecord orig_conv;
23797         orig_conv.inner = (void*)(orig & (~1));
23798         orig_conv.is_owned = false;
23799         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23800         LDKRecord ret_var = Record_clone(&orig_conv);
23801         int64_t ret_ref = 0;
23802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23805         ret_ref = (uintptr_t)ret_var.inner;
23806         if (ret_var.is_owned) {
23807                 ret_ref |= 1;
23808         }
23809         return ret_ref;
23810 }
23811
23812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23813         if ((this_ptr & 1) != 0) return;
23814         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23815         CHECK_ACCESS(this_ptr_ptr);
23816         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
23817         FREE((void*)this_ptr);
23818         Logger_free(this_ptr_conv);
23819 }
23820
23821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23822         LDKChannelHandshakeConfig this_obj_conv;
23823         this_obj_conv.inner = (void*)(this_obj & (~1));
23824         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23826         ChannelHandshakeConfig_free(this_obj_conv);
23827 }
23828
23829 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
23830         LDKChannelHandshakeConfig this_ptr_conv;
23831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23832         this_ptr_conv.is_owned = false;
23833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23834         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
23835         return ret_val;
23836 }
23837
23838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23839         LDKChannelHandshakeConfig this_ptr_conv;
23840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23841         this_ptr_conv.is_owned = false;
23842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23843         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
23844 }
23845
23846 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
23847         LDKChannelHandshakeConfig this_ptr_conv;
23848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23849         this_ptr_conv.is_owned = false;
23850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23851         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
23852         return ret_val;
23853 }
23854
23855 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) {
23856         LDKChannelHandshakeConfig this_ptr_conv;
23857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23858         this_ptr_conv.is_owned = false;
23859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23860         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
23861 }
23862
23863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23864         LDKChannelHandshakeConfig this_ptr_conv;
23865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23866         this_ptr_conv.is_owned = false;
23867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23868         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
23869         return ret_val;
23870 }
23871
23872 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) {
23873         LDKChannelHandshakeConfig this_ptr_conv;
23874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23875         this_ptr_conv.is_owned = false;
23876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23877         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
23878 }
23879
23880 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) {
23881         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
23882         int64_t ret_ref = 0;
23883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23886         ret_ref = (uintptr_t)ret_var.inner;
23887         if (ret_var.is_owned) {
23888                 ret_ref |= 1;
23889         }
23890         return ret_ref;
23891 }
23892
23893 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
23894         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
23895 int64_t ret_ref = 0;
23896 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23897 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23898 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23899 ret_ref = (uintptr_t)ret_var.inner;
23900 if (ret_var.is_owned) {
23901         ret_ref |= 1;
23902 }
23903         return ret_ref;
23904 }
23905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23906         LDKChannelHandshakeConfig arg_conv;
23907         arg_conv.inner = (void*)(arg & (~1));
23908         arg_conv.is_owned = false;
23909         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23910         int64_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
23911         return ret_val;
23912 }
23913
23914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23915         LDKChannelHandshakeConfig orig_conv;
23916         orig_conv.inner = (void*)(orig & (~1));
23917         orig_conv.is_owned = false;
23918         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23919         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
23920         int64_t ret_ref = 0;
23921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23924         ret_ref = (uintptr_t)ret_var.inner;
23925         if (ret_var.is_owned) {
23926                 ret_ref |= 1;
23927         }
23928         return ret_ref;
23929 }
23930
23931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
23932         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
23933         int64_t ret_ref = 0;
23934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23937         ret_ref = (uintptr_t)ret_var.inner;
23938         if (ret_var.is_owned) {
23939                 ret_ref |= 1;
23940         }
23941         return ret_ref;
23942 }
23943
23944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23945         LDKChannelHandshakeLimits this_obj_conv;
23946         this_obj_conv.inner = (void*)(this_obj & (~1));
23947         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23949         ChannelHandshakeLimits_free(this_obj_conv);
23950 }
23951
23952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
23953         LDKChannelHandshakeLimits this_ptr_conv;
23954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23955         this_ptr_conv.is_owned = false;
23956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23957         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
23958         return ret_val;
23959 }
23960
23961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23962         LDKChannelHandshakeLimits this_ptr_conv;
23963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23964         this_ptr_conv.is_owned = false;
23965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23966         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
23967 }
23968
23969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23970         LDKChannelHandshakeLimits this_ptr_conv;
23971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23972         this_ptr_conv.is_owned = false;
23973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23974         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
23975         return ret_val;
23976 }
23977
23978 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) {
23979         LDKChannelHandshakeLimits this_ptr_conv;
23980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23981         this_ptr_conv.is_owned = false;
23982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23983         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
23984 }
23985
23986 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) {
23987         LDKChannelHandshakeLimits this_ptr_conv;
23988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23989         this_ptr_conv.is_owned = false;
23990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23991         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
23992         return ret_val;
23993 }
23994
23995 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) {
23996         LDKChannelHandshakeLimits this_ptr_conv;
23997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23998         this_ptr_conv.is_owned = false;
23999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24000         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
24001 }
24002
24003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24004         LDKChannelHandshakeLimits this_ptr_conv;
24005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24006         this_ptr_conv.is_owned = false;
24007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24008         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
24009         return ret_val;
24010 }
24011
24012 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) {
24013         LDKChannelHandshakeLimits this_ptr_conv;
24014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24015         this_ptr_conv.is_owned = false;
24016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24017         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
24018 }
24019
24020 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
24021         LDKChannelHandshakeLimits this_ptr_conv;
24022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24023         this_ptr_conv.is_owned = false;
24024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24025         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
24026         return ret_val;
24027 }
24028
24029 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) {
24030         LDKChannelHandshakeLimits this_ptr_conv;
24031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24032         this_ptr_conv.is_owned = false;
24033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24034         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
24035 }
24036
24037 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24038         LDKChannelHandshakeLimits this_ptr_conv;
24039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24040         this_ptr_conv.is_owned = false;
24041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24042         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
24043         return ret_val;
24044 }
24045
24046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24047         LDKChannelHandshakeLimits this_ptr_conv;
24048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24049         this_ptr_conv.is_owned = false;
24050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24051         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
24052 }
24053
24054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
24055         LDKChannelHandshakeLimits this_ptr_conv;
24056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24057         this_ptr_conv.is_owned = false;
24058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24059         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
24060         return ret_val;
24061 }
24062
24063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24064         LDKChannelHandshakeLimits this_ptr_conv;
24065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24066         this_ptr_conv.is_owned = false;
24067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24068         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
24069 }
24070
24071 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24072         LDKChannelHandshakeLimits this_ptr_conv;
24073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24074         this_ptr_conv.is_owned = false;
24075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24076         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
24077         return ret_val;
24078 }
24079
24080 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) {
24081         LDKChannelHandshakeLimits this_ptr_conv;
24082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24083         this_ptr_conv.is_owned = false;
24084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24085         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
24086 }
24087
24088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
24089         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
24090         int64_t ret_ref = 0;
24091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24094         ret_ref = (uintptr_t)ret_var.inner;
24095         if (ret_var.is_owned) {
24096                 ret_ref |= 1;
24097         }
24098         return ret_ref;
24099 }
24100
24101 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
24102         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
24103 int64_t ret_ref = 0;
24104 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24105 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24106 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24107 ret_ref = (uintptr_t)ret_var.inner;
24108 if (ret_var.is_owned) {
24109         ret_ref |= 1;
24110 }
24111         return ret_ref;
24112 }
24113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24114         LDKChannelHandshakeLimits arg_conv;
24115         arg_conv.inner = (void*)(arg & (~1));
24116         arg_conv.is_owned = false;
24117         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24118         int64_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
24119         return ret_val;
24120 }
24121
24122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24123         LDKChannelHandshakeLimits orig_conv;
24124         orig_conv.inner = (void*)(orig & (~1));
24125         orig_conv.is_owned = false;
24126         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24127         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
24128         int64_t ret_ref = 0;
24129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24132         ret_ref = (uintptr_t)ret_var.inner;
24133         if (ret_var.is_owned) {
24134                 ret_ref |= 1;
24135         }
24136         return ret_ref;
24137 }
24138
24139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
24140         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
24141         int64_t ret_ref = 0;
24142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24145         ret_ref = (uintptr_t)ret_var.inner;
24146         if (ret_var.is_owned) {
24147                 ret_ref |= 1;
24148         }
24149         return ret_ref;
24150 }
24151
24152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24153         LDKChannelConfig this_obj_conv;
24154         this_obj_conv.inner = (void*)(this_obj & (~1));
24155         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24157         ChannelConfig_free(this_obj_conv);
24158 }
24159
24160 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24161         LDKChannelConfig this_ptr_conv;
24162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24163         this_ptr_conv.is_owned = false;
24164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24165         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
24166         return ret_val;
24167 }
24168
24169 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) {
24170         LDKChannelConfig this_ptr_conv;
24171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24172         this_ptr_conv.is_owned = false;
24173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24174         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
24175 }
24176
24177 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24178         LDKChannelConfig this_ptr_conv;
24179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24180         this_ptr_conv.is_owned = false;
24181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24182         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
24183         return ret_val;
24184 }
24185
24186 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) {
24187         LDKChannelConfig this_ptr_conv;
24188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24189         this_ptr_conv.is_owned = false;
24190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24191         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
24192 }
24193
24194 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24195         LDKChannelConfig this_ptr_conv;
24196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24197         this_ptr_conv.is_owned = false;
24198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24199         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
24200         return ret_val;
24201 }
24202
24203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24204         LDKChannelConfig this_ptr_conv;
24205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24206         this_ptr_conv.is_owned = false;
24207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24208         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
24209 }
24210
24211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
24212         LDKChannelConfig this_ptr_conv;
24213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24214         this_ptr_conv.is_owned = false;
24215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24216         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
24217         return ret_val;
24218 }
24219
24220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24221         LDKChannelConfig this_ptr_conv;
24222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24223         this_ptr_conv.is_owned = false;
24224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24225         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
24226 }
24227
24228 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24229         LDKChannelConfig this_ptr_conv;
24230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24231         this_ptr_conv.is_owned = false;
24232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24233         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
24234         return ret_val;
24235 }
24236
24237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24238         LDKChannelConfig this_ptr_conv;
24239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24240         this_ptr_conv.is_owned = false;
24241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24242         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
24243 }
24244
24245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24246         LDKChannelConfig this_ptr_conv;
24247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24248         this_ptr_conv.is_owned = false;
24249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24250         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
24251         return ret_val;
24252 }
24253
24254 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) {
24255         LDKChannelConfig this_ptr_conv;
24256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24257         this_ptr_conv.is_owned = false;
24258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24259         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
24260 }
24261
24262 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) {
24263         LDKChannelConfig this_ptr_conv;
24264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24265         this_ptr_conv.is_owned = false;
24266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24267         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
24268         return ret_val;
24269 }
24270
24271 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) {
24272         LDKChannelConfig this_ptr_conv;
24273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24274         this_ptr_conv.is_owned = false;
24275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24276         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
24277 }
24278
24279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
24280         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
24281         int64_t ret_ref = 0;
24282         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24283         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24285         ret_ref = (uintptr_t)ret_var.inner;
24286         if (ret_var.is_owned) {
24287                 ret_ref |= 1;
24288         }
24289         return ret_ref;
24290 }
24291
24292 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
24293         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
24294 int64_t ret_ref = 0;
24295 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24296 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24297 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24298 ret_ref = (uintptr_t)ret_var.inner;
24299 if (ret_var.is_owned) {
24300         ret_ref |= 1;
24301 }
24302         return ret_ref;
24303 }
24304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24305         LDKChannelConfig arg_conv;
24306         arg_conv.inner = (void*)(arg & (~1));
24307         arg_conv.is_owned = false;
24308         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24309         int64_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
24310         return ret_val;
24311 }
24312
24313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24314         LDKChannelConfig orig_conv;
24315         orig_conv.inner = (void*)(orig & (~1));
24316         orig_conv.is_owned = false;
24317         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24318         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
24319         int64_t ret_ref = 0;
24320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24323         ret_ref = (uintptr_t)ret_var.inner;
24324         if (ret_var.is_owned) {
24325                 ret_ref |= 1;
24326         }
24327         return ret_ref;
24328 }
24329
24330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
24331         LDKChannelConfig ret_var = ChannelConfig_default();
24332         int64_t ret_ref = 0;
24333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24336         ret_ref = (uintptr_t)ret_var.inner;
24337         if (ret_var.is_owned) {
24338                 ret_ref |= 1;
24339         }
24340         return ret_ref;
24341 }
24342
24343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
24344         LDKChannelConfig obj_conv;
24345         obj_conv.inner = (void*)(obj & (~1));
24346         obj_conv.is_owned = false;
24347         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24348         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
24349         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24350         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24351         CVec_u8Z_free(ret_var);
24352         return ret_arr;
24353 }
24354
24355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24356         LDKu8slice ser_ref;
24357         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24358         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24359         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
24360         *ret_conv = ChannelConfig_read(ser_ref);
24361         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24362         return (int64_t)ret_conv;
24363 }
24364
24365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24366         LDKUserConfig this_obj_conv;
24367         this_obj_conv.inner = (void*)(this_obj & (~1));
24368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24370         UserConfig_free(this_obj_conv);
24371 }
24372
24373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
24374         LDKUserConfig this_ptr_conv;
24375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24376         this_ptr_conv.is_owned = false;
24377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24378         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
24379         int64_t ret_ref = 0;
24380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24383         ret_ref = (uintptr_t)ret_var.inner;
24384         if (ret_var.is_owned) {
24385                 ret_ref |= 1;
24386         }
24387         return ret_ref;
24388 }
24389
24390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24391         LDKUserConfig this_ptr_conv;
24392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24393         this_ptr_conv.is_owned = false;
24394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24395         LDKChannelHandshakeConfig val_conv;
24396         val_conv.inner = (void*)(val & (~1));
24397         val_conv.is_owned = (val & 1) || (val == 0);
24398         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24399         val_conv = ChannelHandshakeConfig_clone(&val_conv);
24400         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
24401 }
24402
24403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
24404         LDKUserConfig this_ptr_conv;
24405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24406         this_ptr_conv.is_owned = false;
24407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24408         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
24409         int64_t ret_ref = 0;
24410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24413         ret_ref = (uintptr_t)ret_var.inner;
24414         if (ret_var.is_owned) {
24415                 ret_ref |= 1;
24416         }
24417         return ret_ref;
24418 }
24419
24420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24421         LDKUserConfig this_ptr_conv;
24422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24423         this_ptr_conv.is_owned = false;
24424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24425         LDKChannelHandshakeLimits val_conv;
24426         val_conv.inner = (void*)(val & (~1));
24427         val_conv.is_owned = (val & 1) || (val == 0);
24428         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24429         val_conv = ChannelHandshakeLimits_clone(&val_conv);
24430         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
24431 }
24432
24433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
24434         LDKUserConfig this_ptr_conv;
24435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24436         this_ptr_conv.is_owned = false;
24437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24438         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
24439         int64_t ret_ref = 0;
24440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24443         ret_ref = (uintptr_t)ret_var.inner;
24444         if (ret_var.is_owned) {
24445                 ret_ref |= 1;
24446         }
24447         return ret_ref;
24448 }
24449
24450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24451         LDKUserConfig this_ptr_conv;
24452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24453         this_ptr_conv.is_owned = false;
24454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24455         LDKChannelConfig val_conv;
24456         val_conv.inner = (void*)(val & (~1));
24457         val_conv.is_owned = (val & 1) || (val == 0);
24458         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24459         val_conv = ChannelConfig_clone(&val_conv);
24460         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
24461 }
24462
24463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24464         LDKUserConfig this_ptr_conv;
24465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24466         this_ptr_conv.is_owned = false;
24467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24468         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
24469         return ret_val;
24470 }
24471
24472 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) {
24473         LDKUserConfig this_ptr_conv;
24474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24475         this_ptr_conv.is_owned = false;
24476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24477         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
24478 }
24479
24480 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24481         LDKUserConfig this_ptr_conv;
24482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24483         this_ptr_conv.is_owned = false;
24484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24485         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
24486         return ret_val;
24487 }
24488
24489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24490         LDKUserConfig this_ptr_conv;
24491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24492         this_ptr_conv.is_owned = false;
24493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24494         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
24495 }
24496
24497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24498         LDKUserConfig this_ptr_conv;
24499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24500         this_ptr_conv.is_owned = false;
24501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24502         jboolean ret_val = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
24503         return ret_val;
24504 }
24505
24506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24507         LDKUserConfig this_ptr_conv;
24508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24509         this_ptr_conv.is_owned = false;
24510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24511         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
24512 }
24513
24514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
24515         LDKChannelHandshakeConfig own_channel_config_arg_conv;
24516         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
24517         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
24518         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
24519         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
24520         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
24521         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
24522         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
24523         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
24524         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
24525         LDKChannelConfig channel_options_arg_conv;
24526         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
24527         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
24528         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
24529         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
24530         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
24531         int64_t ret_ref = 0;
24532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24535         ret_ref = (uintptr_t)ret_var.inner;
24536         if (ret_var.is_owned) {
24537                 ret_ref |= 1;
24538         }
24539         return ret_ref;
24540 }
24541
24542 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
24543         LDKUserConfig ret_var = UserConfig_clone(arg);
24544 int64_t ret_ref = 0;
24545 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24546 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24547 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24548 ret_ref = (uintptr_t)ret_var.inner;
24549 if (ret_var.is_owned) {
24550         ret_ref |= 1;
24551 }
24552         return ret_ref;
24553 }
24554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24555         LDKUserConfig arg_conv;
24556         arg_conv.inner = (void*)(arg & (~1));
24557         arg_conv.is_owned = false;
24558         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24559         int64_t ret_val = UserConfig_clone_ptr(&arg_conv);
24560         return ret_val;
24561 }
24562
24563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24564         LDKUserConfig orig_conv;
24565         orig_conv.inner = (void*)(orig & (~1));
24566         orig_conv.is_owned = false;
24567         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24568         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
24569         int64_t ret_ref = 0;
24570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24573         ret_ref = (uintptr_t)ret_var.inner;
24574         if (ret_var.is_owned) {
24575                 ret_ref |= 1;
24576         }
24577         return ret_ref;
24578 }
24579
24580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
24581         LDKUserConfig ret_var = UserConfig_default();
24582         int64_t ret_ref = 0;
24583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24586         ret_ref = (uintptr_t)ret_var.inner;
24587         if (ret_var.is_owned) {
24588                 ret_ref |= 1;
24589         }
24590         return ret_ref;
24591 }
24592
24593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24594         LDKBestBlock this_obj_conv;
24595         this_obj_conv.inner = (void*)(this_obj & (~1));
24596         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24598         BestBlock_free(this_obj_conv);
24599 }
24600
24601 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
24602         LDKBestBlock ret_var = BestBlock_clone(arg);
24603 int64_t ret_ref = 0;
24604 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24605 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24606 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24607 ret_ref = (uintptr_t)ret_var.inner;
24608 if (ret_var.is_owned) {
24609         ret_ref |= 1;
24610 }
24611         return ret_ref;
24612 }
24613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24614         LDKBestBlock arg_conv;
24615         arg_conv.inner = (void*)(arg & (~1));
24616         arg_conv.is_owned = false;
24617         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24618         int64_t ret_val = BestBlock_clone_ptr(&arg_conv);
24619         return ret_val;
24620 }
24621
24622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24623         LDKBestBlock orig_conv;
24624         orig_conv.inner = (void*)(orig & (~1));
24625         orig_conv.is_owned = false;
24626         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24627         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
24628         int64_t ret_ref = 0;
24629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24632         ret_ref = (uintptr_t)ret_var.inner;
24633         if (ret_var.is_owned) {
24634                 ret_ref |= 1;
24635         }
24636         return ret_ref;
24637 }
24638
24639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
24640         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
24641         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
24642         int64_t ret_ref = 0;
24643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24646         ret_ref = (uintptr_t)ret_var.inner;
24647         if (ret_var.is_owned) {
24648                 ret_ref |= 1;
24649         }
24650         return ret_ref;
24651 }
24652
24653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
24654         LDKThirtyTwoBytes block_hash_ref;
24655         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
24656         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
24657         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
24658         int64_t ret_ref = 0;
24659         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24660         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24662         ret_ref = (uintptr_t)ret_var.inner;
24663         if (ret_var.is_owned) {
24664                 ret_ref |= 1;
24665         }
24666         return ret_ref;
24667 }
24668
24669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
24670         LDKBestBlock this_arg_conv;
24671         this_arg_conv.inner = (void*)(this_arg & (~1));
24672         this_arg_conv.is_owned = false;
24673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24674         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
24676         return ret_arr;
24677 }
24678
24679 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
24680         LDKBestBlock this_arg_conv;
24681         this_arg_conv.inner = (void*)(this_arg & (~1));
24682         this_arg_conv.is_owned = false;
24683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24684         int32_t ret_val = BestBlock_height(&this_arg_conv);
24685         return ret_val;
24686 }
24687
24688 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24689         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
24690         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
24691         return ret_conv;
24692 }
24693
24694 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
24695         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
24696         return ret_conv;
24697 }
24698
24699 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
24700         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
24701         return ret_conv;
24702 }
24703
24704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24705         if ((this_ptr & 1) != 0) return;
24706         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24707         CHECK_ACCESS(this_ptr_ptr);
24708         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
24709         FREE((void*)this_ptr);
24710         Access_free(this_ptr_conv);
24711 }
24712
24713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24714         if ((this_ptr & 1) != 0) return;
24715         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24716         CHECK_ACCESS(this_ptr_ptr);
24717         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
24718         FREE((void*)this_ptr);
24719         Listen_free(this_ptr_conv);
24720 }
24721
24722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24723         if ((this_ptr & 1) != 0) return;
24724         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24725         CHECK_ACCESS(this_ptr_ptr);
24726         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
24727         FREE((void*)this_ptr);
24728         Confirm_free(this_ptr_conv);
24729 }
24730
24731 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24732         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
24733         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
24734         return ret_conv;
24735 }
24736
24737 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
24738         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
24739         return ret_conv;
24740 }
24741
24742 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
24743         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
24744         return ret_conv;
24745 }
24746
24747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24748         if ((this_ptr & 1) != 0) return;
24749         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24750         CHECK_ACCESS(this_ptr_ptr);
24751         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
24752         FREE((void*)this_ptr);
24753         Watch_free(this_ptr_conv);
24754 }
24755
24756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24757         if ((this_ptr & 1) != 0) return;
24758         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24759         CHECK_ACCESS(this_ptr_ptr);
24760         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
24761         FREE((void*)this_ptr);
24762         Filter_free(this_ptr_conv);
24763 }
24764
24765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24766         LDKWatchedOutput this_obj_conv;
24767         this_obj_conv.inner = (void*)(this_obj & (~1));
24768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24770         WatchedOutput_free(this_obj_conv);
24771 }
24772
24773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
24774         LDKWatchedOutput this_ptr_conv;
24775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24776         this_ptr_conv.is_owned = false;
24777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24778         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
24780         return ret_arr;
24781 }
24782
24783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24784         LDKWatchedOutput this_ptr_conv;
24785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24786         this_ptr_conv.is_owned = false;
24787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24788         LDKThirtyTwoBytes val_ref;
24789         CHECK((*env)->GetArrayLength(env, val) == 32);
24790         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24791         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
24792 }
24793
24794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
24795         LDKWatchedOutput this_ptr_conv;
24796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24797         this_ptr_conv.is_owned = false;
24798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24799         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
24800         int64_t ret_ref = 0;
24801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24804         ret_ref = (uintptr_t)ret_var.inner;
24805         if (ret_var.is_owned) {
24806                 ret_ref |= 1;
24807         }
24808         return ret_ref;
24809 }
24810
24811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24812         LDKWatchedOutput this_ptr_conv;
24813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24814         this_ptr_conv.is_owned = false;
24815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24816         LDKOutPoint val_conv;
24817         val_conv.inner = (void*)(val & (~1));
24818         val_conv.is_owned = (val & 1) || (val == 0);
24819         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24820         val_conv = OutPoint_clone(&val_conv);
24821         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
24822 }
24823
24824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24825         LDKWatchedOutput this_ptr_conv;
24826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24827         this_ptr_conv.is_owned = false;
24828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24829         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
24830         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24831         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24832         return ret_arr;
24833 }
24834
24835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24836         LDKWatchedOutput this_ptr_conv;
24837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24838         this_ptr_conv.is_owned = false;
24839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24840         LDKCVec_u8Z val_ref;
24841         val_ref.datalen = (*env)->GetArrayLength(env, val);
24842         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
24843         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
24844         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
24845 }
24846
24847 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) {
24848         LDKThirtyTwoBytes block_hash_arg_ref;
24849         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
24850         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
24851         LDKOutPoint outpoint_arg_conv;
24852         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24853         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24854         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24855         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24856         LDKCVec_u8Z script_pubkey_arg_ref;
24857         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
24858         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
24859         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
24860         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
24861         int64_t ret_ref = 0;
24862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24865         ret_ref = (uintptr_t)ret_var.inner;
24866         if (ret_var.is_owned) {
24867                 ret_ref |= 1;
24868         }
24869         return ret_ref;
24870 }
24871
24872 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
24873         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
24874 int64_t ret_ref = 0;
24875 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24876 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24877 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24878 ret_ref = (uintptr_t)ret_var.inner;
24879 if (ret_var.is_owned) {
24880         ret_ref |= 1;
24881 }
24882         return ret_ref;
24883 }
24884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24885         LDKWatchedOutput arg_conv;
24886         arg_conv.inner = (void*)(arg & (~1));
24887         arg_conv.is_owned = false;
24888         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24889         int64_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
24890         return ret_val;
24891 }
24892
24893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24894         LDKWatchedOutput orig_conv;
24895         orig_conv.inner = (void*)(orig & (~1));
24896         orig_conv.is_owned = false;
24897         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24898         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
24899         int64_t ret_ref = 0;
24900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24903         ret_ref = (uintptr_t)ret_var.inner;
24904         if (ret_var.is_owned) {
24905                 ret_ref |= 1;
24906         }
24907         return ret_ref;
24908 }
24909
24910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
24911         LDKWatchedOutput o_conv;
24912         o_conv.inner = (void*)(o & (~1));
24913         o_conv.is_owned = false;
24914         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24915         int64_t ret_val = WatchedOutput_hash(&o_conv);
24916         return ret_val;
24917 }
24918
24919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24920         if ((this_ptr & 1) != 0) return;
24921         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24922         CHECK_ACCESS(this_ptr_ptr);
24923         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
24924         FREE((void*)this_ptr);
24925         BroadcasterInterface_free(this_ptr_conv);
24926 }
24927
24928 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24929         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
24930         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
24931         return ret_conv;
24932 }
24933
24934 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
24935         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
24936         return ret_conv;
24937 }
24938
24939 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
24940         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
24941         return ret_conv;
24942 }
24943
24944 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
24945         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
24946         return ret_conv;
24947 }
24948
24949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24950         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
24951         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
24952         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
24953         return ret_val;
24954 }
24955
24956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24957         if ((this_ptr & 1) != 0) return;
24958         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24959         CHECK_ACCESS(this_ptr_ptr);
24960         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
24961         FREE((void*)this_ptr);
24962         FeeEstimator_free(this_ptr_conv);
24963 }
24964
24965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24966         LDKMonitorUpdateId this_obj_conv;
24967         this_obj_conv.inner = (void*)(this_obj & (~1));
24968         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24970         MonitorUpdateId_free(this_obj_conv);
24971 }
24972
24973 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
24974         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
24975 int64_t ret_ref = 0;
24976 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24977 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24978 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24979 ret_ref = (uintptr_t)ret_var.inner;
24980 if (ret_var.is_owned) {
24981         ret_ref |= 1;
24982 }
24983         return ret_ref;
24984 }
24985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24986         LDKMonitorUpdateId arg_conv;
24987         arg_conv.inner = (void*)(arg & (~1));
24988         arg_conv.is_owned = false;
24989         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24990         int64_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
24991         return ret_val;
24992 }
24993
24994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24995         LDKMonitorUpdateId orig_conv;
24996         orig_conv.inner = (void*)(orig & (~1));
24997         orig_conv.is_owned = false;
24998         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24999         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
25000         int64_t ret_ref = 0;
25001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25004         ret_ref = (uintptr_t)ret_var.inner;
25005         if (ret_var.is_owned) {
25006                 ret_ref |= 1;
25007         }
25008         return ret_ref;
25009 }
25010
25011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
25012         LDKMonitorUpdateId o_conv;
25013         o_conv.inner = (void*)(o & (~1));
25014         o_conv.is_owned = false;
25015         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25016         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
25017         return ret_val;
25018 }
25019
25020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25021         LDKMonitorUpdateId a_conv;
25022         a_conv.inner = (void*)(a & (~1));
25023         a_conv.is_owned = false;
25024         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25025         LDKMonitorUpdateId b_conv;
25026         b_conv.inner = (void*)(b & (~1));
25027         b_conv.is_owned = false;
25028         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
25029         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
25030         return ret_val;
25031 }
25032
25033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25034         if ((this_ptr & 1) != 0) return;
25035         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25036         CHECK_ACCESS(this_ptr_ptr);
25037         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
25038         FREE((void*)this_ptr);
25039         Persist_free(this_ptr_conv);
25040 }
25041
25042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25043         LDKLockedChannelMonitor this_obj_conv;
25044         this_obj_conv.inner = (void*)(this_obj & (~1));
25045         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25047         LockedChannelMonitor_free(this_obj_conv);
25048 }
25049
25050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25051         LDKChainMonitor this_obj_conv;
25052         this_obj_conv.inner = (void*)(this_obj & (~1));
25053         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25055         ChainMonitor_free(this_obj_conv);
25056 }
25057
25058 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) {
25059         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
25060         CHECK_ACCESS(chain_source_ptr);
25061         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
25062         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
25063         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
25064                 // Manually implement clone for Java trait instances
25065                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
25066                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25067                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
25068                 }
25069         }
25070         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25071         CHECK_ACCESS(broadcaster_ptr);
25072         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25073         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25074                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25075                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25076         }
25077         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25078         CHECK_ACCESS(logger_ptr);
25079         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25080         if (logger_conv.free == LDKLogger_JCalls_free) {
25081                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25082                 LDKLogger_JCalls_cloned(&logger_conv);
25083         }
25084         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
25085         CHECK_ACCESS(feeest_ptr);
25086         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
25087         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
25088                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25089                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
25090         }
25091         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
25092         CHECK_ACCESS(persister_ptr);
25093         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
25094         if (persister_conv.free == LDKPersist_JCalls_free) {
25095                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25096                 LDKPersist_JCalls_cloned(&persister_conv);
25097         }
25098         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
25099         int64_t ret_ref = 0;
25100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25103         ret_ref = (uintptr_t)ret_var.inner;
25104         if (ret_var.is_owned) {
25105                 ret_ref |= 1;
25106         }
25107         return ret_ref;
25108 }
25109
25110 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) {
25111         LDKChainMonitor this_arg_conv;
25112         this_arg_conv.inner = (void*)(this_arg & (~1));
25113         this_arg_conv.is_owned = false;
25114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25115         LDKCVec_ChannelDetailsZ ignored_channels_constr;
25116         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
25117         if (ignored_channels_constr.datalen > 0)
25118                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25119         else
25120                 ignored_channels_constr.data = NULL;
25121         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
25122         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
25123                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
25124                 LDKChannelDetails ignored_channels_conv_16_conv;
25125                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
25126                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
25127                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
25128                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
25129                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
25130         }
25131         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
25132         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
25133         int64_tArray ret_arr = NULL;
25134         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25135         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25136         for (size_t j = 0; j < ret_var.datalen; j++) {
25137                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25138                 *ret_conv_9_copy = ret_var.data[j];
25139                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
25140                 ret_arr_ptr[j] = ret_conv_9_ref;
25141         }
25142         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25143         FREE(ret_var.data);
25144         return ret_arr;
25145 }
25146
25147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
25148         LDKChainMonitor this_arg_conv;
25149         this_arg_conv.inner = (void*)(this_arg & (~1));
25150         this_arg_conv.is_owned = false;
25151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25152         LDKOutPoint funding_txo_conv;
25153         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25154         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25155         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25156         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25157         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25158         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
25159         return (int64_t)ret_conv;
25160 }
25161
25162 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
25163         LDKChainMonitor this_arg_conv;
25164         this_arg_conv.inner = (void*)(this_arg & (~1));
25165         this_arg_conv.is_owned = false;
25166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25167         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
25168         int64_tArray ret_arr = NULL;
25169         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25170         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25171         for (size_t k = 0; k < ret_var.datalen; k++) {
25172                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
25173                 int64_t ret_conv_10_ref = 0;
25174                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25175                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25176                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
25177                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
25178                 if (ret_conv_10_var.is_owned) {
25179                         ret_conv_10_ref |= 1;
25180                 }
25181                 ret_arr_ptr[k] = ret_conv_10_ref;
25182         }
25183         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25184         FREE(ret_var.data);
25185         return ret_arr;
25186 }
25187
25188 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) {
25189         LDKChainMonitor this_arg_conv;
25190         this_arg_conv.inner = (void*)(this_arg & (~1));
25191         this_arg_conv.is_owned = false;
25192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25193         LDKOutPoint funding_txo_conv;
25194         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25195         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25196         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25197         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25198         LDKMonitorUpdateId completed_update_id_conv;
25199         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
25200         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
25201         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
25202         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
25203         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25204         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
25205         return (int64_t)ret_conv;
25206 }
25207
25208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
25209         LDKChainMonitor this_arg_conv;
25210         this_arg_conv.inner = (void*)(this_arg & (~1));
25211         this_arg_conv.is_owned = false;
25212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25213         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25214         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
25215         return (int64_t)ret_ret;
25216 }
25217
25218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
25219         LDKChainMonitor this_arg_conv;
25220         this_arg_conv.inner = (void*)(this_arg & (~1));
25221         this_arg_conv.is_owned = false;
25222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25223         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25224         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
25225         return (int64_t)ret_ret;
25226 }
25227
25228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
25229         LDKChainMonitor this_arg_conv;
25230         this_arg_conv.inner = (void*)(this_arg & (~1));
25231         this_arg_conv.is_owned = false;
25232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25233         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
25234         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
25235         return (int64_t)ret_ret;
25236 }
25237
25238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25239         LDKChainMonitor this_arg_conv;
25240         this_arg_conv.inner = (void*)(this_arg & (~1));
25241         this_arg_conv.is_owned = false;
25242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25243         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25244         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
25245         return (int64_t)ret_ret;
25246 }
25247
25248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25249         LDKChannelMonitorUpdate this_obj_conv;
25250         this_obj_conv.inner = (void*)(this_obj & (~1));
25251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25253         ChannelMonitorUpdate_free(this_obj_conv);
25254 }
25255
25256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25257         LDKChannelMonitorUpdate this_ptr_conv;
25258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25259         this_ptr_conv.is_owned = false;
25260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25261         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
25262         return ret_val;
25263 }
25264
25265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25266         LDKChannelMonitorUpdate this_ptr_conv;
25267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25268         this_ptr_conv.is_owned = false;
25269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25270         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
25271 }
25272
25273 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
25274         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
25275 int64_t ret_ref = 0;
25276 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25277 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25278 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25279 ret_ref = (uintptr_t)ret_var.inner;
25280 if (ret_var.is_owned) {
25281         ret_ref |= 1;
25282 }
25283         return ret_ref;
25284 }
25285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25286         LDKChannelMonitorUpdate arg_conv;
25287         arg_conv.inner = (void*)(arg & (~1));
25288         arg_conv.is_owned = false;
25289         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25290         int64_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
25291         return ret_val;
25292 }
25293
25294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25295         LDKChannelMonitorUpdate orig_conv;
25296         orig_conv.inner = (void*)(orig & (~1));
25297         orig_conv.is_owned = false;
25298         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25299         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
25300         int64_t ret_ref = 0;
25301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25304         ret_ref = (uintptr_t)ret_var.inner;
25305         if (ret_var.is_owned) {
25306                 ret_ref |= 1;
25307         }
25308         return ret_ref;
25309 }
25310
25311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25312         LDKChannelMonitorUpdate obj_conv;
25313         obj_conv.inner = (void*)(obj & (~1));
25314         obj_conv.is_owned = false;
25315         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25316         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
25317         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25318         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25319         CVec_u8Z_free(ret_var);
25320         return ret_arr;
25321 }
25322
25323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25324         LDKu8slice ser_ref;
25325         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25326         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25327         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
25328         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
25329         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25330         return (int64_t)ret_conv;
25331 }
25332
25333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25334         if ((this_ptr & 1) != 0) return;
25335         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25336         CHECK_ACCESS(this_ptr_ptr);
25337         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
25338         FREE((void*)this_ptr);
25339         MonitorEvent_free(this_ptr_conv);
25340 }
25341
25342 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
25343         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25344         *ret_copy = MonitorEvent_clone(arg);
25345 int64_t ret_ref = (uintptr_t)ret_copy;
25346         return ret_ref;
25347 }
25348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25349         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
25350         int64_t ret_val = MonitorEvent_clone_ptr(arg_conv);
25351         return ret_val;
25352 }
25353
25354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25355         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
25356         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25357         *ret_copy = MonitorEvent_clone(orig_conv);
25358         int64_t ret_ref = (uintptr_t)ret_copy;
25359         return ret_ref;
25360 }
25361
25362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
25363         LDKHTLCUpdate a_conv;
25364         a_conv.inner = (void*)(a & (~1));
25365         a_conv.is_owned = (a & 1) || (a == 0);
25366         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25367         a_conv = HTLCUpdate_clone(&a_conv);
25368         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25369         *ret_copy = MonitorEvent_htlcevent(a_conv);
25370         int64_t ret_ref = (uintptr_t)ret_copy;
25371         return ret_ref;
25372 }
25373
25374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
25375         LDKOutPoint a_conv;
25376         a_conv.inner = (void*)(a & (~1));
25377         a_conv.is_owned = (a & 1) || (a == 0);
25378         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25379         a_conv = OutPoint_clone(&a_conv);
25380         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25381         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
25382         int64_t ret_ref = (uintptr_t)ret_copy;
25383         return ret_ref;
25384 }
25385
25386 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) {
25387         LDKOutPoint funding_txo_conv;
25388         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25389         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25390         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25391         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25392         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25393         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
25394         int64_t ret_ref = (uintptr_t)ret_copy;
25395         return ret_ref;
25396 }
25397
25398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
25399         LDKOutPoint a_conv;
25400         a_conv.inner = (void*)(a & (~1));
25401         a_conv.is_owned = (a & 1) || (a == 0);
25402         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25403         a_conv = OutPoint_clone(&a_conv);
25404         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25405         *ret_copy = MonitorEvent_update_failed(a_conv);
25406         int64_t ret_ref = (uintptr_t)ret_copy;
25407         return ret_ref;
25408 }
25409
25410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
25411         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
25412         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
25413         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25414         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25415         CVec_u8Z_free(ret_var);
25416         return ret_arr;
25417 }
25418
25419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25420         LDKu8slice ser_ref;
25421         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25422         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25423         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
25424         *ret_conv = MonitorEvent_read(ser_ref);
25425         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25426         return (int64_t)ret_conv;
25427 }
25428
25429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25430         LDKHTLCUpdate this_obj_conv;
25431         this_obj_conv.inner = (void*)(this_obj & (~1));
25432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25434         HTLCUpdate_free(this_obj_conv);
25435 }
25436
25437 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
25438         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
25439 int64_t ret_ref = 0;
25440 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25441 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25442 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25443 ret_ref = (uintptr_t)ret_var.inner;
25444 if (ret_var.is_owned) {
25445         ret_ref |= 1;
25446 }
25447         return ret_ref;
25448 }
25449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25450         LDKHTLCUpdate arg_conv;
25451         arg_conv.inner = (void*)(arg & (~1));
25452         arg_conv.is_owned = false;
25453         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25454         int64_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
25455         return ret_val;
25456 }
25457
25458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25459         LDKHTLCUpdate orig_conv;
25460         orig_conv.inner = (void*)(orig & (~1));
25461         orig_conv.is_owned = false;
25462         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25463         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
25464         int64_t ret_ref = 0;
25465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25468         ret_ref = (uintptr_t)ret_var.inner;
25469         if (ret_var.is_owned) {
25470                 ret_ref |= 1;
25471         }
25472         return ret_ref;
25473 }
25474
25475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25476         LDKHTLCUpdate obj_conv;
25477         obj_conv.inner = (void*)(obj & (~1));
25478         obj_conv.is_owned = false;
25479         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25480         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
25481         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25482         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25483         CVec_u8Z_free(ret_var);
25484         return ret_arr;
25485 }
25486
25487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25488         LDKu8slice ser_ref;
25489         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25490         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25491         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
25492         *ret_conv = HTLCUpdate_read(ser_ref);
25493         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25494         return (int64_t)ret_conv;
25495 }
25496
25497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_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         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
25502         FREE((void*)this_ptr);
25503         Balance_free(this_ptr_conv);
25504 }
25505
25506 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
25507         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25508         *ret_copy = Balance_clone(arg);
25509 int64_t ret_ref = (uintptr_t)ret_copy;
25510         return ret_ref;
25511 }
25512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25513         LDKBalance* arg_conv = (LDKBalance*)arg;
25514         int64_t ret_val = Balance_clone_ptr(arg_conv);
25515         return ret_val;
25516 }
25517
25518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25519         LDKBalance* orig_conv = (LDKBalance*)orig;
25520         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25521         *ret_copy = Balance_clone(orig_conv);
25522         int64_t ret_ref = (uintptr_t)ret_copy;
25523         return ret_ref;
25524 }
25525
25526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
25527         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25528         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
25529         int64_t ret_ref = (uintptr_t)ret_copy;
25530         return ret_ref;
25531 }
25532
25533 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) {
25534         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25535         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
25536         int64_t ret_ref = (uintptr_t)ret_copy;
25537         return ret_ref;
25538 }
25539
25540 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) {
25541         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25542         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
25543         int64_t ret_ref = (uintptr_t)ret_copy;
25544         return ret_ref;
25545 }
25546
25547 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) {
25548         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25549         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
25550         int64_t ret_ref = (uintptr_t)ret_copy;
25551         return ret_ref;
25552 }
25553
25554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25555         LDKBalance* a_conv = (LDKBalance*)a;
25556         LDKBalance* b_conv = (LDKBalance*)b;
25557         jboolean ret_val = Balance_eq(a_conv, b_conv);
25558         return ret_val;
25559 }
25560
25561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25562         LDKChannelMonitor this_obj_conv;
25563         this_obj_conv.inner = (void*)(this_obj & (~1));
25564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25566         ChannelMonitor_free(this_obj_conv);
25567 }
25568
25569 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
25570         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
25571 int64_t ret_ref = 0;
25572 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25573 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25574 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25575 ret_ref = (uintptr_t)ret_var.inner;
25576 if (ret_var.is_owned) {
25577         ret_ref |= 1;
25578 }
25579         return ret_ref;
25580 }
25581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25582         LDKChannelMonitor arg_conv;
25583         arg_conv.inner = (void*)(arg & (~1));
25584         arg_conv.is_owned = false;
25585         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25586         int64_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
25587         return ret_val;
25588 }
25589
25590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25591         LDKChannelMonitor orig_conv;
25592         orig_conv.inner = (void*)(orig & (~1));
25593         orig_conv.is_owned = false;
25594         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25595         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
25596         int64_t ret_ref = 0;
25597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25600         ret_ref = (uintptr_t)ret_var.inner;
25601         if (ret_var.is_owned) {
25602                 ret_ref |= 1;
25603         }
25604         return ret_ref;
25605 }
25606
25607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
25608         LDKChannelMonitor obj_conv;
25609         obj_conv.inner = (void*)(obj & (~1));
25610         obj_conv.is_owned = false;
25611         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25612         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
25613         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25614         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25615         CVec_u8Z_free(ret_var);
25616         return ret_arr;
25617 }
25618
25619 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) {
25620         LDKChannelMonitor this_arg_conv;
25621         this_arg_conv.inner = (void*)(this_arg & (~1));
25622         this_arg_conv.is_owned = false;
25623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25624         LDKChannelMonitorUpdate updates_conv;
25625         updates_conv.inner = (void*)(updates & (~1));
25626         updates_conv.is_owned = false;
25627         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
25628         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25629         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
25630         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
25631         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25632         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
25633         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
25634         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25635         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
25636         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
25637         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
25638         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
25639         return (int64_t)ret_conv;
25640 }
25641
25642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
25643         LDKChannelMonitor this_arg_conv;
25644         this_arg_conv.inner = (void*)(this_arg & (~1));
25645         this_arg_conv.is_owned = false;
25646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25647         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
25648         return ret_val;
25649 }
25650
25651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
25652         LDKChannelMonitor this_arg_conv;
25653         this_arg_conv.inner = (void*)(this_arg & (~1));
25654         this_arg_conv.is_owned = false;
25655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25656         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
25657         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
25658         return ((int64_t)ret_conv);
25659 }
25660
25661 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
25662         LDKChannelMonitor this_arg_conv;
25663         this_arg_conv.inner = (void*)(this_arg & (~1));
25664         this_arg_conv.is_owned = false;
25665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25666         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
25667         int64_tArray ret_arr = NULL;
25668         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25669         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25670         for (size_t o = 0; o < ret_var.datalen; o++) {
25671                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
25672                 *ret_conv_40_conv = ret_var.data[o];
25673                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
25674         }
25675         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25676         FREE(ret_var.data);
25677         return ret_arr;
25678 }
25679
25680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
25681         LDKChannelMonitor this_arg_conv;
25682         this_arg_conv.inner = (void*)(this_arg & (~1));
25683         this_arg_conv.is_owned = false;
25684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25685         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
25686         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
25687         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
25688         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
25689 }
25690
25691 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
25692         LDKChannelMonitor this_arg_conv;
25693         this_arg_conv.inner = (void*)(this_arg & (~1));
25694         this_arg_conv.is_owned = false;
25695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25696         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
25697         int64_tArray ret_arr = NULL;
25698         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25699         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25700         for (size_t o = 0; o < ret_var.datalen; o++) {
25701                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25702                 *ret_conv_14_copy = ret_var.data[o];
25703                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
25704                 ret_arr_ptr[o] = ret_conv_14_ref;
25705         }
25706         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25707         FREE(ret_var.data);
25708         return ret_arr;
25709 }
25710
25711 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
25712         LDKChannelMonitor this_arg_conv;
25713         this_arg_conv.inner = (void*)(this_arg & (~1));
25714         this_arg_conv.is_owned = false;
25715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25716         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
25717         int64_tArray ret_arr = NULL;
25718         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25719         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25720         for (size_t h = 0; h < ret_var.datalen; h++) {
25721                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25722                 *ret_conv_7_copy = ret_var.data[h];
25723                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
25724                 ret_arr_ptr[h] = ret_conv_7_ref;
25725         }
25726         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25727         FREE(ret_var.data);
25728         return ret_arr;
25729 }
25730
25731 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) {
25732         LDKChannelMonitor this_arg_conv;
25733         this_arg_conv.inner = (void*)(this_arg & (~1));
25734         this_arg_conv.is_owned = false;
25735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25736         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25737         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
25738         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
25739         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
25740         jobjectArray ret_arr = NULL;
25741         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
25742         ;
25743         for (size_t i = 0; i < ret_var.datalen; i++) {
25744                 LDKTransaction ret_conv_8_var = ret_var.data[i];
25745                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
25746                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
25747                 Transaction_free(ret_conv_8_var);
25748                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
25749         }
25750         
25751         FREE(ret_var.data);
25752         return ret_arr;
25753 }
25754
25755 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) {
25756         LDKChannelMonitor this_arg_conv;
25757         this_arg_conv.inner = (void*)(this_arg & (~1));
25758         this_arg_conv.is_owned = false;
25759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25760         unsigned char header_arr[80];
25761         CHECK((*env)->GetArrayLength(env, header) == 80);
25762         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
25763         unsigned char (*header_ref)[80] = &header_arr;
25764         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
25765         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
25766         if (txdata_constr.datalen > 0)
25767                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
25768         else
25769                 txdata_constr.data = NULL;
25770         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
25771         for (size_t c = 0; c < txdata_constr.datalen; c++) {
25772                 int64_t txdata_conv_28 = txdata_vals[c];
25773                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
25774                 CHECK_ACCESS(txdata_conv_28_ptr);
25775                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
25776                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
25777                 txdata_constr.data[c] = txdata_conv_28_conv;
25778         }
25779         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
25780         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25781         CHECK_ACCESS(broadcaster_ptr);
25782         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25783         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25784                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25785                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25786         }
25787         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25788         CHECK_ACCESS(fee_estimator_ptr);
25789         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25790         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25791                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25792                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25793         }
25794         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25795         CHECK_ACCESS(logger_ptr);
25796         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25797         if (logger_conv.free == LDKLogger_JCalls_free) {
25798                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25799                 LDKLogger_JCalls_cloned(&logger_conv);
25800         }
25801         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);
25802         int64_tArray ret_arr = NULL;
25803         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25804         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25805         for (size_t n = 0; n < ret_var.datalen; n++) {
25806                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
25807                 *ret_conv_39_conv = ret_var.data[n];
25808                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
25809         }
25810         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25811         FREE(ret_var.data);
25812         return ret_arr;
25813 }
25814
25815 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) {
25816         LDKChannelMonitor this_arg_conv;
25817         this_arg_conv.inner = (void*)(this_arg & (~1));
25818         this_arg_conv.is_owned = false;
25819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25820         unsigned char header_arr[80];
25821         CHECK((*env)->GetArrayLength(env, header) == 80);
25822         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
25823         unsigned char (*header_ref)[80] = &header_arr;
25824         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25825         CHECK_ACCESS(broadcaster_ptr);
25826         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25827         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25828                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25829                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25830         }
25831         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25832         CHECK_ACCESS(fee_estimator_ptr);
25833         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25834         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25835                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25836                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25837         }
25838         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25839         CHECK_ACCESS(logger_ptr);
25840         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25841         if (logger_conv.free == LDKLogger_JCalls_free) {
25842                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25843                 LDKLogger_JCalls_cloned(&logger_conv);
25844         }
25845         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
25846 }
25847
25848 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) {
25849         LDKChannelMonitor this_arg_conv;
25850         this_arg_conv.inner = (void*)(this_arg & (~1));
25851         this_arg_conv.is_owned = false;
25852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25853         unsigned char header_arr[80];
25854         CHECK((*env)->GetArrayLength(env, header) == 80);
25855         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
25856         unsigned char (*header_ref)[80] = &header_arr;
25857         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
25858         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
25859         if (txdata_constr.datalen > 0)
25860                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
25861         else
25862                 txdata_constr.data = NULL;
25863         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
25864         for (size_t c = 0; c < txdata_constr.datalen; c++) {
25865                 int64_t txdata_conv_28 = txdata_vals[c];
25866                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
25867                 CHECK_ACCESS(txdata_conv_28_ptr);
25868                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
25869                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
25870                 txdata_constr.data[c] = txdata_conv_28_conv;
25871         }
25872         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
25873         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25874         CHECK_ACCESS(broadcaster_ptr);
25875         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25876         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25877                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25878                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25879         }
25880         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25881         CHECK_ACCESS(fee_estimator_ptr);
25882         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25883         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25884                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25885                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25886         }
25887         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25888         CHECK_ACCESS(logger_ptr);
25889         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25890         if (logger_conv.free == LDKLogger_JCalls_free) {
25891                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25892                 LDKLogger_JCalls_cloned(&logger_conv);
25893         }
25894         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);
25895         int64_tArray ret_arr = NULL;
25896         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25897         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25898         for (size_t n = 0; n < ret_var.datalen; n++) {
25899                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
25900                 *ret_conv_39_conv = ret_var.data[n];
25901                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
25902         }
25903         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25904         FREE(ret_var.data);
25905         return ret_arr;
25906 }
25907
25908 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) {
25909         LDKChannelMonitor this_arg_conv;
25910         this_arg_conv.inner = (void*)(this_arg & (~1));
25911         this_arg_conv.is_owned = false;
25912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25913         unsigned char txid_arr[32];
25914         CHECK((*env)->GetArrayLength(env, txid) == 32);
25915         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
25916         unsigned char (*txid_ref)[32] = &txid_arr;
25917         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25918         CHECK_ACCESS(broadcaster_ptr);
25919         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25920         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25921                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25922                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25923         }
25924         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25925         CHECK_ACCESS(fee_estimator_ptr);
25926         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25927         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25928                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25929                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25930         }
25931         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25932         CHECK_ACCESS(logger_ptr);
25933         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25934         if (logger_conv.free == LDKLogger_JCalls_free) {
25935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25936                 LDKLogger_JCalls_cloned(&logger_conv);
25937         }
25938         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
25939 }
25940
25941 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) {
25942         LDKChannelMonitor this_arg_conv;
25943         this_arg_conv.inner = (void*)(this_arg & (~1));
25944         this_arg_conv.is_owned = false;
25945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25946         unsigned char header_arr[80];
25947         CHECK((*env)->GetArrayLength(env, header) == 80);
25948         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
25949         unsigned char (*header_ref)[80] = &header_arr;
25950         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25951         CHECK_ACCESS(broadcaster_ptr);
25952         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25953         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25954                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25955                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25956         }
25957         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25958         CHECK_ACCESS(fee_estimator_ptr);
25959         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25960         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25961                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25962                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25963         }
25964         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25965         CHECK_ACCESS(logger_ptr);
25966         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25967         if (logger_conv.free == LDKLogger_JCalls_free) {
25968                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25969                 LDKLogger_JCalls_cloned(&logger_conv);
25970         }
25971         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
25972         int64_tArray ret_arr = NULL;
25973         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25974         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25975         for (size_t n = 0; n < ret_var.datalen; n++) {
25976                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
25977                 *ret_conv_39_conv = ret_var.data[n];
25978                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
25979         }
25980         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25981         FREE(ret_var.data);
25982         return ret_arr;
25983 }
25984
25985 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
25986         LDKChannelMonitor this_arg_conv;
25987         this_arg_conv.inner = (void*)(this_arg & (~1));
25988         this_arg_conv.is_owned = false;
25989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25990         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
25991         jobjectArray ret_arr = NULL;
25992         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
25993         ;
25994         for (size_t i = 0; i < ret_var.datalen; i++) {
25995                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
25996                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
25997                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
25998         }
25999         
26000         FREE(ret_var.data);
26001         return ret_arr;
26002 }
26003
26004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
26005         LDKChannelMonitor this_arg_conv;
26006         this_arg_conv.inner = (void*)(this_arg & (~1));
26007         this_arg_conv.is_owned = false;
26008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26009         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
26010         int64_t ret_ref = 0;
26011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26014         ret_ref = (uintptr_t)ret_var.inner;
26015         if (ret_var.is_owned) {
26016                 ret_ref |= 1;
26017         }
26018         return ret_ref;
26019 }
26020
26021 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
26022         LDKChannelMonitor this_arg_conv;
26023         this_arg_conv.inner = (void*)(this_arg & (~1));
26024         this_arg_conv.is_owned = false;
26025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26026         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
26027         int64_tArray ret_arr = NULL;
26028         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26029         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26030         for (size_t j = 0; j < ret_var.datalen; j++) {
26031                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26032                 *ret_conv_9_copy = ret_var.data[j];
26033                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
26034                 ret_arr_ptr[j] = ret_conv_9_ref;
26035         }
26036         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26037         FREE(ret_var.data);
26038         return ret_arr;
26039 }
26040
26041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
26042         LDKu8slice ser_ref;
26043         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26044         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26045         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
26046         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
26047         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
26048         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
26049         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
26050         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26051         return (int64_t)ret_conv;
26052 }
26053
26054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26055         LDKOutPoint this_obj_conv;
26056         this_obj_conv.inner = (void*)(this_obj & (~1));
26057         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26059         OutPoint_free(this_obj_conv);
26060 }
26061
26062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
26063         LDKOutPoint 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26068         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
26069         return ret_arr;
26070 }
26071
26072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26073         LDKOutPoint this_ptr_conv;
26074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26075         this_ptr_conv.is_owned = false;
26076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26077         LDKThirtyTwoBytes val_ref;
26078         CHECK((*env)->GetArrayLength(env, val) == 32);
26079         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26080         OutPoint_set_txid(&this_ptr_conv, val_ref);
26081 }
26082
26083 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
26084         LDKOutPoint this_ptr_conv;
26085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26086         this_ptr_conv.is_owned = false;
26087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26088         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
26089         return ret_val;
26090 }
26091
26092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26093         LDKOutPoint this_ptr_conv;
26094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26095         this_ptr_conv.is_owned = false;
26096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26097         OutPoint_set_index(&this_ptr_conv, val);
26098 }
26099
26100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
26101         LDKThirtyTwoBytes txid_arg_ref;
26102         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
26103         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
26104         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
26105         int64_t ret_ref = 0;
26106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26109         ret_ref = (uintptr_t)ret_var.inner;
26110         if (ret_var.is_owned) {
26111                 ret_ref |= 1;
26112         }
26113         return ret_ref;
26114 }
26115
26116 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
26117         LDKOutPoint ret_var = OutPoint_clone(arg);
26118 int64_t ret_ref = 0;
26119 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26120 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26121 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26122 ret_ref = (uintptr_t)ret_var.inner;
26123 if (ret_var.is_owned) {
26124         ret_ref |= 1;
26125 }
26126         return ret_ref;
26127 }
26128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26129         LDKOutPoint arg_conv;
26130         arg_conv.inner = (void*)(arg & (~1));
26131         arg_conv.is_owned = false;
26132         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26133         int64_t ret_val = OutPoint_clone_ptr(&arg_conv);
26134         return ret_val;
26135 }
26136
26137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26138         LDKOutPoint orig_conv;
26139         orig_conv.inner = (void*)(orig & (~1));
26140         orig_conv.is_owned = false;
26141         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26142         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
26143         int64_t ret_ref = 0;
26144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26147         ret_ref = (uintptr_t)ret_var.inner;
26148         if (ret_var.is_owned) {
26149                 ret_ref |= 1;
26150         }
26151         return ret_ref;
26152 }
26153
26154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26155         LDKOutPoint a_conv;
26156         a_conv.inner = (void*)(a & (~1));
26157         a_conv.is_owned = false;
26158         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26159         LDKOutPoint b_conv;
26160         b_conv.inner = (void*)(b & (~1));
26161         b_conv.is_owned = false;
26162         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26163         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
26164         return ret_val;
26165 }
26166
26167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
26168         LDKOutPoint o_conv;
26169         o_conv.inner = (void*)(o & (~1));
26170         o_conv.is_owned = false;
26171         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26172         int64_t ret_val = OutPoint_hash(&o_conv);
26173         return ret_val;
26174 }
26175
26176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26177         LDKOutPoint this_arg_conv;
26178         this_arg_conv.inner = (void*)(this_arg & (~1));
26179         this_arg_conv.is_owned = false;
26180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26181         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
26183         return ret_arr;
26184 }
26185
26186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
26187         LDKOutPoint obj_conv;
26188         obj_conv.inner = (void*)(obj & (~1));
26189         obj_conv.is_owned = false;
26190         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26191         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
26192         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26193         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26194         CVec_u8Z_free(ret_var);
26195         return ret_arr;
26196 }
26197
26198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26199         LDKu8slice ser_ref;
26200         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26201         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26202         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
26203         *ret_conv = OutPoint_read(ser_ref);
26204         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26205         return (int64_t)ret_conv;
26206 }
26207
26208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26209         LDKDelayedPaymentOutputDescriptor this_obj_conv;
26210         this_obj_conv.inner = (void*)(this_obj & (~1));
26211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26213         DelayedPaymentOutputDescriptor_free(this_obj_conv);
26214 }
26215
26216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26217         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26219         this_ptr_conv.is_owned = false;
26220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26221         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26222         int64_t ret_ref = 0;
26223         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26224         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26226         ret_ref = (uintptr_t)ret_var.inner;
26227         if (ret_var.is_owned) {
26228                 ret_ref |= 1;
26229         }
26230         return ret_ref;
26231 }
26232
26233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26234         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26236         this_ptr_conv.is_owned = false;
26237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26238         LDKOutPoint val_conv;
26239         val_conv.inner = (void*)(val & (~1));
26240         val_conv.is_owned = (val & 1) || (val == 0);
26241         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26242         val_conv = OutPoint_clone(&val_conv);
26243         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26244 }
26245
26246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26247         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26249         this_ptr_conv.is_owned = false;
26250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26251         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26252         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
26253         return ret_arr;
26254 }
26255
26256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26257         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26259         this_ptr_conv.is_owned = false;
26260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26261         LDKPublicKey val_ref;
26262         CHECK((*env)->GetArrayLength(env, val) == 33);
26263         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26264         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
26265 }
26266
26267 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26268         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26270         this_ptr_conv.is_owned = false;
26271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26272         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
26273         return ret_val;
26274 }
26275
26276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26277         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26279         this_ptr_conv.is_owned = false;
26280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26281         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
26282 }
26283
26284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26285         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26287         this_ptr_conv.is_owned = false;
26288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26289         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26290         CHECK_ACCESS(val_ptr);
26291         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26292         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26293         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26294 }
26295
26296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26297         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26299         this_ptr_conv.is_owned = false;
26300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26301         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
26303         return ret_arr;
26304 }
26305
26306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26307         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26309         this_ptr_conv.is_owned = false;
26310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26311         LDKPublicKey val_ref;
26312         CHECK((*env)->GetArrayLength(env, val) == 33);
26313         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26314         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
26315 }
26316
26317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26318         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26320         this_ptr_conv.is_owned = false;
26321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26322         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26323         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26324         return ret_arr;
26325 }
26326
26327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26328         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26330         this_ptr_conv.is_owned = false;
26331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26332         LDKThirtyTwoBytes val_ref;
26333         CHECK((*env)->GetArrayLength(env, val) == 32);
26334         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26335         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26336 }
26337
26338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26339         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26341         this_ptr_conv.is_owned = false;
26342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26343         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26344         return ret_val;
26345 }
26346
26347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26348         LDKDelayedPaymentOutputDescriptor 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         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26353 }
26354
26355 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) {
26356         LDKOutPoint outpoint_arg_conv;
26357         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26358         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26359         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26360         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26361         LDKPublicKey per_commitment_point_arg_ref;
26362         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
26363         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
26364         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26365         CHECK_ACCESS(output_arg_ptr);
26366         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26367         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26368         LDKPublicKey revocation_pubkey_arg_ref;
26369         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
26370         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
26371         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26372         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26373         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26374         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);
26375         int64_t ret_ref = 0;
26376         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26377         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26379         ret_ref = (uintptr_t)ret_var.inner;
26380         if (ret_var.is_owned) {
26381                 ret_ref |= 1;
26382         }
26383         return ret_ref;
26384 }
26385
26386 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
26387         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
26388 int64_t ret_ref = 0;
26389 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26390 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26391 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26392 ret_ref = (uintptr_t)ret_var.inner;
26393 if (ret_var.is_owned) {
26394         ret_ref |= 1;
26395 }
26396         return ret_ref;
26397 }
26398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26399         LDKDelayedPaymentOutputDescriptor arg_conv;
26400         arg_conv.inner = (void*)(arg & (~1));
26401         arg_conv.is_owned = false;
26402         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26403         int64_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
26404         return ret_val;
26405 }
26406
26407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26408         LDKDelayedPaymentOutputDescriptor orig_conv;
26409         orig_conv.inner = (void*)(orig & (~1));
26410         orig_conv.is_owned = false;
26411         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26412         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
26413         int64_t ret_ref = 0;
26414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26417         ret_ref = (uintptr_t)ret_var.inner;
26418         if (ret_var.is_owned) {
26419                 ret_ref |= 1;
26420         }
26421         return ret_ref;
26422 }
26423
26424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26425         LDKDelayedPaymentOutputDescriptor obj_conv;
26426         obj_conv.inner = (void*)(obj & (~1));
26427         obj_conv.is_owned = false;
26428         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26429         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
26430         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26431         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26432         CVec_u8Z_free(ret_var);
26433         return ret_arr;
26434 }
26435
26436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26437         LDKu8slice ser_ref;
26438         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26439         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26440         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
26441         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
26442         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26443         return (int64_t)ret_conv;
26444 }
26445
26446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26447         LDKStaticPaymentOutputDescriptor this_obj_conv;
26448         this_obj_conv.inner = (void*)(this_obj & (~1));
26449         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26451         StaticPaymentOutputDescriptor_free(this_obj_conv);
26452 }
26453
26454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26455         LDKStaticPaymentOutputDescriptor 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         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26460         int64_t ret_ref = 0;
26461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26464         ret_ref = (uintptr_t)ret_var.inner;
26465         if (ret_var.is_owned) {
26466                 ret_ref |= 1;
26467         }
26468         return ret_ref;
26469 }
26470
26471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26472         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26474         this_ptr_conv.is_owned = false;
26475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26476         LDKOutPoint val_conv;
26477         val_conv.inner = (void*)(val & (~1));
26478         val_conv.is_owned = (val & 1) || (val == 0);
26479         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26480         val_conv = OutPoint_clone(&val_conv);
26481         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26482 }
26483
26484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26485         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26487         this_ptr_conv.is_owned = false;
26488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26489         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26490         CHECK_ACCESS(val_ptr);
26491         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26492         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26493         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26494 }
26495
26496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26497         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26499         this_ptr_conv.is_owned = false;
26500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26501         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26502         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26503         return ret_arr;
26504 }
26505
26506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26507         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26509         this_ptr_conv.is_owned = false;
26510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26511         LDKThirtyTwoBytes val_ref;
26512         CHECK((*env)->GetArrayLength(env, val) == 32);
26513         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26514         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26515 }
26516
26517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26518         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26520         this_ptr_conv.is_owned = false;
26521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26522         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26523         return ret_val;
26524 }
26525
26526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26527         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26529         this_ptr_conv.is_owned = false;
26530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26531         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26532 }
26533
26534 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) {
26535         LDKOutPoint outpoint_arg_conv;
26536         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26537         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26538         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26539         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26540         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26541         CHECK_ACCESS(output_arg_ptr);
26542         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26543         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26544         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26545         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26546         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26547         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
26548         int64_t ret_ref = 0;
26549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26552         ret_ref = (uintptr_t)ret_var.inner;
26553         if (ret_var.is_owned) {
26554                 ret_ref |= 1;
26555         }
26556         return ret_ref;
26557 }
26558
26559 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
26560         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
26561 int64_t ret_ref = 0;
26562 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26563 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26564 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26565 ret_ref = (uintptr_t)ret_var.inner;
26566 if (ret_var.is_owned) {
26567         ret_ref |= 1;
26568 }
26569         return ret_ref;
26570 }
26571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26572         LDKStaticPaymentOutputDescriptor arg_conv;
26573         arg_conv.inner = (void*)(arg & (~1));
26574         arg_conv.is_owned = false;
26575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26576         int64_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
26577         return ret_val;
26578 }
26579
26580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26581         LDKStaticPaymentOutputDescriptor orig_conv;
26582         orig_conv.inner = (void*)(orig & (~1));
26583         orig_conv.is_owned = false;
26584         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26585         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
26586         int64_t ret_ref = 0;
26587         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26588         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26590         ret_ref = (uintptr_t)ret_var.inner;
26591         if (ret_var.is_owned) {
26592                 ret_ref |= 1;
26593         }
26594         return ret_ref;
26595 }
26596
26597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26598         LDKStaticPaymentOutputDescriptor obj_conv;
26599         obj_conv.inner = (void*)(obj & (~1));
26600         obj_conv.is_owned = false;
26601         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26602         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
26603         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26604         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26605         CVec_u8Z_free(ret_var);
26606         return ret_arr;
26607 }
26608
26609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26610         LDKu8slice ser_ref;
26611         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26612         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26613         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
26614         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
26615         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26616         return (int64_t)ret_conv;
26617 }
26618
26619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26620         if ((this_ptr & 1) != 0) return;
26621         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26622         CHECK_ACCESS(this_ptr_ptr);
26623         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
26624         FREE((void*)this_ptr);
26625         SpendableOutputDescriptor_free(this_ptr_conv);
26626 }
26627
26628 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
26629         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26630         *ret_copy = SpendableOutputDescriptor_clone(arg);
26631 int64_t ret_ref = (uintptr_t)ret_copy;
26632         return ret_ref;
26633 }
26634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26635         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
26636         int64_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
26637         return ret_val;
26638 }
26639
26640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26641         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
26642         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26643         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
26644         int64_t ret_ref = (uintptr_t)ret_copy;
26645         return ret_ref;
26646 }
26647
26648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
26649         LDKOutPoint outpoint_conv;
26650         outpoint_conv.inner = (void*)(outpoint & (~1));
26651         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
26652         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
26653         outpoint_conv = OutPoint_clone(&outpoint_conv);
26654         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
26655         CHECK_ACCESS(output_ptr);
26656         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
26657         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
26658         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26659         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
26660         int64_t ret_ref = (uintptr_t)ret_copy;
26661         return ret_ref;
26662 }
26663
26664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
26665         LDKDelayedPaymentOutputDescriptor a_conv;
26666         a_conv.inner = (void*)(a & (~1));
26667         a_conv.is_owned = (a & 1) || (a == 0);
26668         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26669         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
26670         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26671         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
26672         int64_t ret_ref = (uintptr_t)ret_copy;
26673         return ret_ref;
26674 }
26675
26676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
26677         LDKStaticPaymentOutputDescriptor a_conv;
26678         a_conv.inner = (void*)(a & (~1));
26679         a_conv.is_owned = (a & 1) || (a == 0);
26680         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26681         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
26682         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26683         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
26684         int64_t ret_ref = (uintptr_t)ret_copy;
26685         return ret_ref;
26686 }
26687
26688 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26689         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
26690         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
26691         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26692         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26693         CVec_u8Z_free(ret_var);
26694         return ret_arr;
26695 }
26696
26697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26698         LDKu8slice ser_ref;
26699         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26700         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26701         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
26702         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
26703         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26704         return (int64_t)ret_conv;
26705 }
26706
26707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26708         if ((this_ptr & 1) != 0) return;
26709         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26710         CHECK_ACCESS(this_ptr_ptr);
26711         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
26712         FREE((void*)this_ptr);
26713         BaseSign_free(this_ptr_conv);
26714 }
26715
26716 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
26717         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
26718         *ret_ret = Sign_clone(arg);
26719         return (int64_t)ret_ret;
26720 }
26721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26722         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
26723         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
26724         LDKSign* arg_conv = (LDKSign*)arg_ptr;
26725         int64_t ret_val = Sign_clone_ptr(arg_conv);
26726         return ret_val;
26727 }
26728
26729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26730         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
26731         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
26732         LDKSign* orig_conv = (LDKSign*)orig_ptr;
26733         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
26734         *ret_ret = Sign_clone(orig_conv);
26735         return (int64_t)ret_ret;
26736 }
26737
26738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26739         if ((this_ptr & 1) != 0) return;
26740         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26741         CHECK_ACCESS(this_ptr_ptr);
26742         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
26743         FREE((void*)this_ptr);
26744         Sign_free(this_ptr_conv);
26745 }
26746
26747 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26748         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
26749         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
26750         return ret_conv;
26751 }
26752
26753 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
26754         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
26755         return ret_conv;
26756 }
26757
26758 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
26759         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
26760         return ret_conv;
26761 }
26762
26763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26764         if ((this_ptr & 1) != 0) return;
26765         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26766         CHECK_ACCESS(this_ptr_ptr);
26767         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
26768         FREE((void*)this_ptr);
26769         KeysInterface_free(this_ptr_conv);
26770 }
26771
26772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26773         LDKInMemorySigner this_obj_conv;
26774         this_obj_conv.inner = (void*)(this_obj & (~1));
26775         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26777         InMemorySigner_free(this_obj_conv);
26778 }
26779
26780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26781         LDKInMemorySigner this_ptr_conv;
26782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26783         this_ptr_conv.is_owned = false;
26784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26785         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26786         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
26787         return ret_arr;
26788 }
26789
26790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26791         LDKInMemorySigner this_ptr_conv;
26792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26793         this_ptr_conv.is_owned = false;
26794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26795         LDKSecretKey val_ref;
26796         CHECK((*env)->GetArrayLength(env, val) == 32);
26797         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26798         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
26799 }
26800
26801 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26802         LDKInMemorySigner this_ptr_conv;
26803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26804         this_ptr_conv.is_owned = false;
26805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26806         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26807         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
26808         return ret_arr;
26809 }
26810
26811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26812         LDKInMemorySigner this_ptr_conv;
26813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26814         this_ptr_conv.is_owned = false;
26815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26816         LDKSecretKey val_ref;
26817         CHECK((*env)->GetArrayLength(env, val) == 32);
26818         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26819         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
26820 }
26821
26822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26823         LDKInMemorySigner this_ptr_conv;
26824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26825         this_ptr_conv.is_owned = false;
26826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26827         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26828         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
26829         return ret_arr;
26830 }
26831
26832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26833         LDKInMemorySigner this_ptr_conv;
26834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26835         this_ptr_conv.is_owned = false;
26836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26837         LDKSecretKey val_ref;
26838         CHECK((*env)->GetArrayLength(env, val) == 32);
26839         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26840         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
26841 }
26842
26843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26844         LDKInMemorySigner this_ptr_conv;
26845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26846         this_ptr_conv.is_owned = false;
26847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26848         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26849         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
26850         return ret_arr;
26851 }
26852
26853 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) {
26854         LDKInMemorySigner this_ptr_conv;
26855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26856         this_ptr_conv.is_owned = false;
26857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26858         LDKSecretKey val_ref;
26859         CHECK((*env)->GetArrayLength(env, val) == 32);
26860         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26861         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
26862 }
26863
26864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26865         LDKInMemorySigner this_ptr_conv;
26866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26867         this_ptr_conv.is_owned = false;
26868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26869         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26870         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
26871         return ret_arr;
26872 }
26873
26874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26875         LDKInMemorySigner this_ptr_conv;
26876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26877         this_ptr_conv.is_owned = false;
26878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26879         LDKSecretKey val_ref;
26880         CHECK((*env)->GetArrayLength(env, val) == 32);
26881         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26882         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
26883 }
26884
26885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
26886         LDKInMemorySigner this_ptr_conv;
26887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26888         this_ptr_conv.is_owned = false;
26889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26890         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26891         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
26892         return ret_arr;
26893 }
26894
26895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26896         LDKInMemorySigner this_ptr_conv;
26897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26898         this_ptr_conv.is_owned = false;
26899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26900         LDKThirtyTwoBytes val_ref;
26901         CHECK((*env)->GetArrayLength(env, val) == 32);
26902         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26903         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
26904 }
26905
26906 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
26907         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
26908 int64_t ret_ref = 0;
26909 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26910 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26911 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26912 ret_ref = (uintptr_t)ret_var.inner;
26913 if (ret_var.is_owned) {
26914         ret_ref |= 1;
26915 }
26916         return ret_ref;
26917 }
26918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26919         LDKInMemorySigner arg_conv;
26920         arg_conv.inner = (void*)(arg & (~1));
26921         arg_conv.is_owned = false;
26922         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26923         int64_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
26924         return ret_val;
26925 }
26926
26927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26928         LDKInMemorySigner orig_conv;
26929         orig_conv.inner = (void*)(orig & (~1));
26930         orig_conv.is_owned = false;
26931         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26932         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
26933         int64_t ret_ref = 0;
26934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26937         ret_ref = (uintptr_t)ret_var.inner;
26938         if (ret_var.is_owned) {
26939                 ret_ref |= 1;
26940         }
26941         return ret_ref;
26942 }
26943
26944 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) {
26945         LDKSecretKey node_secret_ref;
26946         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
26947         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
26948         LDKSecretKey funding_key_ref;
26949         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
26950         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
26951         LDKSecretKey revocation_base_key_ref;
26952         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
26953         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
26954         LDKSecretKey payment_key_ref;
26955         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
26956         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
26957         LDKSecretKey delayed_payment_base_key_ref;
26958         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
26959         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
26960         LDKSecretKey htlc_base_key_ref;
26961         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
26962         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
26963         LDKThirtyTwoBytes commitment_seed_ref;
26964         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
26965         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
26966         LDKThirtyTwoBytes channel_keys_id_ref;
26967         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
26968         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
26969         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);
26970         int64_t ret_ref = 0;
26971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26974         ret_ref = (uintptr_t)ret_var.inner;
26975         if (ret_var.is_owned) {
26976                 ret_ref |= 1;
26977         }
26978         return ret_ref;
26979 }
26980
26981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
26982         LDKInMemorySigner this_arg_conv;
26983         this_arg_conv.inner = (void*)(this_arg & (~1));
26984         this_arg_conv.is_owned = false;
26985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26986         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
26987         int64_t ret_ref = 0;
26988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26991         ret_ref = (uintptr_t)ret_var.inner;
26992         if (ret_var.is_owned) {
26993                 ret_ref |= 1;
26994         }
26995         return ret_ref;
26996 }
26997
26998 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
26999         LDKInMemorySigner this_arg_conv;
27000         this_arg_conv.inner = (void*)(this_arg & (~1));
27001         this_arg_conv.is_owned = false;
27002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27003         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
27004         return ret_val;
27005 }
27006
27007 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
27008         LDKInMemorySigner this_arg_conv;
27009         this_arg_conv.inner = (void*)(this_arg & (~1));
27010         this_arg_conv.is_owned = false;
27011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27012         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
27013         return ret_val;
27014 }
27015
27016 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
27017         LDKInMemorySigner this_arg_conv;
27018         this_arg_conv.inner = (void*)(this_arg & (~1));
27019         this_arg_conv.is_owned = false;
27020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27021         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
27022         return ret_val;
27023 }
27024
27025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
27026         LDKInMemorySigner this_arg_conv;
27027         this_arg_conv.inner = (void*)(this_arg & (~1));
27028         this_arg_conv.is_owned = false;
27029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27030         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
27031         int64_t ret_ref = 0;
27032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27035         ret_ref = (uintptr_t)ret_var.inner;
27036         if (ret_var.is_owned) {
27037                 ret_ref |= 1;
27038         }
27039         return ret_ref;
27040 }
27041
27042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
27043         LDKInMemorySigner this_arg_conv;
27044         this_arg_conv.inner = (void*)(this_arg & (~1));
27045         this_arg_conv.is_owned = false;
27046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27047         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
27048         int64_t ret_ref = 0;
27049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27052         ret_ref = (uintptr_t)ret_var.inner;
27053         if (ret_var.is_owned) {
27054                 ret_ref |= 1;
27055         }
27056         return ret_ref;
27057 }
27058
27059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
27060         LDKInMemorySigner this_arg_conv;
27061         this_arg_conv.inner = (void*)(this_arg & (~1));
27062         this_arg_conv.is_owned = false;
27063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27064         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
27065         return ret_val;
27066 }
27067
27068 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) {
27069         LDKInMemorySigner this_arg_conv;
27070         this_arg_conv.inner = (void*)(this_arg & (~1));
27071         this_arg_conv.is_owned = false;
27072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27073         LDKTransaction spend_tx_ref;
27074         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27075         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27076         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27077         spend_tx_ref.data_is_owned = true;
27078         LDKStaticPaymentOutputDescriptor descriptor_conv;
27079         descriptor_conv.inner = (void*)(descriptor & (~1));
27080         descriptor_conv.is_owned = false;
27081         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27082         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27083         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27084         return (int64_t)ret_conv;
27085 }
27086
27087 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) {
27088         LDKInMemorySigner this_arg_conv;
27089         this_arg_conv.inner = (void*)(this_arg & (~1));
27090         this_arg_conv.is_owned = false;
27091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27092         LDKTransaction spend_tx_ref;
27093         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27094         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27095         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27096         spend_tx_ref.data_is_owned = true;
27097         LDKDelayedPaymentOutputDescriptor descriptor_conv;
27098         descriptor_conv.inner = (void*)(descriptor & (~1));
27099         descriptor_conv.is_owned = false;
27100         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27101         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27102         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27103         return (int64_t)ret_conv;
27104 }
27105
27106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
27107         LDKInMemorySigner this_arg_conv;
27108         this_arg_conv.inner = (void*)(this_arg & (~1));
27109         this_arg_conv.is_owned = false;
27110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27111         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
27112         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
27113         return (int64_t)ret_ret;
27114 }
27115
27116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
27117         LDKInMemorySigner this_arg_conv;
27118         this_arg_conv.inner = (void*)(this_arg & (~1));
27119         this_arg_conv.is_owned = false;
27120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27121         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27122         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
27123         return (int64_t)ret_ret;
27124 }
27125
27126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
27127         LDKInMemorySigner obj_conv;
27128         obj_conv.inner = (void*)(obj & (~1));
27129         obj_conv.is_owned = false;
27130         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27131         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
27132         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27133         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27134         CVec_u8Z_free(ret_var);
27135         return ret_arr;
27136 }
27137
27138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
27139         LDKu8slice ser_ref;
27140         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27141         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27142         LDKSecretKey arg_ref;
27143         CHECK((*env)->GetArrayLength(env, arg) == 32);
27144         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
27145         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
27146         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
27147         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27148         return (int64_t)ret_conv;
27149 }
27150
27151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27152         LDKKeysManager this_obj_conv;
27153         this_obj_conv.inner = (void*)(this_obj & (~1));
27154         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27156         KeysManager_free(this_obj_conv);
27157 }
27158
27159 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) {
27160         unsigned char seed_arr[32];
27161         CHECK((*env)->GetArrayLength(env, seed) == 32);
27162         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27163         unsigned char (*seed_ref)[32] = &seed_arr;
27164         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
27165         int64_t ret_ref = 0;
27166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27169         ret_ref = (uintptr_t)ret_var.inner;
27170         if (ret_var.is_owned) {
27171                 ret_ref |= 1;
27172         }
27173         return ret_ref;
27174 }
27175
27176 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) {
27177         LDKKeysManager this_arg_conv;
27178         this_arg_conv.inner = (void*)(this_arg & (~1));
27179         this_arg_conv.is_owned = false;
27180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27181         unsigned char params_arr[32];
27182         CHECK((*env)->GetArrayLength(env, params) == 32);
27183         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27184         unsigned char (*params_ref)[32] = &params_arr;
27185         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27186         int64_t ret_ref = 0;
27187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27190         ret_ref = (uintptr_t)ret_var.inner;
27191         if (ret_var.is_owned) {
27192                 ret_ref |= 1;
27193         }
27194         return ret_ref;
27195 }
27196
27197 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) {
27198         LDKKeysManager this_arg_conv;
27199         this_arg_conv.inner = (void*)(this_arg & (~1));
27200         this_arg_conv.is_owned = false;
27201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27202         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27203         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27204         if (descriptors_constr.datalen > 0)
27205                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27206         else
27207                 descriptors_constr.data = NULL;
27208         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27209         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27210                 int64_t descriptors_conv_27 = descriptors_vals[b];
27211                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27212                 CHECK_ACCESS(descriptors_conv_27_ptr);
27213                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27214                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27215                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27216         }
27217         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27218         LDKCVec_TxOutZ outputs_constr;
27219         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27220         if (outputs_constr.datalen > 0)
27221                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27222         else
27223                 outputs_constr.data = NULL;
27224         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27225         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27226                 int64_t outputs_conv_7 = outputs_vals[h];
27227                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27228                 CHECK_ACCESS(outputs_conv_7_ptr);
27229                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27230                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27231                 outputs_constr.data[h] = outputs_conv_7_conv;
27232         }
27233         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27234         LDKCVec_u8Z change_destination_script_ref;
27235         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27236         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27237         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27238         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27239         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27240         return (int64_t)ret_conv;
27241 }
27242
27243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27244         LDKKeysManager this_arg_conv;
27245         this_arg_conv.inner = (void*)(this_arg & (~1));
27246         this_arg_conv.is_owned = false;
27247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27248         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27249         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
27250         return (int64_t)ret_ret;
27251 }
27252
27253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27254         LDKPhantomKeysManager this_obj_conv;
27255         this_obj_conv.inner = (void*)(this_obj & (~1));
27256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27258         PhantomKeysManager_free(this_obj_conv);
27259 }
27260
27261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27262         LDKPhantomKeysManager this_arg_conv;
27263         this_arg_conv.inner = (void*)(this_arg & (~1));
27264         this_arg_conv.is_owned = false;
27265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27266         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27267         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
27268         return (int64_t)ret_ret;
27269 }
27270
27271 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) {
27272         unsigned char seed_arr[32];
27273         CHECK((*env)->GetArrayLength(env, seed) == 32);
27274         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27275         unsigned char (*seed_ref)[32] = &seed_arr;
27276         unsigned char cross_node_seed_arr[32];
27277         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
27278         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
27279         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
27280         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
27281         int64_t ret_ref = 0;
27282         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27283         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27285         ret_ref = (uintptr_t)ret_var.inner;
27286         if (ret_var.is_owned) {
27287                 ret_ref |= 1;
27288         }
27289         return ret_ref;
27290 }
27291
27292 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) {
27293         LDKPhantomKeysManager this_arg_conv;
27294         this_arg_conv.inner = (void*)(this_arg & (~1));
27295         this_arg_conv.is_owned = false;
27296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27297         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27298         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27299         if (descriptors_constr.datalen > 0)
27300                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27301         else
27302                 descriptors_constr.data = NULL;
27303         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27304         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27305                 int64_t descriptors_conv_27 = descriptors_vals[b];
27306                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27307                 CHECK_ACCESS(descriptors_conv_27_ptr);
27308                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27309                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27310                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27311         }
27312         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27313         LDKCVec_TxOutZ outputs_constr;
27314         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27315         if (outputs_constr.datalen > 0)
27316                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27317         else
27318                 outputs_constr.data = NULL;
27319         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27320         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27321                 int64_t outputs_conv_7 = outputs_vals[h];
27322                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27323                 CHECK_ACCESS(outputs_conv_7_ptr);
27324                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27325                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27326                 outputs_constr.data[h] = outputs_conv_7_conv;
27327         }
27328         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27329         LDKCVec_u8Z change_destination_script_ref;
27330         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27331         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27332         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27333         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27334         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27335         return (int64_t)ret_conv;
27336 }
27337
27338 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) {
27339         LDKPhantomKeysManager this_arg_conv;
27340         this_arg_conv.inner = (void*)(this_arg & (~1));
27341         this_arg_conv.is_owned = false;
27342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27343         unsigned char params_arr[32];
27344         CHECK((*env)->GetArrayLength(env, params) == 32);
27345         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27346         unsigned char (*params_ref)[32] = &params_arr;
27347         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27348         int64_t ret_ref = 0;
27349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27352         ret_ref = (uintptr_t)ret_var.inner;
27353         if (ret_var.is_owned) {
27354                 ret_ref |= 1;
27355         }
27356         return ret_ref;
27357 }
27358
27359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27360         LDKChannelManager this_obj_conv;
27361         this_obj_conv.inner = (void*)(this_obj & (~1));
27362         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27364         ChannelManager_free(this_obj_conv);
27365 }
27366
27367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27368         LDKChainParameters this_obj_conv;
27369         this_obj_conv.inner = (void*)(this_obj & (~1));
27370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27372         ChainParameters_free(this_obj_conv);
27373 }
27374
27375 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
27376         LDKChainParameters this_ptr_conv;
27377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27378         this_ptr_conv.is_owned = false;
27379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27380         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
27381         return ret_conv;
27382 }
27383
27384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27385         LDKChainParameters this_ptr_conv;
27386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27387         this_ptr_conv.is_owned = false;
27388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27389         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
27390         ChainParameters_set_network(&this_ptr_conv, val_conv);
27391 }
27392
27393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
27394         LDKChainParameters this_ptr_conv;
27395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27396         this_ptr_conv.is_owned = false;
27397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27398         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
27399         int64_t ret_ref = 0;
27400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27403         ret_ref = (uintptr_t)ret_var.inner;
27404         if (ret_var.is_owned) {
27405                 ret_ref |= 1;
27406         }
27407         return ret_ref;
27408 }
27409
27410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27411         LDKChainParameters this_ptr_conv;
27412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27413         this_ptr_conv.is_owned = false;
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27415         LDKBestBlock val_conv;
27416         val_conv.inner = (void*)(val & (~1));
27417         val_conv.is_owned = (val & 1) || (val == 0);
27418         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27419         val_conv = BestBlock_clone(&val_conv);
27420         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
27421 }
27422
27423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
27424         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
27425         LDKBestBlock best_block_arg_conv;
27426         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
27427         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
27428         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
27429         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
27430         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
27431         int64_t ret_ref = 0;
27432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27435         ret_ref = (uintptr_t)ret_var.inner;
27436         if (ret_var.is_owned) {
27437                 ret_ref |= 1;
27438         }
27439         return ret_ref;
27440 }
27441
27442 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
27443         LDKChainParameters ret_var = ChainParameters_clone(arg);
27444 int64_t ret_ref = 0;
27445 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27446 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27448 ret_ref = (uintptr_t)ret_var.inner;
27449 if (ret_var.is_owned) {
27450         ret_ref |= 1;
27451 }
27452         return ret_ref;
27453 }
27454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27455         LDKChainParameters arg_conv;
27456         arg_conv.inner = (void*)(arg & (~1));
27457         arg_conv.is_owned = false;
27458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27459         int64_t ret_val = ChainParameters_clone_ptr(&arg_conv);
27460         return ret_val;
27461 }
27462
27463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27464         LDKChainParameters orig_conv;
27465         orig_conv.inner = (void*)(orig & (~1));
27466         orig_conv.is_owned = false;
27467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27468         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
27469         int64_t ret_ref = 0;
27470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27473         ret_ref = (uintptr_t)ret_var.inner;
27474         if (ret_var.is_owned) {
27475                 ret_ref |= 1;
27476         }
27477         return ret_ref;
27478 }
27479
27480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27481         LDKCounterpartyForwardingInfo this_obj_conv;
27482         this_obj_conv.inner = (void*)(this_obj & (~1));
27483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27485         CounterpartyForwardingInfo_free(this_obj_conv);
27486 }
27487
27488 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27489         LDKCounterpartyForwardingInfo this_ptr_conv;
27490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27491         this_ptr_conv.is_owned = false;
27492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27493         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
27494         return ret_val;
27495 }
27496
27497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27498         LDKCounterpartyForwardingInfo this_ptr_conv;
27499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27500         this_ptr_conv.is_owned = false;
27501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27502         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
27503 }
27504
27505 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27506         LDKCounterpartyForwardingInfo this_ptr_conv;
27507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27508         this_ptr_conv.is_owned = false;
27509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27510         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
27511         return ret_val;
27512 }
27513
27514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27515         LDKCounterpartyForwardingInfo this_ptr_conv;
27516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27517         this_ptr_conv.is_owned = false;
27518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27519         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
27520 }
27521
27522 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27523         LDKCounterpartyForwardingInfo this_ptr_conv;
27524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27525         this_ptr_conv.is_owned = false;
27526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27527         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
27528         return ret_val;
27529 }
27530
27531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27532         LDKCounterpartyForwardingInfo this_ptr_conv;
27533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27534         this_ptr_conv.is_owned = false;
27535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27536         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
27537 }
27538
27539 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) {
27540         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
27541         int64_t ret_ref = 0;
27542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27545         ret_ref = (uintptr_t)ret_var.inner;
27546         if (ret_var.is_owned) {
27547                 ret_ref |= 1;
27548         }
27549         return ret_ref;
27550 }
27551
27552 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
27553         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
27554 int64_t ret_ref = 0;
27555 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27556 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27557 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27558 ret_ref = (uintptr_t)ret_var.inner;
27559 if (ret_var.is_owned) {
27560         ret_ref |= 1;
27561 }
27562         return ret_ref;
27563 }
27564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27565         LDKCounterpartyForwardingInfo arg_conv;
27566         arg_conv.inner = (void*)(arg & (~1));
27567         arg_conv.is_owned = false;
27568         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27569         int64_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
27570         return ret_val;
27571 }
27572
27573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27574         LDKCounterpartyForwardingInfo orig_conv;
27575         orig_conv.inner = (void*)(orig & (~1));
27576         orig_conv.is_owned = false;
27577         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27578         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
27579         int64_t ret_ref = 0;
27580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27583         ret_ref = (uintptr_t)ret_var.inner;
27584         if (ret_var.is_owned) {
27585                 ret_ref |= 1;
27586         }
27587         return ret_ref;
27588 }
27589
27590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27591         LDKChannelCounterparty this_obj_conv;
27592         this_obj_conv.inner = (void*)(this_obj & (~1));
27593         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27595         ChannelCounterparty_free(this_obj_conv);
27596 }
27597
27598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27599         LDKChannelCounterparty this_ptr_conv;
27600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27601         this_ptr_conv.is_owned = false;
27602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27603         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27604         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
27605         return ret_arr;
27606 }
27607
27608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27609         LDKChannelCounterparty this_ptr_conv;
27610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27611         this_ptr_conv.is_owned = false;
27612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27613         LDKPublicKey val_ref;
27614         CHECK((*env)->GetArrayLength(env, val) == 33);
27615         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27616         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
27617 }
27618
27619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
27620         LDKChannelCounterparty this_ptr_conv;
27621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27622         this_ptr_conv.is_owned = false;
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27624         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
27625         int64_t ret_ref = 0;
27626         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27627         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27629         ret_ref = (uintptr_t)ret_var.inner;
27630         if (ret_var.is_owned) {
27631                 ret_ref |= 1;
27632         }
27633         return ret_ref;
27634 }
27635
27636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27637         LDKChannelCounterparty this_ptr_conv;
27638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27639         this_ptr_conv.is_owned = false;
27640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27641         LDKInitFeatures val_conv;
27642         val_conv.inner = (void*)(val & (~1));
27643         val_conv.is_owned = (val & 1) || (val == 0);
27644         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27645         val_conv = InitFeatures_clone(&val_conv);
27646         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
27647 }
27648
27649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
27650         LDKChannelCounterparty this_ptr_conv;
27651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27652         this_ptr_conv.is_owned = false;
27653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27654         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
27655         return ret_val;
27656 }
27657
27658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27659         LDKChannelCounterparty this_ptr_conv;
27660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27661         this_ptr_conv.is_owned = false;
27662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27663         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
27664 }
27665
27666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
27667         LDKChannelCounterparty this_ptr_conv;
27668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27669         this_ptr_conv.is_owned = false;
27670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27671         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
27672         int64_t ret_ref = 0;
27673         if ((uintptr_t)ret_var.inner > 4096) {
27674                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27675                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27677                 ret_ref = (uintptr_t)ret_var.inner;
27678                 if (ret_var.is_owned) {
27679                         ret_ref |= 1;
27680                 }
27681         }
27682         return ret_ref;
27683 }
27684
27685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27686         LDKChannelCounterparty this_ptr_conv;
27687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27688         this_ptr_conv.is_owned = false;
27689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27690         LDKCounterpartyForwardingInfo val_conv;
27691         val_conv.inner = (void*)(val & (~1));
27692         val_conv.is_owned = (val & 1) || (val == 0);
27693         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27694         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
27695         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
27696 }
27697
27698 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) {
27699         LDKPublicKey node_id_arg_ref;
27700         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
27701         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
27702         LDKInitFeatures features_arg_conv;
27703         features_arg_conv.inner = (void*)(features_arg & (~1));
27704         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
27705         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
27706         features_arg_conv = InitFeatures_clone(&features_arg_conv);
27707         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
27708         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
27709         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
27710         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
27711         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
27712         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
27713         int64_t ret_ref = 0;
27714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27717         ret_ref = (uintptr_t)ret_var.inner;
27718         if (ret_var.is_owned) {
27719                 ret_ref |= 1;
27720         }
27721         return ret_ref;
27722 }
27723
27724 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
27725         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
27726 int64_t ret_ref = 0;
27727 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27728 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27729 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27730 ret_ref = (uintptr_t)ret_var.inner;
27731 if (ret_var.is_owned) {
27732         ret_ref |= 1;
27733 }
27734         return ret_ref;
27735 }
27736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27737         LDKChannelCounterparty arg_conv;
27738         arg_conv.inner = (void*)(arg & (~1));
27739         arg_conv.is_owned = false;
27740         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27741         int64_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
27742         return ret_val;
27743 }
27744
27745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27746         LDKChannelCounterparty orig_conv;
27747         orig_conv.inner = (void*)(orig & (~1));
27748         orig_conv.is_owned = false;
27749         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27750         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
27751         int64_t ret_ref = 0;
27752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27755         ret_ref = (uintptr_t)ret_var.inner;
27756         if (ret_var.is_owned) {
27757                 ret_ref |= 1;
27758         }
27759         return ret_ref;
27760 }
27761
27762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27763         LDKChannelDetails this_obj_conv;
27764         this_obj_conv.inner = (void*)(this_obj & (~1));
27765         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27767         ChannelDetails_free(this_obj_conv);
27768 }
27769
27770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27771         LDKChannelDetails this_ptr_conv;
27772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27773         this_ptr_conv.is_owned = false;
27774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27775         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27776         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
27777         return ret_arr;
27778 }
27779
27780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27781         LDKChannelDetails this_ptr_conv;
27782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27783         this_ptr_conv.is_owned = false;
27784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27785         LDKThirtyTwoBytes val_ref;
27786         CHECK((*env)->GetArrayLength(env, val) == 32);
27787         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27788         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
27789 }
27790
27791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
27792         LDKChannelDetails this_ptr_conv;
27793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27794         this_ptr_conv.is_owned = false;
27795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27796         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
27797         int64_t ret_ref = 0;
27798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27801         ret_ref = (uintptr_t)ret_var.inner;
27802         if (ret_var.is_owned) {
27803                 ret_ref |= 1;
27804         }
27805         return ret_ref;
27806 }
27807
27808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27809         LDKChannelDetails this_ptr_conv;
27810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27811         this_ptr_conv.is_owned = false;
27812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27813         LDKChannelCounterparty val_conv;
27814         val_conv.inner = (void*)(val & (~1));
27815         val_conv.is_owned = (val & 1) || (val == 0);
27816         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27817         val_conv = ChannelCounterparty_clone(&val_conv);
27818         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
27819 }
27820
27821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
27822         LDKChannelDetails this_ptr_conv;
27823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27824         this_ptr_conv.is_owned = false;
27825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27826         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
27827         int64_t ret_ref = 0;
27828         if ((uintptr_t)ret_var.inner > 4096) {
27829                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27830                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27832                 ret_ref = (uintptr_t)ret_var.inner;
27833                 if (ret_var.is_owned) {
27834                         ret_ref |= 1;
27835                 }
27836         }
27837         return ret_ref;
27838 }
27839
27840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27841         LDKChannelDetails this_ptr_conv;
27842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27843         this_ptr_conv.is_owned = false;
27844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27845         LDKOutPoint val_conv;
27846         val_conv.inner = (void*)(val & (~1));
27847         val_conv.is_owned = (val & 1) || (val == 0);
27848         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27849         val_conv = OutPoint_clone(&val_conv);
27850         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
27851 }
27852
27853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27854         LDKChannelDetails this_ptr_conv;
27855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27856         this_ptr_conv.is_owned = false;
27857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27858         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27859         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
27860         int64_t ret_ref = (uintptr_t)ret_copy;
27861         return ret_ref;
27862 }
27863
27864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27865         LDKChannelDetails this_ptr_conv;
27866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27867         this_ptr_conv.is_owned = false;
27868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27869         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27870         CHECK_ACCESS(val_ptr);
27871         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
27872         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
27873         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
27874 }
27875
27876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27877         LDKChannelDetails this_ptr_conv;
27878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27879         this_ptr_conv.is_owned = false;
27880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27881         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
27882         return ret_val;
27883 }
27884
27885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27886         LDKChannelDetails this_ptr_conv;
27887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27888         this_ptr_conv.is_owned = false;
27889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27890         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
27891 }
27892
27893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
27894         LDKChannelDetails this_ptr_conv;
27895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27896         this_ptr_conv.is_owned = false;
27897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27898         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27899         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
27900         int64_t ret_ref = (uintptr_t)ret_copy;
27901         return ret_ref;
27902 }
27903
27904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27905         LDKChannelDetails this_ptr_conv;
27906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27907         this_ptr_conv.is_owned = false;
27908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27909         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27910         CHECK_ACCESS(val_ptr);
27911         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
27912         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
27913         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
27914 }
27915
27916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27917         LDKChannelDetails this_ptr_conv;
27918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27919         this_ptr_conv.is_owned = false;
27920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27921         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
27922         return ret_val;
27923 }
27924
27925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27926         LDKChannelDetails this_ptr_conv;
27927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27928         this_ptr_conv.is_owned = false;
27929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27930         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
27931 }
27932
27933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27934         LDKChannelDetails this_ptr_conv;
27935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27936         this_ptr_conv.is_owned = false;
27937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27938         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
27939         return ret_val;
27940 }
27941
27942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27943         LDKChannelDetails this_ptr_conv;
27944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27945         this_ptr_conv.is_owned = false;
27946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27947         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
27948 }
27949
27950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27951         LDKChannelDetails this_ptr_conv;
27952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27953         this_ptr_conv.is_owned = false;
27954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27955         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
27956         return ret_val;
27957 }
27958
27959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27960         LDKChannelDetails this_ptr_conv;
27961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27962         this_ptr_conv.is_owned = false;
27963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27964         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
27965 }
27966
27967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27968         LDKChannelDetails this_ptr_conv;
27969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27970         this_ptr_conv.is_owned = false;
27971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27972         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
27973         return ret_val;
27974 }
27975
27976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27977         LDKChannelDetails this_ptr_conv;
27978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27979         this_ptr_conv.is_owned = false;
27980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27981         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
27982 }
27983
27984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
27985         LDKChannelDetails this_ptr_conv;
27986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27987         this_ptr_conv.is_owned = false;
27988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27989         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
27990         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
27991         int64_t ret_ref = (uintptr_t)ret_copy;
27992         return ret_ref;
27993 }
27994
27995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27996         LDKChannelDetails this_ptr_conv;
27997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27998         this_ptr_conv.is_owned = false;
27999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28000         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28001         CHECK_ACCESS(val_ptr);
28002         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
28003         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
28004         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
28005 }
28006
28007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28008         LDKChannelDetails this_ptr_conv;
28009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28010         this_ptr_conv.is_owned = false;
28011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28012         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
28013         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
28014         int64_t ret_ref = (uintptr_t)ret_copy;
28015         return ret_ref;
28016 }
28017
28018 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) {
28019         LDKChannelDetails this_ptr_conv;
28020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28021         this_ptr_conv.is_owned = false;
28022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28023         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28024         CHECK_ACCESS(val_ptr);
28025         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
28026         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
28027         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
28028 }
28029
28030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
28031         LDKChannelDetails this_ptr_conv;
28032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28033         this_ptr_conv.is_owned = false;
28034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28035         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
28036         return ret_val;
28037 }
28038
28039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28040         LDKChannelDetails this_ptr_conv;
28041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28042         this_ptr_conv.is_owned = false;
28043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28044         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
28045 }
28046
28047 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
28048         LDKChannelDetails this_ptr_conv;
28049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28050         this_ptr_conv.is_owned = false;
28051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28052         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
28053         return ret_val;
28054 }
28055
28056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28057         LDKChannelDetails this_ptr_conv;
28058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28059         this_ptr_conv.is_owned = false;
28060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28061         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
28062 }
28063
28064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
28065         LDKChannelDetails this_ptr_conv;
28066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28067         this_ptr_conv.is_owned = false;
28068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28069         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
28070         return ret_val;
28071 }
28072
28073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28074         LDKChannelDetails this_ptr_conv;
28075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28076         this_ptr_conv.is_owned = false;
28077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28078         ChannelDetails_set_is_usable(&this_ptr_conv, val);
28079 }
28080
28081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
28082         LDKChannelDetails this_ptr_conv;
28083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28084         this_ptr_conv.is_owned = false;
28085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28086         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
28087         return ret_val;
28088 }
28089
28090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28091         LDKChannelDetails this_ptr_conv;
28092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28093         this_ptr_conv.is_owned = false;
28094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28095         ChannelDetails_set_is_public(&this_ptr_conv, val);
28096 }
28097
28098 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 short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
28099         LDKThirtyTwoBytes channel_id_arg_ref;
28100         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28101         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28102         LDKChannelCounterparty counterparty_arg_conv;
28103         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
28104         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
28105         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
28106         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
28107         LDKOutPoint funding_txo_arg_conv;
28108         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
28109         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
28110         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
28111         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
28112         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
28113         CHECK_ACCESS(short_channel_id_arg_ptr);
28114         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
28115         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
28116         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
28117         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
28118         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
28119         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
28120         CHECK_ACCESS(confirmations_required_arg_ptr);
28121         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
28122         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
28123         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
28124         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
28125         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
28126         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
28127         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
28128         int64_t ret_ref = 0;
28129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28132         ret_ref = (uintptr_t)ret_var.inner;
28133         if (ret_var.is_owned) {
28134                 ret_ref |= 1;
28135         }
28136         return ret_ref;
28137 }
28138
28139 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
28140         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
28141 int64_t ret_ref = 0;
28142 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28143 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28144 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28145 ret_ref = (uintptr_t)ret_var.inner;
28146 if (ret_var.is_owned) {
28147         ret_ref |= 1;
28148 }
28149         return ret_ref;
28150 }
28151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28152         LDKChannelDetails arg_conv;
28153         arg_conv.inner = (void*)(arg & (~1));
28154         arg_conv.is_owned = false;
28155         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28156         int64_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
28157         return ret_val;
28158 }
28159
28160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28161         LDKChannelDetails orig_conv;
28162         orig_conv.inner = (void*)(orig & (~1));
28163         orig_conv.is_owned = false;
28164         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28165         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
28166         int64_t ret_ref = 0;
28167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28170         ret_ref = (uintptr_t)ret_var.inner;
28171         if (ret_var.is_owned) {
28172                 ret_ref |= 1;
28173         }
28174         return ret_ref;
28175 }
28176
28177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28178         if ((this_ptr & 1) != 0) return;
28179         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28180         CHECK_ACCESS(this_ptr_ptr);
28181         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
28182         FREE((void*)this_ptr);
28183         PaymentSendFailure_free(this_ptr_conv);
28184 }
28185
28186 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
28187         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28188         *ret_copy = PaymentSendFailure_clone(arg);
28189 int64_t ret_ref = (uintptr_t)ret_copy;
28190         return ret_ref;
28191 }
28192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28193         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
28194         int64_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
28195         return ret_val;
28196 }
28197
28198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28199         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
28200         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28201         *ret_copy = PaymentSendFailure_clone(orig_conv);
28202         int64_t ret_ref = (uintptr_t)ret_copy;
28203         return ret_ref;
28204 }
28205
28206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
28207         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
28208         CHECK_ACCESS(a_ptr);
28209         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
28210         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
28211         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28212         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
28213         int64_t ret_ref = (uintptr_t)ret_copy;
28214         return ret_ref;
28215 }
28216
28217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
28218         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
28219         a_constr.datalen = (*env)->GetArrayLength(env, a);
28220         if (a_constr.datalen > 0)
28221                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28222         else
28223                 a_constr.data = NULL;
28224         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28225         for (size_t w = 0; w < a_constr.datalen; w++) {
28226                 int64_t a_conv_22 = a_vals[w];
28227                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
28228                 CHECK_ACCESS(a_conv_22_ptr);
28229                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
28230                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
28231                 a_constr.data[w] = a_conv_22_conv;
28232         }
28233         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28234         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28235         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
28236         int64_t ret_ref = (uintptr_t)ret_copy;
28237         return ret_ref;
28238 }
28239
28240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
28241         LDKCVec_APIErrorZ a_constr;
28242         a_constr.datalen = (*env)->GetArrayLength(env, a);
28243         if (a_constr.datalen > 0)
28244                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
28245         else
28246                 a_constr.data = NULL;
28247         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28248         for (size_t k = 0; k < a_constr.datalen; k++) {
28249                 int64_t a_conv_10 = a_vals[k];
28250                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
28251                 CHECK_ACCESS(a_conv_10_ptr);
28252                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
28253                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
28254                 a_constr.data[k] = a_conv_10_conv;
28255         }
28256         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28257         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28258         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
28259         int64_t ret_ref = (uintptr_t)ret_copy;
28260         return ret_ref;
28261 }
28262
28263 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) {
28264         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
28265         results_constr.datalen = (*env)->GetArrayLength(env, results);
28266         if (results_constr.datalen > 0)
28267                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28268         else
28269                 results_constr.data = NULL;
28270         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
28271         for (size_t w = 0; w < results_constr.datalen; w++) {
28272                 int64_t results_conv_22 = results_vals[w];
28273                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
28274                 CHECK_ACCESS(results_conv_22_ptr);
28275                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
28276                 results_constr.data[w] = results_conv_22_conv;
28277         }
28278         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
28279         LDKRouteParameters failed_paths_retry_conv;
28280         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
28281         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
28282         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
28283         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
28284         LDKThirtyTwoBytes payment_id_ref;
28285         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
28286         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
28287         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28288         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
28289         int64_t ret_ref = (uintptr_t)ret_copy;
28290         return ret_ref;
28291 }
28292
28293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28294         LDKPhantomRouteHints this_obj_conv;
28295         this_obj_conv.inner = (void*)(this_obj & (~1));
28296         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28298         PhantomRouteHints_free(this_obj_conv);
28299 }
28300
28301 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28302         LDKPhantomRouteHints this_ptr_conv;
28303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28304         this_ptr_conv.is_owned = false;
28305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28306         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
28307         int64_tArray ret_arr = NULL;
28308         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28309         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28310         for (size_t q = 0; q < ret_var.datalen; q++) {
28311                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
28312                 int64_t ret_conv_16_ref = 0;
28313                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28314                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28315                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
28316                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
28317                 if (ret_conv_16_var.is_owned) {
28318                         ret_conv_16_ref |= 1;
28319                 }
28320                 ret_arr_ptr[q] = ret_conv_16_ref;
28321         }
28322         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28323         FREE(ret_var.data);
28324         return ret_arr;
28325 }
28326
28327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28328         LDKPhantomRouteHints this_ptr_conv;
28329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28330         this_ptr_conv.is_owned = false;
28331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28332         LDKCVec_ChannelDetailsZ val_constr;
28333         val_constr.datalen = (*env)->GetArrayLength(env, val);
28334         if (val_constr.datalen > 0)
28335                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28336         else
28337                 val_constr.data = NULL;
28338         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28339         for (size_t q = 0; q < val_constr.datalen; q++) {
28340                 int64_t val_conv_16 = val_vals[q];
28341                 LDKChannelDetails val_conv_16_conv;
28342                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
28343                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
28344                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
28345                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
28346                 val_constr.data[q] = val_conv_16_conv;
28347         }
28348         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28349         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
28350 }
28351
28352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28353         LDKPhantomRouteHints this_ptr_conv;
28354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28355         this_ptr_conv.is_owned = false;
28356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28357         int64_t ret_val = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
28358         return ret_val;
28359 }
28360
28361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28362         LDKPhantomRouteHints this_ptr_conv;
28363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28364         this_ptr_conv.is_owned = false;
28365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28366         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
28367 }
28368
28369 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28370         LDKPhantomRouteHints this_ptr_conv;
28371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28372         this_ptr_conv.is_owned = false;
28373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28374         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28375         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
28376         return ret_arr;
28377 }
28378
28379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28380         LDKPhantomRouteHints this_ptr_conv;
28381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28382         this_ptr_conv.is_owned = false;
28383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28384         LDKPublicKey val_ref;
28385         CHECK((*env)->GetArrayLength(env, val) == 33);
28386         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28387         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
28388 }
28389
28390 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) {
28391         LDKCVec_ChannelDetailsZ channels_arg_constr;
28392         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
28393         if (channels_arg_constr.datalen > 0)
28394                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28395         else
28396                 channels_arg_constr.data = NULL;
28397         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
28398         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
28399                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
28400                 LDKChannelDetails channels_arg_conv_16_conv;
28401                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
28402                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
28403                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
28404                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
28405                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
28406         }
28407         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
28408         LDKPublicKey real_node_pubkey_arg_ref;
28409         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
28410         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
28411         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
28412         int64_t ret_ref = 0;
28413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28416         ret_ref = (uintptr_t)ret_var.inner;
28417         if (ret_var.is_owned) {
28418                 ret_ref |= 1;
28419         }
28420         return ret_ref;
28421 }
28422
28423 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
28424         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
28425 int64_t ret_ref = 0;
28426 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28427 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28428 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28429 ret_ref = (uintptr_t)ret_var.inner;
28430 if (ret_var.is_owned) {
28431         ret_ref |= 1;
28432 }
28433         return ret_ref;
28434 }
28435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28436         LDKPhantomRouteHints arg_conv;
28437         arg_conv.inner = (void*)(arg & (~1));
28438         arg_conv.is_owned = false;
28439         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28440         int64_t ret_val = PhantomRouteHints_clone_ptr(&arg_conv);
28441         return ret_val;
28442 }
28443
28444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28445         LDKPhantomRouteHints orig_conv;
28446         orig_conv.inner = (void*)(orig & (~1));
28447         orig_conv.is_owned = false;
28448         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28449         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
28450         int64_t ret_ref = 0;
28451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28454         ret_ref = (uintptr_t)ret_var.inner;
28455         if (ret_var.is_owned) {
28456                 ret_ref |= 1;
28457         }
28458         return ret_ref;
28459 }
28460
28461 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) {
28462         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
28463         CHECK_ACCESS(fee_est_ptr);
28464         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
28465         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
28466                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28467                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
28468         }
28469         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
28470         CHECK_ACCESS(chain_monitor_ptr);
28471         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
28472         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
28473                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28474                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
28475         }
28476         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
28477         CHECK_ACCESS(tx_broadcaster_ptr);
28478         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
28479         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28480                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28481                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
28482         }
28483         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28484         CHECK_ACCESS(logger_ptr);
28485         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28486         if (logger_conv.free == LDKLogger_JCalls_free) {
28487                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28488                 LDKLogger_JCalls_cloned(&logger_conv);
28489         }
28490         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
28491         CHECK_ACCESS(keys_manager_ptr);
28492         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
28493         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
28494                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28495                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
28496         }
28497         LDKUserConfig config_conv;
28498         config_conv.inner = (void*)(config & (~1));
28499         config_conv.is_owned = (config & 1) || (config == 0);
28500         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
28501         config_conv = UserConfig_clone(&config_conv);
28502         LDKChainParameters params_conv;
28503         params_conv.inner = (void*)(params & (~1));
28504         params_conv.is_owned = (params & 1) || (params == 0);
28505         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
28506         params_conv = ChainParameters_clone(&params_conv);
28507         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
28508         int64_t ret_ref = 0;
28509         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28510         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28512         ret_ref = (uintptr_t)ret_var.inner;
28513         if (ret_var.is_owned) {
28514                 ret_ref |= 1;
28515         }
28516         return ret_ref;
28517 }
28518
28519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
28520         LDKChannelManager this_arg_conv;
28521         this_arg_conv.inner = (void*)(this_arg & (~1));
28522         this_arg_conv.is_owned = false;
28523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28524         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
28525         int64_t ret_ref = 0;
28526         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28527         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28529         ret_ref = (uintptr_t)ret_var.inner;
28530         if (ret_var.is_owned) {
28531                 ret_ref |= 1;
28532         }
28533         return ret_ref;
28534 }
28535
28536 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) {
28537         LDKChannelManager this_arg_conv;
28538         this_arg_conv.inner = (void*)(this_arg & (~1));
28539         this_arg_conv.is_owned = false;
28540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28541         LDKPublicKey their_network_key_ref;
28542         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
28543         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
28544         LDKUserConfig override_config_conv;
28545         override_config_conv.inner = (void*)(override_config & (~1));
28546         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
28547         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
28548         override_config_conv = UserConfig_clone(&override_config_conv);
28549         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
28550         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
28551         return (int64_t)ret_conv;
28552 }
28553
28554 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
28555         LDKChannelManager this_arg_conv;
28556         this_arg_conv.inner = (void*)(this_arg & (~1));
28557         this_arg_conv.is_owned = false;
28558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28559         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
28560         int64_tArray ret_arr = NULL;
28561         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28562         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28563         for (size_t q = 0; q < ret_var.datalen; q++) {
28564                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
28565                 int64_t ret_conv_16_ref = 0;
28566                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28567                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28568                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
28569                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
28570                 if (ret_conv_16_var.is_owned) {
28571                         ret_conv_16_ref |= 1;
28572                 }
28573                 ret_arr_ptr[q] = ret_conv_16_ref;
28574         }
28575         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28576         FREE(ret_var.data);
28577         return ret_arr;
28578 }
28579
28580 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
28581         LDKChannelManager this_arg_conv;
28582         this_arg_conv.inner = (void*)(this_arg & (~1));
28583         this_arg_conv.is_owned = false;
28584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28585         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
28586         int64_tArray ret_arr = NULL;
28587         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28588         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28589         for (size_t q = 0; q < ret_var.datalen; q++) {
28590                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
28591                 int64_t ret_conv_16_ref = 0;
28592                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28593                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28594                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
28595                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
28596                 if (ret_conv_16_var.is_owned) {
28597                         ret_conv_16_ref |= 1;
28598                 }
28599                 ret_arr_ptr[q] = ret_conv_16_ref;
28600         }
28601         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28602         FREE(ret_var.data);
28603         return ret_arr;
28604 }
28605
28606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
28607         LDKChannelManager this_arg_conv;
28608         this_arg_conv.inner = (void*)(this_arg & (~1));
28609         this_arg_conv.is_owned = false;
28610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28611         unsigned char channel_id_arr[32];
28612         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
28613         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
28614         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
28615         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28616         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
28617         return (int64_t)ret_conv;
28618 }
28619
28620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
28621         LDKChannelManager this_arg_conv;
28622         this_arg_conv.inner = (void*)(this_arg & (~1));
28623         this_arg_conv.is_owned = false;
28624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28625         unsigned char channel_id_arr[32];
28626         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
28627         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
28628         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
28629         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28630         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
28631         return (int64_t)ret_conv;
28632 }
28633
28634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
28635         LDKChannelManager this_arg_conv;
28636         this_arg_conv.inner = (void*)(this_arg & (~1));
28637         this_arg_conv.is_owned = false;
28638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28639         unsigned char channel_id_arr[32];
28640         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
28641         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
28642         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
28643         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28644         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
28645         return (int64_t)ret_conv;
28646 }
28647
28648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
28649         LDKChannelManager this_arg_conv;
28650         this_arg_conv.inner = (void*)(this_arg & (~1));
28651         this_arg_conv.is_owned = false;
28652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28653         ChannelManager_force_close_all_channels(&this_arg_conv);
28654 }
28655
28656 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) {
28657         LDKChannelManager this_arg_conv;
28658         this_arg_conv.inner = (void*)(this_arg & (~1));
28659         this_arg_conv.is_owned = false;
28660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28661         LDKRoute route_conv;
28662         route_conv.inner = (void*)(route & (~1));
28663         route_conv.is_owned = false;
28664         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
28665         LDKThirtyTwoBytes payment_hash_ref;
28666         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28667         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
28668         LDKThirtyTwoBytes payment_secret_ref;
28669         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
28670         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
28671         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
28672         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
28673         return (int64_t)ret_conv;
28674 }
28675
28676 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) {
28677         LDKChannelManager this_arg_conv;
28678         this_arg_conv.inner = (void*)(this_arg & (~1));
28679         this_arg_conv.is_owned = false;
28680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28681         LDKRoute route_conv;
28682         route_conv.inner = (void*)(route & (~1));
28683         route_conv.is_owned = false;
28684         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
28685         LDKThirtyTwoBytes payment_id_ref;
28686         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
28687         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
28688         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
28689         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
28690         return (int64_t)ret_conv;
28691 }
28692
28693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
28694         LDKChannelManager this_arg_conv;
28695         this_arg_conv.inner = (void*)(this_arg & (~1));
28696         this_arg_conv.is_owned = false;
28697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28698         LDKThirtyTwoBytes payment_id_ref;
28699         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
28700         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
28701         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
28702 }
28703
28704 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) {
28705         LDKChannelManager this_arg_conv;
28706         this_arg_conv.inner = (void*)(this_arg & (~1));
28707         this_arg_conv.is_owned = false;
28708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28709         LDKRoute route_conv;
28710         route_conv.inner = (void*)(route & (~1));
28711         route_conv.is_owned = false;
28712         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
28713         LDKThirtyTwoBytes payment_preimage_ref;
28714         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
28715         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
28716         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
28717         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
28718         return (int64_t)ret_conv;
28719 }
28720
28721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
28722         LDKChannelManager this_arg_conv;
28723         this_arg_conv.inner = (void*)(this_arg & (~1));
28724         this_arg_conv.is_owned = false;
28725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28726         unsigned char temporary_channel_id_arr[32];
28727         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
28728         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
28729         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
28730         LDKTransaction funding_transaction_ref;
28731         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
28732         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
28733         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
28734         funding_transaction_ref.data_is_owned = true;
28735         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28736         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
28737         return (int64_t)ret_conv;
28738 }
28739
28740 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) {
28741         LDKChannelManager this_arg_conv;
28742         this_arg_conv.inner = (void*)(this_arg & (~1));
28743         this_arg_conv.is_owned = false;
28744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28745         LDKThreeBytes rgb_ref;
28746         CHECK((*env)->GetArrayLength(env, rgb) == 3);
28747         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
28748         LDKThirtyTwoBytes alias_ref;
28749         CHECK((*env)->GetArrayLength(env, alias) == 32);
28750         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
28751         LDKCVec_NetAddressZ addresses_constr;
28752         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
28753         if (addresses_constr.datalen > 0)
28754                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28755         else
28756                 addresses_constr.data = NULL;
28757         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
28758         for (size_t m = 0; m < addresses_constr.datalen; m++) {
28759                 int64_t addresses_conv_12 = addresses_vals[m];
28760                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
28761                 CHECK_ACCESS(addresses_conv_12_ptr);
28762                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
28763                 addresses_constr.data[m] = addresses_conv_12_conv;
28764         }
28765         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
28766         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
28767 }
28768
28769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
28770         LDKChannelManager this_arg_conv;
28771         this_arg_conv.inner = (void*)(this_arg & (~1));
28772         this_arg_conv.is_owned = false;
28773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28774         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
28775 }
28776
28777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
28778         LDKChannelManager this_arg_conv;
28779         this_arg_conv.inner = (void*)(this_arg & (~1));
28780         this_arg_conv.is_owned = false;
28781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28782         ChannelManager_timer_tick_occurred(&this_arg_conv);
28783 }
28784
28785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
28786         LDKChannelManager this_arg_conv;
28787         this_arg_conv.inner = (void*)(this_arg & (~1));
28788         this_arg_conv.is_owned = false;
28789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28790         unsigned char payment_hash_arr[32];
28791         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28792         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
28793         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
28794         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
28795         return ret_val;
28796 }
28797
28798 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
28799         LDKChannelManager this_arg_conv;
28800         this_arg_conv.inner = (void*)(this_arg & (~1));
28801         this_arg_conv.is_owned = false;
28802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28803         LDKThirtyTwoBytes payment_preimage_ref;
28804         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
28805         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
28806         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
28807         return ret_val;
28808 }
28809
28810 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28811         LDKChannelManager this_arg_conv;
28812         this_arg_conv.inner = (void*)(this_arg & (~1));
28813         this_arg_conv.is_owned = false;
28814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28815         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28816         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
28817         return ret_arr;
28818 }
28819
28820 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) {
28821         LDKChannelManager this_arg_conv;
28822         this_arg_conv.inner = (void*)(this_arg & (~1));
28823         this_arg_conv.is_owned = false;
28824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28825         unsigned char temporary_channel_id_arr[32];
28826         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
28827         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
28828         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
28829         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28830         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref);
28831         return (int64_t)ret_conv;
28832 }
28833
28834 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) {
28835         LDKChannelManager this_arg_conv;
28836         this_arg_conv.inner = (void*)(this_arg & (~1));
28837         this_arg_conv.is_owned = false;
28838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28839         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28840         CHECK_ACCESS(min_value_msat_ptr);
28841         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28842         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28843         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
28844         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
28845         return (int64_t)ret_conv;
28846 }
28847
28848 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) {
28849         LDKChannelManager this_arg_conv;
28850         this_arg_conv.inner = (void*)(this_arg & (~1));
28851         this_arg_conv.is_owned = false;
28852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28853         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28854         CHECK_ACCESS(min_value_msat_ptr);
28855         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28856         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28857         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
28858         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
28859         return (int64_t)ret_conv;
28860 }
28861
28862 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) {
28863         LDKChannelManager this_arg_conv;
28864         this_arg_conv.inner = (void*)(this_arg & (~1));
28865         this_arg_conv.is_owned = false;
28866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28867         LDKThirtyTwoBytes payment_hash_ref;
28868         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28869         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
28870         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28871         CHECK_ACCESS(min_value_msat_ptr);
28872         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28873         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28874         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
28875         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
28876         return (int64_t)ret_conv;
28877 }
28878
28879 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) {
28880         LDKChannelManager this_arg_conv;
28881         this_arg_conv.inner = (void*)(this_arg & (~1));
28882         this_arg_conv.is_owned = false;
28883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28884         LDKThirtyTwoBytes payment_hash_ref;
28885         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28886         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
28887         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28888         CHECK_ACCESS(min_value_msat_ptr);
28889         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28890         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28891         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
28892         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
28893         return (int64_t)ret_conv;
28894 }
28895
28896 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) {
28897         LDKChannelManager this_arg_conv;
28898         this_arg_conv.inner = (void*)(this_arg & (~1));
28899         this_arg_conv.is_owned = false;
28900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28901         LDKThirtyTwoBytes payment_hash_ref;
28902         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28903         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
28904         LDKThirtyTwoBytes payment_secret_ref;
28905         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
28906         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
28907         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
28908         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
28909         return (int64_t)ret_conv;
28910 }
28911
28912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
28913         LDKChannelManager this_arg_conv;
28914         this_arg_conv.inner = (void*)(this_arg & (~1));
28915         this_arg_conv.is_owned = false;
28916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28917         int64_t ret_val = ChannelManager_get_phantom_scid(&this_arg_conv);
28918         return ret_val;
28919 }
28920
28921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
28922         LDKChannelManager this_arg_conv;
28923         this_arg_conv.inner = (void*)(this_arg & (~1));
28924         this_arg_conv.is_owned = false;
28925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28926         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
28927         int64_t ret_ref = 0;
28928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28931         ret_ref = (uintptr_t)ret_var.inner;
28932         if (ret_var.is_owned) {
28933                 ret_ref |= 1;
28934         }
28935         return ret_ref;
28936 }
28937
28938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
28939         LDKChannelManager this_arg_conv;
28940         this_arg_conv.inner = (void*)(this_arg & (~1));
28941         this_arg_conv.is_owned = false;
28942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28943         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28944         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
28945         return (int64_t)ret_ret;
28946 }
28947
28948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
28949         LDKChannelManager this_arg_conv;
28950         this_arg_conv.inner = (void*)(this_arg & (~1));
28951         this_arg_conv.is_owned = false;
28952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28953         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
28954         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
28955         return (int64_t)ret_ret;
28956 }
28957
28958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
28959         LDKChannelManager this_arg_conv;
28960         this_arg_conv.inner = (void*)(this_arg & (~1));
28961         this_arg_conv.is_owned = false;
28962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28963         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
28964         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
28965         return (int64_t)ret_ret;
28966 }
28967
28968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
28969         LDKChannelManager this_arg_conv;
28970         this_arg_conv.inner = (void*)(this_arg & (~1));
28971         this_arg_conv.is_owned = false;
28972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28973         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
28974         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
28975         return (int64_t)ret_ret;
28976 }
28977
28978 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) {
28979         LDKChannelManager this_arg_conv;
28980         this_arg_conv.inner = (void*)(this_arg & (~1));
28981         this_arg_conv.is_owned = false;
28982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28983         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
28984         return ret_val;
28985 }
28986
28987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
28988         LDKChannelManager this_arg_conv;
28989         this_arg_conv.inner = (void*)(this_arg & (~1));
28990         this_arg_conv.is_owned = false;
28991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28992         ChannelManager_await_persistable_update(&this_arg_conv);
28993 }
28994
28995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
28996         LDKChannelManager this_arg_conv;
28997         this_arg_conv.inner = (void*)(this_arg & (~1));
28998         this_arg_conv.is_owned = false;
28999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29000         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
29001         int64_t ret_ref = 0;
29002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29005         ret_ref = (uintptr_t)ret_var.inner;
29006         if (ret_var.is_owned) {
29007                 ret_ref |= 1;
29008         }
29009         return ret_ref;
29010 }
29011
29012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
29013         LDKChannelManager this_arg_conv;
29014         this_arg_conv.inner = (void*)(this_arg & (~1));
29015         this_arg_conv.is_owned = false;
29016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29017         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
29018         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
29019         return (int64_t)ret_ret;
29020 }
29021
29022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
29023         LDKCounterpartyForwardingInfo obj_conv;
29024         obj_conv.inner = (void*)(obj & (~1));
29025         obj_conv.is_owned = false;
29026         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29027         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
29028         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29029         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29030         CVec_u8Z_free(ret_var);
29031         return ret_arr;
29032 }
29033
29034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29035         LDKu8slice ser_ref;
29036         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29037         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29038         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
29039         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
29040         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29041         return (int64_t)ret_conv;
29042 }
29043
29044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
29045         LDKChannelCounterparty obj_conv;
29046         obj_conv.inner = (void*)(obj & (~1));
29047         obj_conv.is_owned = false;
29048         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29049         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
29050         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29051         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29052         CVec_u8Z_free(ret_var);
29053         return ret_arr;
29054 }
29055
29056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29057         LDKu8slice ser_ref;
29058         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29059         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29060         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
29061         *ret_conv = ChannelCounterparty_read(ser_ref);
29062         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29063         return (int64_t)ret_conv;
29064 }
29065
29066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
29067         LDKChannelDetails obj_conv;
29068         obj_conv.inner = (void*)(obj & (~1));
29069         obj_conv.is_owned = false;
29070         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29071         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
29072         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29073         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29074         CVec_u8Z_free(ret_var);
29075         return ret_arr;
29076 }
29077
29078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29079         LDKu8slice ser_ref;
29080         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29081         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29082         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
29083         *ret_conv = ChannelDetails_read(ser_ref);
29084         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29085         return (int64_t)ret_conv;
29086 }
29087
29088 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
29089         LDKPhantomRouteHints obj_conv;
29090         obj_conv.inner = (void*)(obj & (~1));
29091         obj_conv.is_owned = false;
29092         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29093         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
29094         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29095         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29096         CVec_u8Z_free(ret_var);
29097         return ret_arr;
29098 }
29099
29100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29101         LDKu8slice ser_ref;
29102         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29103         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29104         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
29105         *ret_conv = PhantomRouteHints_read(ser_ref);
29106         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29107         return (int64_t)ret_conv;
29108 }
29109
29110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
29111         LDKChannelManager obj_conv;
29112         obj_conv.inner = (void*)(obj & (~1));
29113         obj_conv.is_owned = false;
29114         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29115         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
29116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29118         CVec_u8Z_free(ret_var);
29119         return ret_arr;
29120 }
29121
29122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29123         LDKChannelManagerReadArgs this_obj_conv;
29124         this_obj_conv.inner = (void*)(this_obj & (~1));
29125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29127         ChannelManagerReadArgs_free(this_obj_conv);
29128 }
29129
29130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
29131         LDKChannelManagerReadArgs this_ptr_conv;
29132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29133         this_ptr_conv.is_owned = false;
29134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29135         // WARNING: This object doesn't live past this scope, needs clone!
29136         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
29137         return ret_ret;
29138 }
29139
29140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29141         LDKChannelManagerReadArgs this_ptr_conv;
29142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29143         this_ptr_conv.is_owned = false;
29144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29145         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29146         CHECK_ACCESS(val_ptr);
29147         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
29148         if (val_conv.free == LDKKeysInterface_JCalls_free) {
29149                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29150                 LDKKeysInterface_JCalls_cloned(&val_conv);
29151         }
29152         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
29153 }
29154
29155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
29156         LDKChannelManagerReadArgs this_ptr_conv;
29157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29158         this_ptr_conv.is_owned = false;
29159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29160         // WARNING: This object doesn't live past this scope, needs clone!
29161         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
29162         return ret_ret;
29163 }
29164
29165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29166         LDKChannelManagerReadArgs this_ptr_conv;
29167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29168         this_ptr_conv.is_owned = false;
29169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29170         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29171         CHECK_ACCESS(val_ptr);
29172         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
29173         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
29174                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29175                 LDKFeeEstimator_JCalls_cloned(&val_conv);
29176         }
29177         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
29178 }
29179
29180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
29181         LDKChannelManagerReadArgs this_ptr_conv;
29182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29183         this_ptr_conv.is_owned = false;
29184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29185         // WARNING: This object doesn't live past this scope, needs clone!
29186         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
29187         return ret_ret;
29188 }
29189
29190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29191         LDKChannelManagerReadArgs this_ptr_conv;
29192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29193         this_ptr_conv.is_owned = false;
29194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29195         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29196         CHECK_ACCESS(val_ptr);
29197         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
29198         if (val_conv.free == LDKWatch_JCalls_free) {
29199                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29200                 LDKWatch_JCalls_cloned(&val_conv);
29201         }
29202         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
29203 }
29204
29205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
29206         LDKChannelManagerReadArgs this_ptr_conv;
29207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29208         this_ptr_conv.is_owned = false;
29209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29210         // WARNING: This object doesn't live past this scope, needs clone!
29211         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
29212         return ret_ret;
29213 }
29214
29215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29216         LDKChannelManagerReadArgs this_ptr_conv;
29217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29218         this_ptr_conv.is_owned = false;
29219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29220         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29221         CHECK_ACCESS(val_ptr);
29222         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
29223         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
29224                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29225                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
29226         }
29227         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
29228 }
29229
29230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
29231         LDKChannelManagerReadArgs this_ptr_conv;
29232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29233         this_ptr_conv.is_owned = false;
29234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29235         // WARNING: This object doesn't live past this scope, needs clone!
29236         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
29237         return ret_ret;
29238 }
29239
29240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29241         LDKChannelManagerReadArgs this_ptr_conv;
29242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29243         this_ptr_conv.is_owned = false;
29244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29245         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29246         CHECK_ACCESS(val_ptr);
29247         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
29248         if (val_conv.free == LDKLogger_JCalls_free) {
29249                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29250                 LDKLogger_JCalls_cloned(&val_conv);
29251         }
29252         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
29253 }
29254
29255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
29256         LDKChannelManagerReadArgs this_ptr_conv;
29257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29258         this_ptr_conv.is_owned = false;
29259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29260         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
29261         int64_t ret_ref = 0;
29262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29265         ret_ref = (uintptr_t)ret_var.inner;
29266         if (ret_var.is_owned) {
29267                 ret_ref |= 1;
29268         }
29269         return ret_ref;
29270 }
29271
29272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29273         LDKChannelManagerReadArgs this_ptr_conv;
29274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29275         this_ptr_conv.is_owned = false;
29276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29277         LDKUserConfig val_conv;
29278         val_conv.inner = (void*)(val & (~1));
29279         val_conv.is_owned = (val & 1) || (val == 0);
29280         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29281         val_conv = UserConfig_clone(&val_conv);
29282         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
29283 }
29284
29285 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) {
29286         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
29287         CHECK_ACCESS(keys_manager_ptr);
29288         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
29289         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29290                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29291                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29292         }
29293         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
29294         CHECK_ACCESS(fee_estimator_ptr);
29295         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29296         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29297                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29298                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29299         }
29300         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
29301         CHECK_ACCESS(chain_monitor_ptr);
29302         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
29303         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
29304                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29305                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
29306         }
29307         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
29308         CHECK_ACCESS(tx_broadcaster_ptr);
29309         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
29310         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29311                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29312                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
29313         }
29314         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
29315         CHECK_ACCESS(logger_ptr);
29316         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29317         if (logger_conv.free == LDKLogger_JCalls_free) {
29318                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29319                 LDKLogger_JCalls_cloned(&logger_conv);
29320         }
29321         LDKUserConfig default_config_conv;
29322         default_config_conv.inner = (void*)(default_config & (~1));
29323         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
29324         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
29325         default_config_conv = UserConfig_clone(&default_config_conv);
29326         LDKCVec_ChannelMonitorZ channel_monitors_constr;
29327         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
29328         if (channel_monitors_constr.datalen > 0)
29329                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
29330         else
29331                 channel_monitors_constr.data = NULL;
29332         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
29333         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
29334                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
29335                 LDKChannelMonitor channel_monitors_conv_16_conv;
29336                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
29337                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
29338                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
29339                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
29340         }
29341         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
29342         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);
29343         int64_t ret_ref = 0;
29344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29347         ret_ref = (uintptr_t)ret_var.inner;
29348         if (ret_var.is_owned) {
29349                 ret_ref |= 1;
29350         }
29351         return ret_ref;
29352 }
29353
29354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
29355         LDKu8slice ser_ref;
29356         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29357         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29358         LDKChannelManagerReadArgs arg_conv;
29359         arg_conv.inner = (void*)(arg & (~1));
29360         arg_conv.is_owned = (arg & 1) || (arg == 0);
29361         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29362         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
29363         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
29364         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
29365         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29366         return (int64_t)ret_conv;
29367 }
29368
29369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29370         LDKDecodeError this_obj_conv;
29371         this_obj_conv.inner = (void*)(this_obj & (~1));
29372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29374         DecodeError_free(this_obj_conv);
29375 }
29376
29377 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
29378         LDKDecodeError ret_var = DecodeError_clone(arg);
29379 int64_t ret_ref = 0;
29380 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29381 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29382 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29383 ret_ref = (uintptr_t)ret_var.inner;
29384 if (ret_var.is_owned) {
29385         ret_ref |= 1;
29386 }
29387         return ret_ref;
29388 }
29389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29390         LDKDecodeError arg_conv;
29391         arg_conv.inner = (void*)(arg & (~1));
29392         arg_conv.is_owned = false;
29393         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29394         int64_t ret_val = DecodeError_clone_ptr(&arg_conv);
29395         return ret_val;
29396 }
29397
29398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29399         LDKDecodeError orig_conv;
29400         orig_conv.inner = (void*)(orig & (~1));
29401         orig_conv.is_owned = false;
29402         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29403         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
29404         int64_t ret_ref = 0;
29405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29408         ret_ref = (uintptr_t)ret_var.inner;
29409         if (ret_var.is_owned) {
29410                 ret_ref |= 1;
29411         }
29412         return ret_ref;
29413 }
29414
29415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29416         LDKInit this_obj_conv;
29417         this_obj_conv.inner = (void*)(this_obj & (~1));
29418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29420         Init_free(this_obj_conv);
29421 }
29422
29423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29424         LDKInit this_ptr_conv;
29425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29426         this_ptr_conv.is_owned = false;
29427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29428         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
29429         int64_t ret_ref = 0;
29430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29433         ret_ref = (uintptr_t)ret_var.inner;
29434         if (ret_var.is_owned) {
29435                 ret_ref |= 1;
29436         }
29437         return ret_ref;
29438 }
29439
29440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29441         LDKInit this_ptr_conv;
29442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29443         this_ptr_conv.is_owned = false;
29444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29445         LDKInitFeatures val_conv;
29446         val_conv.inner = (void*)(val & (~1));
29447         val_conv.is_owned = (val & 1) || (val == 0);
29448         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29449         val_conv = InitFeatures_clone(&val_conv);
29450         Init_set_features(&this_ptr_conv, val_conv);
29451 }
29452
29453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
29454         LDKInitFeatures features_arg_conv;
29455         features_arg_conv.inner = (void*)(features_arg & (~1));
29456         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29457         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29458         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29459         LDKInit ret_var = Init_new(features_arg_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 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
29472         LDKInit ret_var = Init_clone(arg);
29473 int64_t ret_ref = 0;
29474 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29475 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29476 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29477 ret_ref = (uintptr_t)ret_var.inner;
29478 if (ret_var.is_owned) {
29479         ret_ref |= 1;
29480 }
29481         return ret_ref;
29482 }
29483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29484         LDKInit arg_conv;
29485         arg_conv.inner = (void*)(arg & (~1));
29486         arg_conv.is_owned = false;
29487         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29488         int64_t ret_val = Init_clone_ptr(&arg_conv);
29489         return ret_val;
29490 }
29491
29492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29493         LDKInit orig_conv;
29494         orig_conv.inner = (void*)(orig & (~1));
29495         orig_conv.is_owned = false;
29496         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29497         LDKInit ret_var = Init_clone(&orig_conv);
29498         int64_t ret_ref = 0;
29499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29502         ret_ref = (uintptr_t)ret_var.inner;
29503         if (ret_var.is_owned) {
29504                 ret_ref |= 1;
29505         }
29506         return ret_ref;
29507 }
29508
29509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29510         LDKErrorMessage this_obj_conv;
29511         this_obj_conv.inner = (void*)(this_obj & (~1));
29512         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29514         ErrorMessage_free(this_obj_conv);
29515 }
29516
29517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29518         LDKErrorMessage this_ptr_conv;
29519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29520         this_ptr_conv.is_owned = false;
29521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29522         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29523         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
29524         return ret_arr;
29525 }
29526
29527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29528         LDKErrorMessage this_ptr_conv;
29529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29530         this_ptr_conv.is_owned = false;
29531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29532         LDKThirtyTwoBytes val_ref;
29533         CHECK((*env)->GetArrayLength(env, val) == 32);
29534         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29535         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
29536 }
29537
29538 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
29539         LDKErrorMessage this_ptr_conv;
29540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29541         this_ptr_conv.is_owned = false;
29542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29543         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
29544         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29545         Str_free(ret_str);
29546         return ret_conv;
29547 }
29548
29549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
29550         LDKErrorMessage this_ptr_conv;
29551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29552         this_ptr_conv.is_owned = false;
29553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29554         LDKStr val_conv = java_to_owned_str(env, val);
29555         ErrorMessage_set_data(&this_ptr_conv, val_conv);
29556 }
29557
29558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
29559         LDKThirtyTwoBytes channel_id_arg_ref;
29560         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29561         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29562         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
29563         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
29564         int64_t ret_ref = 0;
29565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29568         ret_ref = (uintptr_t)ret_var.inner;
29569         if (ret_var.is_owned) {
29570                 ret_ref |= 1;
29571         }
29572         return ret_ref;
29573 }
29574
29575 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
29576         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
29577 int64_t ret_ref = 0;
29578 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29579 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29580 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29581 ret_ref = (uintptr_t)ret_var.inner;
29582 if (ret_var.is_owned) {
29583         ret_ref |= 1;
29584 }
29585         return ret_ref;
29586 }
29587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29588         LDKErrorMessage arg_conv;
29589         arg_conv.inner = (void*)(arg & (~1));
29590         arg_conv.is_owned = false;
29591         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29592         int64_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
29593         return ret_val;
29594 }
29595
29596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29597         LDKErrorMessage orig_conv;
29598         orig_conv.inner = (void*)(orig & (~1));
29599         orig_conv.is_owned = false;
29600         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29601         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
29602         int64_t ret_ref = 0;
29603         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29604         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29606         ret_ref = (uintptr_t)ret_var.inner;
29607         if (ret_var.is_owned) {
29608                 ret_ref |= 1;
29609         }
29610         return ret_ref;
29611 }
29612
29613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29614         LDKWarningMessage this_obj_conv;
29615         this_obj_conv.inner = (void*)(this_obj & (~1));
29616         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29618         WarningMessage_free(this_obj_conv);
29619 }
29620
29621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29622         LDKWarningMessage this_ptr_conv;
29623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29624         this_ptr_conv.is_owned = false;
29625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29626         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29627         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
29628         return ret_arr;
29629 }
29630
29631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29632         LDKWarningMessage this_ptr_conv;
29633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29634         this_ptr_conv.is_owned = false;
29635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29636         LDKThirtyTwoBytes val_ref;
29637         CHECK((*env)->GetArrayLength(env, val) == 32);
29638         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29639         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
29640 }
29641
29642 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
29643         LDKWarningMessage this_ptr_conv;
29644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29645         this_ptr_conv.is_owned = false;
29646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29647         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
29648         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29649         Str_free(ret_str);
29650         return ret_conv;
29651 }
29652
29653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
29654         LDKWarningMessage this_ptr_conv;
29655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29656         this_ptr_conv.is_owned = false;
29657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29658         LDKStr val_conv = java_to_owned_str(env, val);
29659         WarningMessage_set_data(&this_ptr_conv, val_conv);
29660 }
29661
29662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
29663         LDKThirtyTwoBytes channel_id_arg_ref;
29664         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29665         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29666         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
29667         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
29668         int64_t ret_ref = 0;
29669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29672         ret_ref = (uintptr_t)ret_var.inner;
29673         if (ret_var.is_owned) {
29674                 ret_ref |= 1;
29675         }
29676         return ret_ref;
29677 }
29678
29679 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
29680         LDKWarningMessage ret_var = WarningMessage_clone(arg);
29681 int64_t ret_ref = 0;
29682 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29683 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29684 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29685 ret_ref = (uintptr_t)ret_var.inner;
29686 if (ret_var.is_owned) {
29687         ret_ref |= 1;
29688 }
29689         return ret_ref;
29690 }
29691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29692         LDKWarningMessage arg_conv;
29693         arg_conv.inner = (void*)(arg & (~1));
29694         arg_conv.is_owned = false;
29695         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29696         int64_t ret_val = WarningMessage_clone_ptr(&arg_conv);
29697         return ret_val;
29698 }
29699
29700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29701         LDKWarningMessage orig_conv;
29702         orig_conv.inner = (void*)(orig & (~1));
29703         orig_conv.is_owned = false;
29704         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29705         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
29706         int64_t ret_ref = 0;
29707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29710         ret_ref = (uintptr_t)ret_var.inner;
29711         if (ret_var.is_owned) {
29712                 ret_ref |= 1;
29713         }
29714         return ret_ref;
29715 }
29716
29717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29718         LDKPing this_obj_conv;
29719         this_obj_conv.inner = (void*)(this_obj & (~1));
29720         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29722         Ping_free(this_obj_conv);
29723 }
29724
29725 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
29726         LDKPing this_ptr_conv;
29727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29728         this_ptr_conv.is_owned = false;
29729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29730         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
29731         return ret_val;
29732 }
29733
29734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29735         LDKPing this_ptr_conv;
29736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29737         this_ptr_conv.is_owned = false;
29738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29739         Ping_set_ponglen(&this_ptr_conv, val);
29740 }
29741
29742 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
29743         LDKPing this_ptr_conv;
29744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29745         this_ptr_conv.is_owned = false;
29746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29747         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
29748         return ret_val;
29749 }
29750
29751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29752         LDKPing this_ptr_conv;
29753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29754         this_ptr_conv.is_owned = false;
29755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29756         Ping_set_byteslen(&this_ptr_conv, val);
29757 }
29758
29759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
29760         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
29761         int64_t ret_ref = 0;
29762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29765         ret_ref = (uintptr_t)ret_var.inner;
29766         if (ret_var.is_owned) {
29767                 ret_ref |= 1;
29768         }
29769         return ret_ref;
29770 }
29771
29772 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
29773         LDKPing ret_var = Ping_clone(arg);
29774 int64_t ret_ref = 0;
29775 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29776 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29777 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29778 ret_ref = (uintptr_t)ret_var.inner;
29779 if (ret_var.is_owned) {
29780         ret_ref |= 1;
29781 }
29782         return ret_ref;
29783 }
29784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29785         LDKPing arg_conv;
29786         arg_conv.inner = (void*)(arg & (~1));
29787         arg_conv.is_owned = false;
29788         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29789         int64_t ret_val = Ping_clone_ptr(&arg_conv);
29790         return ret_val;
29791 }
29792
29793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29794         LDKPing orig_conv;
29795         orig_conv.inner = (void*)(orig & (~1));
29796         orig_conv.is_owned = false;
29797         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29798         LDKPing ret_var = Ping_clone(&orig_conv);
29799         int64_t ret_ref = 0;
29800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29803         ret_ref = (uintptr_t)ret_var.inner;
29804         if (ret_var.is_owned) {
29805                 ret_ref |= 1;
29806         }
29807         return ret_ref;
29808 }
29809
29810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29811         LDKPong this_obj_conv;
29812         this_obj_conv.inner = (void*)(this_obj & (~1));
29813         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29815         Pong_free(this_obj_conv);
29816 }
29817
29818 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
29819         LDKPong this_ptr_conv;
29820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29821         this_ptr_conv.is_owned = false;
29822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29823         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
29824         return ret_val;
29825 }
29826
29827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29828         LDKPong this_ptr_conv;
29829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29830         this_ptr_conv.is_owned = false;
29831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29832         Pong_set_byteslen(&this_ptr_conv, val);
29833 }
29834
29835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
29836         LDKPong ret_var = Pong_new(byteslen_arg);
29837         int64_t ret_ref = 0;
29838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29841         ret_ref = (uintptr_t)ret_var.inner;
29842         if (ret_var.is_owned) {
29843                 ret_ref |= 1;
29844         }
29845         return ret_ref;
29846 }
29847
29848 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
29849         LDKPong ret_var = Pong_clone(arg);
29850 int64_t ret_ref = 0;
29851 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29852 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29853 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29854 ret_ref = (uintptr_t)ret_var.inner;
29855 if (ret_var.is_owned) {
29856         ret_ref |= 1;
29857 }
29858         return ret_ref;
29859 }
29860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29861         LDKPong arg_conv;
29862         arg_conv.inner = (void*)(arg & (~1));
29863         arg_conv.is_owned = false;
29864         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29865         int64_t ret_val = Pong_clone_ptr(&arg_conv);
29866         return ret_val;
29867 }
29868
29869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29870         LDKPong orig_conv;
29871         orig_conv.inner = (void*)(orig & (~1));
29872         orig_conv.is_owned = false;
29873         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29874         LDKPong ret_var = Pong_clone(&orig_conv);
29875         int64_t ret_ref = 0;
29876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29879         ret_ref = (uintptr_t)ret_var.inner;
29880         if (ret_var.is_owned) {
29881                 ret_ref |= 1;
29882         }
29883         return ret_ref;
29884 }
29885
29886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29887         LDKOpenChannel this_obj_conv;
29888         this_obj_conv.inner = (void*)(this_obj & (~1));
29889         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29891         OpenChannel_free(this_obj_conv);
29892 }
29893
29894 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29895         LDKOpenChannel this_ptr_conv;
29896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29897         this_ptr_conv.is_owned = false;
29898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29899         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29900         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
29901         return ret_arr;
29902 }
29903
29904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29905         LDKOpenChannel this_ptr_conv;
29906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29907         this_ptr_conv.is_owned = false;
29908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29909         LDKThirtyTwoBytes val_ref;
29910         CHECK((*env)->GetArrayLength(env, val) == 32);
29911         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29912         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
29913 }
29914
29915 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29916         LDKOpenChannel this_ptr_conv;
29917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29918         this_ptr_conv.is_owned = false;
29919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29920         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29921         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
29922         return ret_arr;
29923 }
29924
29925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29926         LDKOpenChannel this_ptr_conv;
29927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29928         this_ptr_conv.is_owned = false;
29929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29930         LDKThirtyTwoBytes val_ref;
29931         CHECK((*env)->GetArrayLength(env, val) == 32);
29932         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29933         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
29934 }
29935
29936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29937         LDKOpenChannel this_ptr_conv;
29938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29939         this_ptr_conv.is_owned = false;
29940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29941         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
29942         return ret_val;
29943 }
29944
29945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29946         LDKOpenChannel this_ptr_conv;
29947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29948         this_ptr_conv.is_owned = false;
29949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29950         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
29951 }
29952
29953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29954         LDKOpenChannel 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         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
29959         return ret_val;
29960 }
29961
29962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29963         LDKOpenChannel this_ptr_conv;
29964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29965         this_ptr_conv.is_owned = false;
29966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29967         OpenChannel_set_push_msat(&this_ptr_conv, val);
29968 }
29969
29970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29971         LDKOpenChannel this_ptr_conv;
29972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29973         this_ptr_conv.is_owned = false;
29974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29975         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
29976         return ret_val;
29977 }
29978
29979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29980         LDKOpenChannel this_ptr_conv;
29981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29982         this_ptr_conv.is_owned = false;
29983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29984         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
29985 }
29986
29987 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) {
29988         LDKOpenChannel 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         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
29993         return ret_val;
29994 }
29995
29996 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) {
29997         LDKOpenChannel this_ptr_conv;
29998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29999         this_ptr_conv.is_owned = false;
30000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30001         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
30002 }
30003
30004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30005         LDKOpenChannel this_ptr_conv;
30006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30007         this_ptr_conv.is_owned = false;
30008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30009         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
30010         return ret_val;
30011 }
30012
30013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30014         LDKOpenChannel this_ptr_conv;
30015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30016         this_ptr_conv.is_owned = false;
30017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30018         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
30019 }
30020
30021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30022         LDKOpenChannel this_ptr_conv;
30023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30024         this_ptr_conv.is_owned = false;
30025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30026         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
30027         return ret_val;
30028 }
30029
30030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30031         LDKOpenChannel this_ptr_conv;
30032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30033         this_ptr_conv.is_owned = false;
30034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30035         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
30036 }
30037
30038 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
30039         LDKOpenChannel this_ptr_conv;
30040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30041         this_ptr_conv.is_owned = false;
30042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30043         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
30044         return ret_val;
30045 }
30046
30047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30048         LDKOpenChannel this_ptr_conv;
30049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30050         this_ptr_conv.is_owned = false;
30051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30052         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
30053 }
30054
30055 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30056         LDKOpenChannel this_ptr_conv;
30057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30058         this_ptr_conv.is_owned = false;
30059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30060         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
30061         return ret_val;
30062 }
30063
30064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30065         LDKOpenChannel this_ptr_conv;
30066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30067         this_ptr_conv.is_owned = false;
30068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30069         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
30070 }
30071
30072 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30073         LDKOpenChannel this_ptr_conv;
30074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30075         this_ptr_conv.is_owned = false;
30076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30077         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
30078         return ret_val;
30079 }
30080
30081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30082         LDKOpenChannel this_ptr_conv;
30083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30084         this_ptr_conv.is_owned = false;
30085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30086         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
30087 }
30088
30089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30090         LDKOpenChannel this_ptr_conv;
30091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30092         this_ptr_conv.is_owned = false;
30093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30094         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30095         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
30096         return ret_arr;
30097 }
30098
30099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30100         LDKOpenChannel 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         LDKPublicKey val_ref;
30105         CHECK((*env)->GetArrayLength(env, val) == 33);
30106         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30107         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
30108 }
30109
30110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30111         LDKOpenChannel this_ptr_conv;
30112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30113         this_ptr_conv.is_owned = false;
30114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30115         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
30117         return ret_arr;
30118 }
30119
30120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30121         LDKOpenChannel this_ptr_conv;
30122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30123         this_ptr_conv.is_owned = false;
30124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30125         LDKPublicKey val_ref;
30126         CHECK((*env)->GetArrayLength(env, val) == 33);
30127         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30128         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
30129 }
30130
30131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30132         LDKOpenChannel this_ptr_conv;
30133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30134         this_ptr_conv.is_owned = false;
30135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30136         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30137         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
30138         return ret_arr;
30139 }
30140
30141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30142         LDKOpenChannel this_ptr_conv;
30143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30144         this_ptr_conv.is_owned = false;
30145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30146         LDKPublicKey val_ref;
30147         CHECK((*env)->GetArrayLength(env, val) == 33);
30148         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30149         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
30150 }
30151
30152 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30153         LDKOpenChannel this_ptr_conv;
30154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30155         this_ptr_conv.is_owned = false;
30156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30157         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30158         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
30159         return ret_arr;
30160 }
30161
30162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30163         LDKOpenChannel this_ptr_conv;
30164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30165         this_ptr_conv.is_owned = false;
30166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30167         LDKPublicKey val_ref;
30168         CHECK((*env)->GetArrayLength(env, val) == 33);
30169         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30170         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
30171 }
30172
30173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30174         LDKOpenChannel this_ptr_conv;
30175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30176         this_ptr_conv.is_owned = false;
30177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30178         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30179         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
30180         return ret_arr;
30181 }
30182
30183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30184         LDKOpenChannel this_ptr_conv;
30185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30186         this_ptr_conv.is_owned = false;
30187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30188         LDKPublicKey val_ref;
30189         CHECK((*env)->GetArrayLength(env, val) == 33);
30190         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30191         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
30192 }
30193
30194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30195         LDKOpenChannel this_ptr_conv;
30196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30197         this_ptr_conv.is_owned = false;
30198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30199         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30200         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
30201         return ret_arr;
30202 }
30203
30204 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) {
30205         LDKOpenChannel 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         LDKPublicKey val_ref;
30210         CHECK((*env)->GetArrayLength(env, val) == 33);
30211         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30212         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
30213 }
30214
30215 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
30216         LDKOpenChannel this_ptr_conv;
30217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30218         this_ptr_conv.is_owned = false;
30219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30220         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
30221         return ret_val;
30222 }
30223
30224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
30225         LDKOpenChannel this_ptr_conv;
30226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30227         this_ptr_conv.is_owned = false;
30228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30229         OpenChannel_set_channel_flags(&this_ptr_conv, val);
30230 }
30231
30232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30233         LDKOpenChannel this_ptr_conv;
30234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30235         this_ptr_conv.is_owned = false;
30236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30237         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
30238         int64_t ret_ref = 0;
30239         if ((uintptr_t)ret_var.inner > 4096) {
30240                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30241                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30243                 ret_ref = (uintptr_t)ret_var.inner;
30244                 if (ret_var.is_owned) {
30245                         ret_ref |= 1;
30246                 }
30247         }
30248         return ret_ref;
30249 }
30250
30251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30252         LDKOpenChannel this_ptr_conv;
30253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30254         this_ptr_conv.is_owned = false;
30255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30256         LDKChannelTypeFeatures val_conv;
30257         val_conv.inner = (void*)(val & (~1));
30258         val_conv.is_owned = (val & 1) || (val == 0);
30259         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30260         val_conv = ChannelTypeFeatures_clone(&val_conv);
30261         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
30262 }
30263
30264 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
30265         LDKOpenChannel ret_var = OpenChannel_clone(arg);
30266 int64_t ret_ref = 0;
30267 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30268 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30269 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30270 ret_ref = (uintptr_t)ret_var.inner;
30271 if (ret_var.is_owned) {
30272         ret_ref |= 1;
30273 }
30274         return ret_ref;
30275 }
30276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30277         LDKOpenChannel arg_conv;
30278         arg_conv.inner = (void*)(arg & (~1));
30279         arg_conv.is_owned = false;
30280         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30281         int64_t ret_val = OpenChannel_clone_ptr(&arg_conv);
30282         return ret_val;
30283 }
30284
30285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30286         LDKOpenChannel orig_conv;
30287         orig_conv.inner = (void*)(orig & (~1));
30288         orig_conv.is_owned = false;
30289         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30290         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
30291         int64_t ret_ref = 0;
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         return ret_ref;
30300 }
30301
30302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30303         LDKAcceptChannel this_obj_conv;
30304         this_obj_conv.inner = (void*)(this_obj & (~1));
30305         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30307         AcceptChannel_free(this_obj_conv);
30308 }
30309
30310 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30311         LDKAcceptChannel this_ptr_conv;
30312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30313         this_ptr_conv.is_owned = false;
30314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30315         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30316         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
30317         return ret_arr;
30318 }
30319
30320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30321         LDKAcceptChannel this_ptr_conv;
30322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30323         this_ptr_conv.is_owned = false;
30324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30325         LDKThirtyTwoBytes val_ref;
30326         CHECK((*env)->GetArrayLength(env, val) == 32);
30327         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30328         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
30329 }
30330
30331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30332         LDKAcceptChannel this_ptr_conv;
30333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30334         this_ptr_conv.is_owned = false;
30335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30336         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
30337         return ret_val;
30338 }
30339
30340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30341         LDKAcceptChannel this_ptr_conv;
30342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30343         this_ptr_conv.is_owned = false;
30344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30345         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
30346 }
30347
30348 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) {
30349         LDKAcceptChannel this_ptr_conv;
30350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30351         this_ptr_conv.is_owned = false;
30352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30353         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
30354         return ret_val;
30355 }
30356
30357 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) {
30358         LDKAcceptChannel this_ptr_conv;
30359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30360         this_ptr_conv.is_owned = false;
30361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30362         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
30363 }
30364
30365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30366         LDKAcceptChannel this_ptr_conv;
30367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30368         this_ptr_conv.is_owned = false;
30369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30370         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
30371         return ret_val;
30372 }
30373
30374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30375         LDKAcceptChannel this_ptr_conv;
30376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30377         this_ptr_conv.is_owned = false;
30378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30379         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
30380 }
30381
30382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30383         LDKAcceptChannel this_ptr_conv;
30384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30385         this_ptr_conv.is_owned = false;
30386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30387         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
30388         return ret_val;
30389 }
30390
30391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30392         LDKAcceptChannel this_ptr_conv;
30393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30394         this_ptr_conv.is_owned = false;
30395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30396         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
30397 }
30398
30399 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
30400         LDKAcceptChannel this_ptr_conv;
30401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30402         this_ptr_conv.is_owned = false;
30403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30404         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
30405         return ret_val;
30406 }
30407
30408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30409         LDKAcceptChannel this_ptr_conv;
30410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30411         this_ptr_conv.is_owned = false;
30412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30413         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
30414 }
30415
30416 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30417         LDKAcceptChannel this_ptr_conv;
30418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30419         this_ptr_conv.is_owned = false;
30420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30421         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
30422         return ret_val;
30423 }
30424
30425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30426         LDKAcceptChannel this_ptr_conv;
30427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30428         this_ptr_conv.is_owned = false;
30429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30430         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
30431 }
30432
30433 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30434         LDKAcceptChannel this_ptr_conv;
30435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30436         this_ptr_conv.is_owned = false;
30437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30438         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
30439         return ret_val;
30440 }
30441
30442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30443         LDKAcceptChannel this_ptr_conv;
30444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30445         this_ptr_conv.is_owned = false;
30446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30447         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
30448 }
30449
30450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30451         LDKAcceptChannel this_ptr_conv;
30452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30453         this_ptr_conv.is_owned = false;
30454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30455         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30456         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
30457         return ret_arr;
30458 }
30459
30460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30461         LDKAcceptChannel this_ptr_conv;
30462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30463         this_ptr_conv.is_owned = false;
30464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30465         LDKPublicKey val_ref;
30466         CHECK((*env)->GetArrayLength(env, val) == 33);
30467         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30468         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
30469 }
30470
30471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30472         LDKAcceptChannel this_ptr_conv;
30473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30474         this_ptr_conv.is_owned = false;
30475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30476         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30477         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
30478         return ret_arr;
30479 }
30480
30481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30482         LDKAcceptChannel this_ptr_conv;
30483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30484         this_ptr_conv.is_owned = false;
30485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30486         LDKPublicKey val_ref;
30487         CHECK((*env)->GetArrayLength(env, val) == 33);
30488         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30489         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
30490 }
30491
30492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30493         LDKAcceptChannel this_ptr_conv;
30494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30495         this_ptr_conv.is_owned = false;
30496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30497         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
30499         return ret_arr;
30500 }
30501
30502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30503         LDKAcceptChannel this_ptr_conv;
30504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30505         this_ptr_conv.is_owned = false;
30506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30507         LDKPublicKey val_ref;
30508         CHECK((*env)->GetArrayLength(env, val) == 33);
30509         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30510         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
30511 }
30512
30513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30514         LDKAcceptChannel this_ptr_conv;
30515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30516         this_ptr_conv.is_owned = false;
30517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30518         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30519         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
30520         return ret_arr;
30521 }
30522
30523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30524         LDKAcceptChannel this_ptr_conv;
30525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30526         this_ptr_conv.is_owned = false;
30527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30528         LDKPublicKey val_ref;
30529         CHECK((*env)->GetArrayLength(env, val) == 33);
30530         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30531         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
30532 }
30533
30534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30535         LDKAcceptChannel this_ptr_conv;
30536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30537         this_ptr_conv.is_owned = false;
30538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30539         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30540         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
30541         return ret_arr;
30542 }
30543
30544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30545         LDKAcceptChannel this_ptr_conv;
30546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30547         this_ptr_conv.is_owned = false;
30548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30549         LDKPublicKey val_ref;
30550         CHECK((*env)->GetArrayLength(env, val) == 33);
30551         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30552         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
30553 }
30554
30555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30556         LDKAcceptChannel this_ptr_conv;
30557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30558         this_ptr_conv.is_owned = false;
30559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30560         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30561         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
30562         return ret_arr;
30563 }
30564
30565 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) {
30566         LDKAcceptChannel this_ptr_conv;
30567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30568         this_ptr_conv.is_owned = false;
30569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30570         LDKPublicKey val_ref;
30571         CHECK((*env)->GetArrayLength(env, val) == 33);
30572         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30573         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
30574 }
30575
30576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30577         LDKAcceptChannel this_ptr_conv;
30578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30579         this_ptr_conv.is_owned = false;
30580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30581         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
30582         int64_t ret_ref = 0;
30583         if ((uintptr_t)ret_var.inner > 4096) {
30584                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30585                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30587                 ret_ref = (uintptr_t)ret_var.inner;
30588                 if (ret_var.is_owned) {
30589                         ret_ref |= 1;
30590                 }
30591         }
30592         return ret_ref;
30593 }
30594
30595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30596         LDKAcceptChannel this_ptr_conv;
30597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30598         this_ptr_conv.is_owned = false;
30599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30600         LDKChannelTypeFeatures val_conv;
30601         val_conv.inner = (void*)(val & (~1));
30602         val_conv.is_owned = (val & 1) || (val == 0);
30603         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30604         val_conv = ChannelTypeFeatures_clone(&val_conv);
30605         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
30606 }
30607
30608 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
30609         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
30610 int64_t ret_ref = 0;
30611 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30612 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30613 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30614 ret_ref = (uintptr_t)ret_var.inner;
30615 if (ret_var.is_owned) {
30616         ret_ref |= 1;
30617 }
30618         return ret_ref;
30619 }
30620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30621         LDKAcceptChannel arg_conv;
30622         arg_conv.inner = (void*)(arg & (~1));
30623         arg_conv.is_owned = false;
30624         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30625         int64_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
30626         return ret_val;
30627 }
30628
30629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30630         LDKAcceptChannel orig_conv;
30631         orig_conv.inner = (void*)(orig & (~1));
30632         orig_conv.is_owned = false;
30633         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30634         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
30635         int64_t ret_ref = 0;
30636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30639         ret_ref = (uintptr_t)ret_var.inner;
30640         if (ret_var.is_owned) {
30641                 ret_ref |= 1;
30642         }
30643         return ret_ref;
30644 }
30645
30646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30647         LDKFundingCreated this_obj_conv;
30648         this_obj_conv.inner = (void*)(this_obj & (~1));
30649         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30651         FundingCreated_free(this_obj_conv);
30652 }
30653
30654 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30655         LDKFundingCreated this_ptr_conv;
30656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30657         this_ptr_conv.is_owned = false;
30658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30659         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30660         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
30661         return ret_arr;
30662 }
30663
30664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30665         LDKFundingCreated this_ptr_conv;
30666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30667         this_ptr_conv.is_owned = false;
30668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30669         LDKThirtyTwoBytes val_ref;
30670         CHECK((*env)->GetArrayLength(env, val) == 32);
30671         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30672         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
30673 }
30674
30675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30676         LDKFundingCreated this_ptr_conv;
30677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30678         this_ptr_conv.is_owned = false;
30679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30680         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30681         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
30682         return ret_arr;
30683 }
30684
30685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30686         LDKFundingCreated this_ptr_conv;
30687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30688         this_ptr_conv.is_owned = false;
30689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30690         LDKThirtyTwoBytes val_ref;
30691         CHECK((*env)->GetArrayLength(env, val) == 32);
30692         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30693         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
30694 }
30695
30696 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
30697         LDKFundingCreated this_ptr_conv;
30698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30699         this_ptr_conv.is_owned = false;
30700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30701         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
30702         return ret_val;
30703 }
30704
30705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30706         LDKFundingCreated this_ptr_conv;
30707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30708         this_ptr_conv.is_owned = false;
30709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30710         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
30711 }
30712
30713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
30714         LDKFundingCreated this_ptr_conv;
30715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30716         this_ptr_conv.is_owned = false;
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30718         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
30719         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
30720         return ret_arr;
30721 }
30722
30723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30724         LDKFundingCreated this_ptr_conv;
30725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30726         this_ptr_conv.is_owned = false;
30727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30728         LDKSignature val_ref;
30729         CHECK((*env)->GetArrayLength(env, val) == 64);
30730         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
30731         FundingCreated_set_signature(&this_ptr_conv, val_ref);
30732 }
30733
30734 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) {
30735         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
30736         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
30737         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
30738         LDKThirtyTwoBytes funding_txid_arg_ref;
30739         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
30740         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
30741         LDKSignature signature_arg_ref;
30742         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
30743         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
30744         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
30745         int64_t ret_ref = 0;
30746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30749         ret_ref = (uintptr_t)ret_var.inner;
30750         if (ret_var.is_owned) {
30751                 ret_ref |= 1;
30752         }
30753         return ret_ref;
30754 }
30755
30756 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
30757         LDKFundingCreated ret_var = FundingCreated_clone(arg);
30758 int64_t ret_ref = 0;
30759 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30760 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30761 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30762 ret_ref = (uintptr_t)ret_var.inner;
30763 if (ret_var.is_owned) {
30764         ret_ref |= 1;
30765 }
30766         return ret_ref;
30767 }
30768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30769         LDKFundingCreated arg_conv;
30770         arg_conv.inner = (void*)(arg & (~1));
30771         arg_conv.is_owned = false;
30772         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30773         int64_t ret_val = FundingCreated_clone_ptr(&arg_conv);
30774         return ret_val;
30775 }
30776
30777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30778         LDKFundingCreated orig_conv;
30779         orig_conv.inner = (void*)(orig & (~1));
30780         orig_conv.is_owned = false;
30781         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30782         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
30783         int64_t ret_ref = 0;
30784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30787         ret_ref = (uintptr_t)ret_var.inner;
30788         if (ret_var.is_owned) {
30789                 ret_ref |= 1;
30790         }
30791         return ret_ref;
30792 }
30793
30794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30795         LDKFundingSigned this_obj_conv;
30796         this_obj_conv.inner = (void*)(this_obj & (~1));
30797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30799         FundingSigned_free(this_obj_conv);
30800 }
30801
30802 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30803         LDKFundingSigned this_ptr_conv;
30804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30805         this_ptr_conv.is_owned = false;
30806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30807         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
30809         return ret_arr;
30810 }
30811
30812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30813         LDKFundingSigned this_ptr_conv;
30814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30815         this_ptr_conv.is_owned = false;
30816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30817         LDKThirtyTwoBytes val_ref;
30818         CHECK((*env)->GetArrayLength(env, val) == 32);
30819         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30820         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
30821 }
30822
30823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
30824         LDKFundingSigned this_ptr_conv;
30825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30826         this_ptr_conv.is_owned = false;
30827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30828         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
30829         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
30830         return ret_arr;
30831 }
30832
30833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30834         LDKFundingSigned this_ptr_conv;
30835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30836         this_ptr_conv.is_owned = false;
30837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30838         LDKSignature val_ref;
30839         CHECK((*env)->GetArrayLength(env, val) == 64);
30840         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
30841         FundingSigned_set_signature(&this_ptr_conv, val_ref);
30842 }
30843
30844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
30845         LDKThirtyTwoBytes channel_id_arg_ref;
30846         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30847         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30848         LDKSignature signature_arg_ref;
30849         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
30850         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
30851         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
30852         int64_t ret_ref = 0;
30853         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30854         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30856         ret_ref = (uintptr_t)ret_var.inner;
30857         if (ret_var.is_owned) {
30858                 ret_ref |= 1;
30859         }
30860         return ret_ref;
30861 }
30862
30863 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
30864         LDKFundingSigned ret_var = FundingSigned_clone(arg);
30865 int64_t ret_ref = 0;
30866 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30867 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30868 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30869 ret_ref = (uintptr_t)ret_var.inner;
30870 if (ret_var.is_owned) {
30871         ret_ref |= 1;
30872 }
30873         return ret_ref;
30874 }
30875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30876         LDKFundingSigned arg_conv;
30877         arg_conv.inner = (void*)(arg & (~1));
30878         arg_conv.is_owned = false;
30879         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30880         int64_t ret_val = FundingSigned_clone_ptr(&arg_conv);
30881         return ret_val;
30882 }
30883
30884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30885         LDKFundingSigned orig_conv;
30886         orig_conv.inner = (void*)(orig & (~1));
30887         orig_conv.is_owned = false;
30888         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30889         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
30890         int64_t ret_ref = 0;
30891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30894         ret_ref = (uintptr_t)ret_var.inner;
30895         if (ret_var.is_owned) {
30896                 ret_ref |= 1;
30897         }
30898         return ret_ref;
30899 }
30900
30901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30902         LDKFundingLocked this_obj_conv;
30903         this_obj_conv.inner = (void*)(this_obj & (~1));
30904         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30906         FundingLocked_free(this_obj_conv);
30907 }
30908
30909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30910         LDKFundingLocked this_ptr_conv;
30911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30912         this_ptr_conv.is_owned = false;
30913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30914         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30915         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
30916         return ret_arr;
30917 }
30918
30919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30920         LDKFundingLocked this_ptr_conv;
30921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30922         this_ptr_conv.is_owned = false;
30923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30924         LDKThirtyTwoBytes val_ref;
30925         CHECK((*env)->GetArrayLength(env, val) == 32);
30926         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30927         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
30928 }
30929
30930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30931         LDKFundingLocked this_ptr_conv;
30932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30933         this_ptr_conv.is_owned = false;
30934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30935         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30936         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
30937         return ret_arr;
30938 }
30939
30940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30941         LDKFundingLocked this_ptr_conv;
30942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30943         this_ptr_conv.is_owned = false;
30944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30945         LDKPublicKey val_ref;
30946         CHECK((*env)->GetArrayLength(env, val) == 33);
30947         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30948         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
30949 }
30950
30951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
30952         LDKThirtyTwoBytes channel_id_arg_ref;
30953         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30954         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30955         LDKPublicKey next_per_commitment_point_arg_ref;
30956         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
30957         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
30958         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
30959         int64_t ret_ref = 0;
30960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30963         ret_ref = (uintptr_t)ret_var.inner;
30964         if (ret_var.is_owned) {
30965                 ret_ref |= 1;
30966         }
30967         return ret_ref;
30968 }
30969
30970 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
30971         LDKFundingLocked ret_var = FundingLocked_clone(arg);
30972 int64_t ret_ref = 0;
30973 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30974 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30975 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30976 ret_ref = (uintptr_t)ret_var.inner;
30977 if (ret_var.is_owned) {
30978         ret_ref |= 1;
30979 }
30980         return ret_ref;
30981 }
30982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30983         LDKFundingLocked arg_conv;
30984         arg_conv.inner = (void*)(arg & (~1));
30985         arg_conv.is_owned = false;
30986         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30987         int64_t ret_val = FundingLocked_clone_ptr(&arg_conv);
30988         return ret_val;
30989 }
30990
30991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30992         LDKFundingLocked orig_conv;
30993         orig_conv.inner = (void*)(orig & (~1));
30994         orig_conv.is_owned = false;
30995         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30996         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
30997         int64_t ret_ref = 0;
30998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31001         ret_ref = (uintptr_t)ret_var.inner;
31002         if (ret_var.is_owned) {
31003                 ret_ref |= 1;
31004         }
31005         return ret_ref;
31006 }
31007
31008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31009         LDKShutdown this_obj_conv;
31010         this_obj_conv.inner = (void*)(this_obj & (~1));
31011         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31013         Shutdown_free(this_obj_conv);
31014 }
31015
31016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31017         LDKShutdown this_ptr_conv;
31018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31019         this_ptr_conv.is_owned = false;
31020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31021         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31022         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
31023         return ret_arr;
31024 }
31025
31026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31027         LDKShutdown this_ptr_conv;
31028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31029         this_ptr_conv.is_owned = false;
31030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31031         LDKThirtyTwoBytes val_ref;
31032         CHECK((*env)->GetArrayLength(env, val) == 32);
31033         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31034         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
31035 }
31036
31037 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31038         LDKShutdown this_ptr_conv;
31039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31040         this_ptr_conv.is_owned = false;
31041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31042         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
31043         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31044         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31045         return ret_arr;
31046 }
31047
31048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31049         LDKShutdown this_ptr_conv;
31050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31051         this_ptr_conv.is_owned = false;
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31053         LDKCVec_u8Z val_ref;
31054         val_ref.datalen = (*env)->GetArrayLength(env, val);
31055         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31056         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
31057         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
31058 }
31059
31060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
31061         LDKThirtyTwoBytes channel_id_arg_ref;
31062         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31063         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31064         LDKCVec_u8Z scriptpubkey_arg_ref;
31065         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
31066         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
31067         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
31068         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
31069         int64_t ret_ref = 0;
31070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31073         ret_ref = (uintptr_t)ret_var.inner;
31074         if (ret_var.is_owned) {
31075                 ret_ref |= 1;
31076         }
31077         return ret_ref;
31078 }
31079
31080 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
31081         LDKShutdown ret_var = Shutdown_clone(arg);
31082 int64_t ret_ref = 0;
31083 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31084 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31085 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31086 ret_ref = (uintptr_t)ret_var.inner;
31087 if (ret_var.is_owned) {
31088         ret_ref |= 1;
31089 }
31090         return ret_ref;
31091 }
31092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31093         LDKShutdown arg_conv;
31094         arg_conv.inner = (void*)(arg & (~1));
31095         arg_conv.is_owned = false;
31096         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31097         int64_t ret_val = Shutdown_clone_ptr(&arg_conv);
31098         return ret_val;
31099 }
31100
31101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31102         LDKShutdown orig_conv;
31103         orig_conv.inner = (void*)(orig & (~1));
31104         orig_conv.is_owned = false;
31105         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31106         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
31107         int64_t ret_ref = 0;
31108         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31109         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31111         ret_ref = (uintptr_t)ret_var.inner;
31112         if (ret_var.is_owned) {
31113                 ret_ref |= 1;
31114         }
31115         return ret_ref;
31116 }
31117
31118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31119         LDKClosingSignedFeeRange this_obj_conv;
31120         this_obj_conv.inner = (void*)(this_obj & (~1));
31121         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31123         ClosingSignedFeeRange_free(this_obj_conv);
31124 }
31125
31126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31127         LDKClosingSignedFeeRange this_ptr_conv;
31128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31129         this_ptr_conv.is_owned = false;
31130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31131         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
31132         return ret_val;
31133 }
31134
31135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31136         LDKClosingSignedFeeRange this_ptr_conv;
31137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31138         this_ptr_conv.is_owned = false;
31139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31140         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
31141 }
31142
31143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31144         LDKClosingSignedFeeRange this_ptr_conv;
31145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31146         this_ptr_conv.is_owned = false;
31147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31148         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
31149         return ret_val;
31150 }
31151
31152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31153         LDKClosingSignedFeeRange this_ptr_conv;
31154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31155         this_ptr_conv.is_owned = false;
31156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31157         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
31158 }
31159
31160 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) {
31161         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
31162         int64_t ret_ref = 0;
31163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31166         ret_ref = (uintptr_t)ret_var.inner;
31167         if (ret_var.is_owned) {
31168                 ret_ref |= 1;
31169         }
31170         return ret_ref;
31171 }
31172
31173 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
31174         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
31175 int64_t ret_ref = 0;
31176 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31177 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31178 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31179 ret_ref = (uintptr_t)ret_var.inner;
31180 if (ret_var.is_owned) {
31181         ret_ref |= 1;
31182 }
31183         return ret_ref;
31184 }
31185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31186         LDKClosingSignedFeeRange arg_conv;
31187         arg_conv.inner = (void*)(arg & (~1));
31188         arg_conv.is_owned = false;
31189         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31190         int64_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
31191         return ret_val;
31192 }
31193
31194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31195         LDKClosingSignedFeeRange orig_conv;
31196         orig_conv.inner = (void*)(orig & (~1));
31197         orig_conv.is_owned = false;
31198         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31199         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
31200         int64_t ret_ref = 0;
31201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31204         ret_ref = (uintptr_t)ret_var.inner;
31205         if (ret_var.is_owned) {
31206                 ret_ref |= 1;
31207         }
31208         return ret_ref;
31209 }
31210
31211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31212         LDKClosingSigned this_obj_conv;
31213         this_obj_conv.inner = (void*)(this_obj & (~1));
31214         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31216         ClosingSigned_free(this_obj_conv);
31217 }
31218
31219 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31220         LDKClosingSigned this_ptr_conv;
31221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31222         this_ptr_conv.is_owned = false;
31223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31224         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31225         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
31226         return ret_arr;
31227 }
31228
31229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31230         LDKClosingSigned this_ptr_conv;
31231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31232         this_ptr_conv.is_owned = false;
31233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31234         LDKThirtyTwoBytes val_ref;
31235         CHECK((*env)->GetArrayLength(env, val) == 32);
31236         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31237         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
31238 }
31239
31240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31241         LDKClosingSigned this_ptr_conv;
31242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31243         this_ptr_conv.is_owned = false;
31244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31245         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
31246         return ret_val;
31247 }
31248
31249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31250         LDKClosingSigned this_ptr_conv;
31251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31252         this_ptr_conv.is_owned = false;
31253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31254         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
31255 }
31256
31257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31258         LDKClosingSigned this_ptr_conv;
31259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31260         this_ptr_conv.is_owned = false;
31261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31262         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31263         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
31264         return ret_arr;
31265 }
31266
31267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31268         LDKClosingSigned this_ptr_conv;
31269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31270         this_ptr_conv.is_owned = false;
31271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31272         LDKSignature val_ref;
31273         CHECK((*env)->GetArrayLength(env, val) == 64);
31274         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31275         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
31276 }
31277
31278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
31279         LDKClosingSigned this_ptr_conv;
31280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31281         this_ptr_conv.is_owned = false;
31282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31283         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
31284         int64_t ret_ref = 0;
31285         if ((uintptr_t)ret_var.inner > 4096) {
31286                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31287                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31289                 ret_ref = (uintptr_t)ret_var.inner;
31290                 if (ret_var.is_owned) {
31291                         ret_ref |= 1;
31292                 }
31293         }
31294         return ret_ref;
31295 }
31296
31297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31298         LDKClosingSigned this_ptr_conv;
31299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31300         this_ptr_conv.is_owned = false;
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31302         LDKClosingSignedFeeRange val_conv;
31303         val_conv.inner = (void*)(val & (~1));
31304         val_conv.is_owned = (val & 1) || (val == 0);
31305         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31306         val_conv = ClosingSignedFeeRange_clone(&val_conv);
31307         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
31308 }
31309
31310 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) {
31311         LDKThirtyTwoBytes channel_id_arg_ref;
31312         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31313         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31314         LDKSignature signature_arg_ref;
31315         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31316         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31317         LDKClosingSignedFeeRange fee_range_arg_conv;
31318         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
31319         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
31320         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
31321         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
31322         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
31323         int64_t ret_ref = 0;
31324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31327         ret_ref = (uintptr_t)ret_var.inner;
31328         if (ret_var.is_owned) {
31329                 ret_ref |= 1;
31330         }
31331         return ret_ref;
31332 }
31333
31334 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
31335         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
31336 int64_t ret_ref = 0;
31337 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31338 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31339 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31340 ret_ref = (uintptr_t)ret_var.inner;
31341 if (ret_var.is_owned) {
31342         ret_ref |= 1;
31343 }
31344         return ret_ref;
31345 }
31346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31347         LDKClosingSigned arg_conv;
31348         arg_conv.inner = (void*)(arg & (~1));
31349         arg_conv.is_owned = false;
31350         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31351         int64_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
31352         return ret_val;
31353 }
31354
31355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31356         LDKClosingSigned orig_conv;
31357         orig_conv.inner = (void*)(orig & (~1));
31358         orig_conv.is_owned = false;
31359         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31360         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
31361         int64_t ret_ref = 0;
31362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31365         ret_ref = (uintptr_t)ret_var.inner;
31366         if (ret_var.is_owned) {
31367                 ret_ref |= 1;
31368         }
31369         return ret_ref;
31370 }
31371
31372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31373         LDKUpdateAddHTLC this_obj_conv;
31374         this_obj_conv.inner = (void*)(this_obj & (~1));
31375         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31377         UpdateAddHTLC_free(this_obj_conv);
31378 }
31379
31380 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31381         LDKUpdateAddHTLC this_ptr_conv;
31382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31383         this_ptr_conv.is_owned = false;
31384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31385         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31386         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
31387         return ret_arr;
31388 }
31389
31390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31391         LDKUpdateAddHTLC this_ptr_conv;
31392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31393         this_ptr_conv.is_owned = false;
31394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31395         LDKThirtyTwoBytes val_ref;
31396         CHECK((*env)->GetArrayLength(env, val) == 32);
31397         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31398         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
31399 }
31400
31401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31402         LDKUpdateAddHTLC this_ptr_conv;
31403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31404         this_ptr_conv.is_owned = false;
31405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31406         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
31407         return ret_val;
31408 }
31409
31410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31411         LDKUpdateAddHTLC this_ptr_conv;
31412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31413         this_ptr_conv.is_owned = false;
31414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31415         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
31416 }
31417
31418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31419         LDKUpdateAddHTLC this_ptr_conv;
31420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31421         this_ptr_conv.is_owned = false;
31422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31423         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
31424         return ret_val;
31425 }
31426
31427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31428         LDKUpdateAddHTLC this_ptr_conv;
31429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31430         this_ptr_conv.is_owned = false;
31431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31432         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
31433 }
31434
31435 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31436         LDKUpdateAddHTLC this_ptr_conv;
31437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31438         this_ptr_conv.is_owned = false;
31439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31440         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31441         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
31442         return ret_arr;
31443 }
31444
31445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31446         LDKUpdateAddHTLC this_ptr_conv;
31447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31448         this_ptr_conv.is_owned = false;
31449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31450         LDKThirtyTwoBytes val_ref;
31451         CHECK((*env)->GetArrayLength(env, val) == 32);
31452         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31453         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
31454 }
31455
31456 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
31457         LDKUpdateAddHTLC this_ptr_conv;
31458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31459         this_ptr_conv.is_owned = false;
31460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31461         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
31462         return ret_val;
31463 }
31464
31465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31466         LDKUpdateAddHTLC this_ptr_conv;
31467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31468         this_ptr_conv.is_owned = false;
31469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31470         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
31471 }
31472
31473 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
31474         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
31475 int64_t ret_ref = 0;
31476 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31477 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31478 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31479 ret_ref = (uintptr_t)ret_var.inner;
31480 if (ret_var.is_owned) {
31481         ret_ref |= 1;
31482 }
31483         return ret_ref;
31484 }
31485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31486         LDKUpdateAddHTLC arg_conv;
31487         arg_conv.inner = (void*)(arg & (~1));
31488         arg_conv.is_owned = false;
31489         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31490         int64_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
31491         return ret_val;
31492 }
31493
31494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31495         LDKUpdateAddHTLC orig_conv;
31496         orig_conv.inner = (void*)(orig & (~1));
31497         orig_conv.is_owned = false;
31498         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31499         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
31500         int64_t ret_ref = 0;
31501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31504         ret_ref = (uintptr_t)ret_var.inner;
31505         if (ret_var.is_owned) {
31506                 ret_ref |= 1;
31507         }
31508         return ret_ref;
31509 }
31510
31511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31512         LDKUpdateFulfillHTLC this_obj_conv;
31513         this_obj_conv.inner = (void*)(this_obj & (~1));
31514         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31516         UpdateFulfillHTLC_free(this_obj_conv);
31517 }
31518
31519 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31520         LDKUpdateFulfillHTLC this_ptr_conv;
31521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31522         this_ptr_conv.is_owned = false;
31523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31524         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31525         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
31526         return ret_arr;
31527 }
31528
31529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31530         LDKUpdateFulfillHTLC this_ptr_conv;
31531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31532         this_ptr_conv.is_owned = false;
31533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31534         LDKThirtyTwoBytes val_ref;
31535         CHECK((*env)->GetArrayLength(env, val) == 32);
31536         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31537         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
31538 }
31539
31540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31541         LDKUpdateFulfillHTLC this_ptr_conv;
31542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31543         this_ptr_conv.is_owned = false;
31544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31545         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
31546         return ret_val;
31547 }
31548
31549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31550         LDKUpdateFulfillHTLC this_ptr_conv;
31551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31552         this_ptr_conv.is_owned = false;
31553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31554         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
31555 }
31556
31557 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
31558         LDKUpdateFulfillHTLC this_ptr_conv;
31559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31560         this_ptr_conv.is_owned = false;
31561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31562         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31563         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
31564         return ret_arr;
31565 }
31566
31567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31568         LDKUpdateFulfillHTLC this_ptr_conv;
31569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31570         this_ptr_conv.is_owned = false;
31571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31572         LDKThirtyTwoBytes val_ref;
31573         CHECK((*env)->GetArrayLength(env, val) == 32);
31574         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31575         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
31576 }
31577
31578 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) {
31579         LDKThirtyTwoBytes channel_id_arg_ref;
31580         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31581         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31582         LDKThirtyTwoBytes payment_preimage_arg_ref;
31583         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
31584         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
31585         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
31586         int64_t ret_ref = 0;
31587         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31588         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31590         ret_ref = (uintptr_t)ret_var.inner;
31591         if (ret_var.is_owned) {
31592                 ret_ref |= 1;
31593         }
31594         return ret_ref;
31595 }
31596
31597 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
31598         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
31599 int64_t ret_ref = 0;
31600 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31601 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31602 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31603 ret_ref = (uintptr_t)ret_var.inner;
31604 if (ret_var.is_owned) {
31605         ret_ref |= 1;
31606 }
31607         return ret_ref;
31608 }
31609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31610         LDKUpdateFulfillHTLC arg_conv;
31611         arg_conv.inner = (void*)(arg & (~1));
31612         arg_conv.is_owned = false;
31613         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31614         int64_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
31615         return ret_val;
31616 }
31617
31618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31619         LDKUpdateFulfillHTLC orig_conv;
31620         orig_conv.inner = (void*)(orig & (~1));
31621         orig_conv.is_owned = false;
31622         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31623         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
31624         int64_t ret_ref = 0;
31625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31628         ret_ref = (uintptr_t)ret_var.inner;
31629         if (ret_var.is_owned) {
31630                 ret_ref |= 1;
31631         }
31632         return ret_ref;
31633 }
31634
31635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31636         LDKUpdateFailHTLC this_obj_conv;
31637         this_obj_conv.inner = (void*)(this_obj & (~1));
31638         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31640         UpdateFailHTLC_free(this_obj_conv);
31641 }
31642
31643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31644         LDKUpdateFailHTLC this_ptr_conv;
31645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31646         this_ptr_conv.is_owned = false;
31647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31648         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31649         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
31650         return ret_arr;
31651 }
31652
31653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31654         LDKUpdateFailHTLC this_ptr_conv;
31655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31656         this_ptr_conv.is_owned = false;
31657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31658         LDKThirtyTwoBytes val_ref;
31659         CHECK((*env)->GetArrayLength(env, val) == 32);
31660         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31661         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
31662 }
31663
31664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31665         LDKUpdateFailHTLC this_ptr_conv;
31666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31667         this_ptr_conv.is_owned = false;
31668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31669         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
31670         return ret_val;
31671 }
31672
31673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31674         LDKUpdateFailHTLC this_ptr_conv;
31675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31676         this_ptr_conv.is_owned = false;
31677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31678         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
31679 }
31680
31681 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
31682         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
31683 int64_t ret_ref = 0;
31684 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31685 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31686 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31687 ret_ref = (uintptr_t)ret_var.inner;
31688 if (ret_var.is_owned) {
31689         ret_ref |= 1;
31690 }
31691         return ret_ref;
31692 }
31693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31694         LDKUpdateFailHTLC arg_conv;
31695         arg_conv.inner = (void*)(arg & (~1));
31696         arg_conv.is_owned = false;
31697         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31698         int64_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
31699         return ret_val;
31700 }
31701
31702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31703         LDKUpdateFailHTLC orig_conv;
31704         orig_conv.inner = (void*)(orig & (~1));
31705         orig_conv.is_owned = false;
31706         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31707         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
31708         int64_t ret_ref = 0;
31709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31712         ret_ref = (uintptr_t)ret_var.inner;
31713         if (ret_var.is_owned) {
31714                 ret_ref |= 1;
31715         }
31716         return ret_ref;
31717 }
31718
31719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31720         LDKUpdateFailMalformedHTLC this_obj_conv;
31721         this_obj_conv.inner = (void*)(this_obj & (~1));
31722         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31724         UpdateFailMalformedHTLC_free(this_obj_conv);
31725 }
31726
31727 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31728         LDKUpdateFailMalformedHTLC this_ptr_conv;
31729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31730         this_ptr_conv.is_owned = false;
31731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31732         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31733         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
31734         return ret_arr;
31735 }
31736
31737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31738         LDKUpdateFailMalformedHTLC this_ptr_conv;
31739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31740         this_ptr_conv.is_owned = false;
31741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31742         LDKThirtyTwoBytes val_ref;
31743         CHECK((*env)->GetArrayLength(env, val) == 32);
31744         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31745         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
31746 }
31747
31748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31749         LDKUpdateFailMalformedHTLC this_ptr_conv;
31750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31751         this_ptr_conv.is_owned = false;
31752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31753         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
31754         return ret_val;
31755 }
31756
31757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31758         LDKUpdateFailMalformedHTLC this_ptr_conv;
31759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31760         this_ptr_conv.is_owned = false;
31761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31762         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
31763 }
31764
31765 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
31766         LDKUpdateFailMalformedHTLC this_ptr_conv;
31767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31768         this_ptr_conv.is_owned = false;
31769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31770         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
31771         return ret_val;
31772 }
31773
31774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31775         LDKUpdateFailMalformedHTLC this_ptr_conv;
31776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31777         this_ptr_conv.is_owned = false;
31778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31779         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
31780 }
31781
31782 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
31783         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
31784 int64_t ret_ref = 0;
31785 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31786 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31787 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31788 ret_ref = (uintptr_t)ret_var.inner;
31789 if (ret_var.is_owned) {
31790         ret_ref |= 1;
31791 }
31792         return ret_ref;
31793 }
31794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31795         LDKUpdateFailMalformedHTLC arg_conv;
31796         arg_conv.inner = (void*)(arg & (~1));
31797         arg_conv.is_owned = false;
31798         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31799         int64_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
31800         return ret_val;
31801 }
31802
31803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31804         LDKUpdateFailMalformedHTLC orig_conv;
31805         orig_conv.inner = (void*)(orig & (~1));
31806         orig_conv.is_owned = false;
31807         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31808         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
31809         int64_t ret_ref = 0;
31810         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31811         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31813         ret_ref = (uintptr_t)ret_var.inner;
31814         if (ret_var.is_owned) {
31815                 ret_ref |= 1;
31816         }
31817         return ret_ref;
31818 }
31819
31820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31821         LDKCommitmentSigned this_obj_conv;
31822         this_obj_conv.inner = (void*)(this_obj & (~1));
31823         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31825         CommitmentSigned_free(this_obj_conv);
31826 }
31827
31828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31829         LDKCommitmentSigned this_ptr_conv;
31830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31831         this_ptr_conv.is_owned = false;
31832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31833         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31834         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
31835         return ret_arr;
31836 }
31837
31838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31839         LDKCommitmentSigned this_ptr_conv;
31840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31841         this_ptr_conv.is_owned = false;
31842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31843         LDKThirtyTwoBytes val_ref;
31844         CHECK((*env)->GetArrayLength(env, val) == 32);
31845         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31846         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
31847 }
31848
31849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31850         LDKCommitmentSigned this_ptr_conv;
31851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31852         this_ptr_conv.is_owned = false;
31853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31854         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31855         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
31856         return ret_arr;
31857 }
31858
31859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31860         LDKCommitmentSigned this_ptr_conv;
31861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31862         this_ptr_conv.is_owned = false;
31863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31864         LDKSignature val_ref;
31865         CHECK((*env)->GetArrayLength(env, val) == 64);
31866         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31867         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
31868 }
31869
31870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
31871         LDKCommitmentSigned this_ptr_conv;
31872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31873         this_ptr_conv.is_owned = false;
31874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31875         LDKCVec_SignatureZ val_constr;
31876         val_constr.datalen = (*env)->GetArrayLength(env, val);
31877         if (val_constr.datalen > 0)
31878                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
31879         else
31880                 val_constr.data = NULL;
31881         for (size_t i = 0; i < val_constr.datalen; i++) {
31882                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
31883                 LDKSignature val_conv_8_ref;
31884                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
31885                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
31886                 val_constr.data[i] = val_conv_8_ref;
31887         }
31888         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
31889 }
31890
31891 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) {
31892         LDKThirtyTwoBytes channel_id_arg_ref;
31893         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31894         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31895         LDKSignature signature_arg_ref;
31896         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31897         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31898         LDKCVec_SignatureZ htlc_signatures_arg_constr;
31899         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
31900         if (htlc_signatures_arg_constr.datalen > 0)
31901                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
31902         else
31903                 htlc_signatures_arg_constr.data = NULL;
31904         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
31905                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
31906                 LDKSignature htlc_signatures_arg_conv_8_ref;
31907                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
31908                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
31909                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
31910         }
31911         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
31912         int64_t ret_ref = 0;
31913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31916         ret_ref = (uintptr_t)ret_var.inner;
31917         if (ret_var.is_owned) {
31918                 ret_ref |= 1;
31919         }
31920         return ret_ref;
31921 }
31922
31923 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
31924         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
31925 int64_t ret_ref = 0;
31926 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31927 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31928 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31929 ret_ref = (uintptr_t)ret_var.inner;
31930 if (ret_var.is_owned) {
31931         ret_ref |= 1;
31932 }
31933         return ret_ref;
31934 }
31935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31936         LDKCommitmentSigned arg_conv;
31937         arg_conv.inner = (void*)(arg & (~1));
31938         arg_conv.is_owned = false;
31939         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31940         int64_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
31941         return ret_val;
31942 }
31943
31944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31945         LDKCommitmentSigned orig_conv;
31946         orig_conv.inner = (void*)(orig & (~1));
31947         orig_conv.is_owned = false;
31948         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31949         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
31950         int64_t ret_ref = 0;
31951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31954         ret_ref = (uintptr_t)ret_var.inner;
31955         if (ret_var.is_owned) {
31956                 ret_ref |= 1;
31957         }
31958         return ret_ref;
31959 }
31960
31961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31962         LDKRevokeAndACK this_obj_conv;
31963         this_obj_conv.inner = (void*)(this_obj & (~1));
31964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31966         RevokeAndACK_free(this_obj_conv);
31967 }
31968
31969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31970         LDKRevokeAndACK this_ptr_conv;
31971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31972         this_ptr_conv.is_owned = false;
31973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31974         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31975         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
31976         return ret_arr;
31977 }
31978
31979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31980         LDKRevokeAndACK this_ptr_conv;
31981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31982         this_ptr_conv.is_owned = false;
31983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31984         LDKThirtyTwoBytes val_ref;
31985         CHECK((*env)->GetArrayLength(env, val) == 32);
31986         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31987         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
31988 }
31989
31990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
31991         LDKRevokeAndACK 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31996         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
31997         return ret_arr;
31998 }
31999
32000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32001         LDKRevokeAndACK this_ptr_conv;
32002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32003         this_ptr_conv.is_owned = false;
32004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32005         LDKThirtyTwoBytes val_ref;
32006         CHECK((*env)->GetArrayLength(env, val) == 32);
32007         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32008         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
32009 }
32010
32011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32012         LDKRevokeAndACK this_ptr_conv;
32013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32014         this_ptr_conv.is_owned = false;
32015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32016         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32017         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
32018         return ret_arr;
32019 }
32020
32021 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) {
32022         LDKRevokeAndACK this_ptr_conv;
32023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32024         this_ptr_conv.is_owned = false;
32025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32026         LDKPublicKey val_ref;
32027         CHECK((*env)->GetArrayLength(env, val) == 33);
32028         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32029         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
32030 }
32031
32032 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) {
32033         LDKThirtyTwoBytes channel_id_arg_ref;
32034         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32035         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32036         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
32037         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
32038         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
32039         LDKPublicKey next_per_commitment_point_arg_ref;
32040         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
32041         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
32042         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
32043         int64_t ret_ref = 0;
32044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32047         ret_ref = (uintptr_t)ret_var.inner;
32048         if (ret_var.is_owned) {
32049                 ret_ref |= 1;
32050         }
32051         return ret_ref;
32052 }
32053
32054 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
32055         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
32056 int64_t ret_ref = 0;
32057 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32058 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32059 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32060 ret_ref = (uintptr_t)ret_var.inner;
32061 if (ret_var.is_owned) {
32062         ret_ref |= 1;
32063 }
32064         return ret_ref;
32065 }
32066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32067         LDKRevokeAndACK arg_conv;
32068         arg_conv.inner = (void*)(arg & (~1));
32069         arg_conv.is_owned = false;
32070         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32071         int64_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
32072         return ret_val;
32073 }
32074
32075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32076         LDKRevokeAndACK orig_conv;
32077         orig_conv.inner = (void*)(orig & (~1));
32078         orig_conv.is_owned = false;
32079         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32080         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
32081         int64_t ret_ref = 0;
32082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32085         ret_ref = (uintptr_t)ret_var.inner;
32086         if (ret_var.is_owned) {
32087                 ret_ref |= 1;
32088         }
32089         return ret_ref;
32090 }
32091
32092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32093         LDKUpdateFee this_obj_conv;
32094         this_obj_conv.inner = (void*)(this_obj & (~1));
32095         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32097         UpdateFee_free(this_obj_conv);
32098 }
32099
32100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32101         LDKUpdateFee this_ptr_conv;
32102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32103         this_ptr_conv.is_owned = false;
32104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32105         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32106         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
32107         return ret_arr;
32108 }
32109
32110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32111         LDKUpdateFee this_ptr_conv;
32112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32113         this_ptr_conv.is_owned = false;
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32115         LDKThirtyTwoBytes val_ref;
32116         CHECK((*env)->GetArrayLength(env, val) == 32);
32117         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32118         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
32119 }
32120
32121 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
32122         LDKUpdateFee this_ptr_conv;
32123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32124         this_ptr_conv.is_owned = false;
32125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32126         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
32127         return ret_val;
32128 }
32129
32130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32131         LDKUpdateFee this_ptr_conv;
32132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32133         this_ptr_conv.is_owned = false;
32134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32135         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
32136 }
32137
32138 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) {
32139         LDKThirtyTwoBytes channel_id_arg_ref;
32140         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32141         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32142         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
32143         int64_t ret_ref = 0;
32144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32147         ret_ref = (uintptr_t)ret_var.inner;
32148         if (ret_var.is_owned) {
32149                 ret_ref |= 1;
32150         }
32151         return ret_ref;
32152 }
32153
32154 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
32155         LDKUpdateFee ret_var = UpdateFee_clone(arg);
32156 int64_t ret_ref = 0;
32157 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32158 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32159 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32160 ret_ref = (uintptr_t)ret_var.inner;
32161 if (ret_var.is_owned) {
32162         ret_ref |= 1;
32163 }
32164         return ret_ref;
32165 }
32166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32167         LDKUpdateFee arg_conv;
32168         arg_conv.inner = (void*)(arg & (~1));
32169         arg_conv.is_owned = false;
32170         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32171         int64_t ret_val = UpdateFee_clone_ptr(&arg_conv);
32172         return ret_val;
32173 }
32174
32175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32176         LDKUpdateFee orig_conv;
32177         orig_conv.inner = (void*)(orig & (~1));
32178         orig_conv.is_owned = false;
32179         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32180         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
32181         int64_t ret_ref = 0;
32182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32185         ret_ref = (uintptr_t)ret_var.inner;
32186         if (ret_var.is_owned) {
32187                 ret_ref |= 1;
32188         }
32189         return ret_ref;
32190 }
32191
32192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32193         LDKDataLossProtect this_obj_conv;
32194         this_obj_conv.inner = (void*)(this_obj & (~1));
32195         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32197         DataLossProtect_free(this_obj_conv);
32198 }
32199
32200 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
32201         LDKDataLossProtect this_ptr_conv;
32202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32203         this_ptr_conv.is_owned = false;
32204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32205         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32206         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
32207         return ret_arr;
32208 }
32209
32210 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) {
32211         LDKDataLossProtect this_ptr_conv;
32212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32213         this_ptr_conv.is_owned = false;
32214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32215         LDKThirtyTwoBytes val_ref;
32216         CHECK((*env)->GetArrayLength(env, val) == 32);
32217         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32218         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
32219 }
32220
32221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32222         LDKDataLossProtect this_ptr_conv;
32223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32224         this_ptr_conv.is_owned = false;
32225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32226         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32227         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
32228         return ret_arr;
32229 }
32230
32231 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) {
32232         LDKDataLossProtect this_ptr_conv;
32233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32234         this_ptr_conv.is_owned = false;
32235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32236         LDKPublicKey val_ref;
32237         CHECK((*env)->GetArrayLength(env, val) == 33);
32238         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32239         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
32240 }
32241
32242 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) {
32243         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
32244         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
32245         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
32246         LDKPublicKey my_current_per_commitment_point_arg_ref;
32247         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
32248         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
32249         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
32250         int64_t ret_ref = 0;
32251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32254         ret_ref = (uintptr_t)ret_var.inner;
32255         if (ret_var.is_owned) {
32256                 ret_ref |= 1;
32257         }
32258         return ret_ref;
32259 }
32260
32261 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
32262         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
32263 int64_t ret_ref = 0;
32264 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32265 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32266 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32267 ret_ref = (uintptr_t)ret_var.inner;
32268 if (ret_var.is_owned) {
32269         ret_ref |= 1;
32270 }
32271         return ret_ref;
32272 }
32273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32274         LDKDataLossProtect arg_conv;
32275         arg_conv.inner = (void*)(arg & (~1));
32276         arg_conv.is_owned = false;
32277         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32278         int64_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
32279         return ret_val;
32280 }
32281
32282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32283         LDKDataLossProtect orig_conv;
32284         orig_conv.inner = (void*)(orig & (~1));
32285         orig_conv.is_owned = false;
32286         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32287         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
32288         int64_t ret_ref = 0;
32289         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32290         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32292         ret_ref = (uintptr_t)ret_var.inner;
32293         if (ret_var.is_owned) {
32294                 ret_ref |= 1;
32295         }
32296         return ret_ref;
32297 }
32298
32299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32300         LDKChannelReestablish this_obj_conv;
32301         this_obj_conv.inner = (void*)(this_obj & (~1));
32302         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32304         ChannelReestablish_free(this_obj_conv);
32305 }
32306
32307 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32308         LDKChannelReestablish this_ptr_conv;
32309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32310         this_ptr_conv.is_owned = false;
32311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32312         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32313         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
32314         return ret_arr;
32315 }
32316
32317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32318         LDKChannelReestablish this_ptr_conv;
32319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32320         this_ptr_conv.is_owned = false;
32321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32322         LDKThirtyTwoBytes val_ref;
32323         CHECK((*env)->GetArrayLength(env, val) == 32);
32324         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32325         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
32326 }
32327
32328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32329         LDKChannelReestablish this_ptr_conv;
32330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32331         this_ptr_conv.is_owned = false;
32332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32333         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
32334         return ret_val;
32335 }
32336
32337 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) {
32338         LDKChannelReestablish this_ptr_conv;
32339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32340         this_ptr_conv.is_owned = false;
32341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32342         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
32343 }
32344
32345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32346         LDKChannelReestablish this_ptr_conv;
32347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32348         this_ptr_conv.is_owned = false;
32349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32350         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
32351         return ret_val;
32352 }
32353
32354 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) {
32355         LDKChannelReestablish this_ptr_conv;
32356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32357         this_ptr_conv.is_owned = false;
32358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32359         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
32360 }
32361
32362 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
32363         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
32364 int64_t ret_ref = 0;
32365 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32366 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32367 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32368 ret_ref = (uintptr_t)ret_var.inner;
32369 if (ret_var.is_owned) {
32370         ret_ref |= 1;
32371 }
32372         return ret_ref;
32373 }
32374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32375         LDKChannelReestablish arg_conv;
32376         arg_conv.inner = (void*)(arg & (~1));
32377         arg_conv.is_owned = false;
32378         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32379         int64_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
32380         return ret_val;
32381 }
32382
32383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32384         LDKChannelReestablish orig_conv;
32385         orig_conv.inner = (void*)(orig & (~1));
32386         orig_conv.is_owned = false;
32387         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32388         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
32389         int64_t ret_ref = 0;
32390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32393         ret_ref = (uintptr_t)ret_var.inner;
32394         if (ret_var.is_owned) {
32395                 ret_ref |= 1;
32396         }
32397         return ret_ref;
32398 }
32399
32400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32401         LDKAnnouncementSignatures this_obj_conv;
32402         this_obj_conv.inner = (void*)(this_obj & (~1));
32403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32405         AnnouncementSignatures_free(this_obj_conv);
32406 }
32407
32408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32409         LDKAnnouncementSignatures 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32414         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
32415         return ret_arr;
32416 }
32417
32418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32419         LDKAnnouncementSignatures this_ptr_conv;
32420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32421         this_ptr_conv.is_owned = false;
32422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32423         LDKThirtyTwoBytes val_ref;
32424         CHECK((*env)->GetArrayLength(env, val) == 32);
32425         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32426         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
32427 }
32428
32429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32430         LDKAnnouncementSignatures this_ptr_conv;
32431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32432         this_ptr_conv.is_owned = false;
32433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32434         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
32435         return ret_val;
32436 }
32437
32438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32439         LDKAnnouncementSignatures this_ptr_conv;
32440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32441         this_ptr_conv.is_owned = false;
32442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32443         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
32444 }
32445
32446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32447         LDKAnnouncementSignatures this_ptr_conv;
32448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32449         this_ptr_conv.is_owned = false;
32450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32451         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
32453         return ret_arr;
32454 }
32455
32456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32457         LDKAnnouncementSignatures this_ptr_conv;
32458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32459         this_ptr_conv.is_owned = false;
32460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32461         LDKSignature val_ref;
32462         CHECK((*env)->GetArrayLength(env, val) == 64);
32463         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32464         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
32465 }
32466
32467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32468         LDKAnnouncementSignatures 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32473         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
32474         return ret_arr;
32475 }
32476
32477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32478         LDKAnnouncementSignatures this_ptr_conv;
32479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32480         this_ptr_conv.is_owned = false;
32481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32482         LDKSignature val_ref;
32483         CHECK((*env)->GetArrayLength(env, val) == 64);
32484         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32485         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
32486 }
32487
32488 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) {
32489         LDKThirtyTwoBytes channel_id_arg_ref;
32490         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32491         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32492         LDKSignature node_signature_arg_ref;
32493         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
32494         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
32495         LDKSignature bitcoin_signature_arg_ref;
32496         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
32497         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
32498         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
32499         int64_t ret_ref = 0;
32500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32503         ret_ref = (uintptr_t)ret_var.inner;
32504         if (ret_var.is_owned) {
32505                 ret_ref |= 1;
32506         }
32507         return ret_ref;
32508 }
32509
32510 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
32511         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
32512 int64_t ret_ref = 0;
32513 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32514 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32515 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32516 ret_ref = (uintptr_t)ret_var.inner;
32517 if (ret_var.is_owned) {
32518         ret_ref |= 1;
32519 }
32520         return ret_ref;
32521 }
32522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32523         LDKAnnouncementSignatures arg_conv;
32524         arg_conv.inner = (void*)(arg & (~1));
32525         arg_conv.is_owned = false;
32526         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32527         int64_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
32528         return ret_val;
32529 }
32530
32531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32532         LDKAnnouncementSignatures orig_conv;
32533         orig_conv.inner = (void*)(orig & (~1));
32534         orig_conv.is_owned = false;
32535         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32536         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
32537         int64_t ret_ref = 0;
32538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32541         ret_ref = (uintptr_t)ret_var.inner;
32542         if (ret_var.is_owned) {
32543                 ret_ref |= 1;
32544         }
32545         return ret_ref;
32546 }
32547
32548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32549         if ((this_ptr & 1) != 0) return;
32550         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32551         CHECK_ACCESS(this_ptr_ptr);
32552         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
32553         FREE((void*)this_ptr);
32554         NetAddress_free(this_ptr_conv);
32555 }
32556
32557 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
32558         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32559         *ret_copy = NetAddress_clone(arg);
32560 int64_t ret_ref = (uintptr_t)ret_copy;
32561         return ret_ref;
32562 }
32563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32564         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
32565         int64_t ret_val = NetAddress_clone_ptr(arg_conv);
32566         return ret_val;
32567 }
32568
32569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32570         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
32571         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32572         *ret_copy = NetAddress_clone(orig_conv);
32573         int64_t ret_ref = (uintptr_t)ret_copy;
32574         return ret_ref;
32575 }
32576
32577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
32578         LDKFourBytes addr_ref;
32579         CHECK((*env)->GetArrayLength(env, addr) == 4);
32580         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
32581         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32582         *ret_copy = NetAddress_ipv4(addr_ref, port);
32583         int64_t ret_ref = (uintptr_t)ret_copy;
32584         return ret_ref;
32585 }
32586
32587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
32588         LDKSixteenBytes addr_ref;
32589         CHECK((*env)->GetArrayLength(env, addr) == 16);
32590         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
32591         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32592         *ret_copy = NetAddress_ipv6(addr_ref, port);
32593         int64_t ret_ref = (uintptr_t)ret_copy;
32594         return ret_ref;
32595 }
32596
32597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
32598         LDKTwelveBytes a_ref;
32599         CHECK((*env)->GetArrayLength(env, a) == 12);
32600         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
32601         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32602         *ret_copy = NetAddress_onion_v2(a_ref);
32603         int64_t ret_ref = (uintptr_t)ret_copy;
32604         return ret_ref;
32605 }
32606
32607 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) {
32608         LDKThirtyTwoBytes ed25519_pubkey_ref;
32609         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
32610         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
32611         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32612         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
32613         int64_t ret_ref = (uintptr_t)ret_copy;
32614         return ret_ref;
32615 }
32616
32617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
32618         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
32619         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
32620         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32621         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32622         CVec_u8Z_free(ret_var);
32623         return ret_arr;
32624 }
32625
32626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32627         LDKu8slice ser_ref;
32628         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32629         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32630         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
32631         *ret_conv = NetAddress_read(ser_ref);
32632         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32633         return (int64_t)ret_conv;
32634 }
32635
32636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32637         LDKUnsignedNodeAnnouncement this_obj_conv;
32638         this_obj_conv.inner = (void*)(this_obj & (~1));
32639         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32641         UnsignedNodeAnnouncement_free(this_obj_conv);
32642 }
32643
32644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32645         LDKUnsignedNodeAnnouncement this_ptr_conv;
32646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32647         this_ptr_conv.is_owned = false;
32648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32649         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
32650         int64_t ret_ref = 0;
32651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32654         ret_ref = (uintptr_t)ret_var.inner;
32655         if (ret_var.is_owned) {
32656                 ret_ref |= 1;
32657         }
32658         return ret_ref;
32659 }
32660
32661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32662         LDKUnsignedNodeAnnouncement this_ptr_conv;
32663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32664         this_ptr_conv.is_owned = false;
32665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32666         LDKNodeFeatures val_conv;
32667         val_conv.inner = (void*)(val & (~1));
32668         val_conv.is_owned = (val & 1) || (val == 0);
32669         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32670         val_conv = NodeFeatures_clone(&val_conv);
32671         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
32672 }
32673
32674 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
32675         LDKUnsignedNodeAnnouncement this_ptr_conv;
32676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32677         this_ptr_conv.is_owned = false;
32678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32679         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
32680         return ret_val;
32681 }
32682
32683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32684         LDKUnsignedNodeAnnouncement this_ptr_conv;
32685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32686         this_ptr_conv.is_owned = false;
32687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32688         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
32689 }
32690
32691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32692         LDKUnsignedNodeAnnouncement this_ptr_conv;
32693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32694         this_ptr_conv.is_owned = false;
32695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32696         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32697         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
32698         return ret_arr;
32699 }
32700
32701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32702         LDKUnsignedNodeAnnouncement this_ptr_conv;
32703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32704         this_ptr_conv.is_owned = false;
32705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32706         LDKPublicKey val_ref;
32707         CHECK((*env)->GetArrayLength(env, val) == 33);
32708         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32709         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
32710 }
32711
32712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
32713         LDKUnsignedNodeAnnouncement this_ptr_conv;
32714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32715         this_ptr_conv.is_owned = false;
32716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32717         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
32718         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
32719         return ret_arr;
32720 }
32721
32722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32723         LDKUnsignedNodeAnnouncement this_ptr_conv;
32724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32725         this_ptr_conv.is_owned = false;
32726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32727         LDKThreeBytes val_ref;
32728         CHECK((*env)->GetArrayLength(env, val) == 3);
32729         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
32730         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
32731 }
32732
32733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32734         LDKUnsignedNodeAnnouncement this_ptr_conv;
32735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32736         this_ptr_conv.is_owned = false;
32737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32738         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32739         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
32740         return ret_arr;
32741 }
32742
32743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32744         LDKUnsignedNodeAnnouncement this_ptr_conv;
32745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32746         this_ptr_conv.is_owned = false;
32747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32748         LDKThirtyTwoBytes val_ref;
32749         CHECK((*env)->GetArrayLength(env, val) == 32);
32750         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32751         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
32752 }
32753
32754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
32755         LDKUnsignedNodeAnnouncement this_ptr_conv;
32756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32757         this_ptr_conv.is_owned = false;
32758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32759         LDKCVec_NetAddressZ val_constr;
32760         val_constr.datalen = (*env)->GetArrayLength(env, val);
32761         if (val_constr.datalen > 0)
32762                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32763         else
32764                 val_constr.data = NULL;
32765         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32766         for (size_t m = 0; m < val_constr.datalen; m++) {
32767                 int64_t val_conv_12 = val_vals[m];
32768                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
32769                 CHECK_ACCESS(val_conv_12_ptr);
32770                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
32771                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
32772                 val_constr.data[m] = val_conv_12_conv;
32773         }
32774         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32775         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
32776 }
32777
32778 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
32779         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
32780 int64_t ret_ref = 0;
32781 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32782 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32783 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32784 ret_ref = (uintptr_t)ret_var.inner;
32785 if (ret_var.is_owned) {
32786         ret_ref |= 1;
32787 }
32788         return ret_ref;
32789 }
32790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32791         LDKUnsignedNodeAnnouncement arg_conv;
32792         arg_conv.inner = (void*)(arg & (~1));
32793         arg_conv.is_owned = false;
32794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32795         int64_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
32796         return ret_val;
32797 }
32798
32799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32800         LDKUnsignedNodeAnnouncement orig_conv;
32801         orig_conv.inner = (void*)(orig & (~1));
32802         orig_conv.is_owned = false;
32803         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32804         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
32805         int64_t ret_ref = 0;
32806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32809         ret_ref = (uintptr_t)ret_var.inner;
32810         if (ret_var.is_owned) {
32811                 ret_ref |= 1;
32812         }
32813         return ret_ref;
32814 }
32815
32816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32817         LDKNodeAnnouncement this_obj_conv;
32818         this_obj_conv.inner = (void*)(this_obj & (~1));
32819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32821         NodeAnnouncement_free(this_obj_conv);
32822 }
32823
32824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32825         LDKNodeAnnouncement this_ptr_conv;
32826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32827         this_ptr_conv.is_owned = false;
32828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32829         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32830         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
32831         return ret_arr;
32832 }
32833
32834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32835         LDKNodeAnnouncement this_ptr_conv;
32836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32837         this_ptr_conv.is_owned = false;
32838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32839         LDKSignature val_ref;
32840         CHECK((*env)->GetArrayLength(env, val) == 64);
32841         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32842         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
32843 }
32844
32845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
32846         LDKNodeAnnouncement 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         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
32851         int64_t ret_ref = 0;
32852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32855         ret_ref = (uintptr_t)ret_var.inner;
32856         if (ret_var.is_owned) {
32857                 ret_ref |= 1;
32858         }
32859         return ret_ref;
32860 }
32861
32862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32863         LDKNodeAnnouncement 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         LDKUnsignedNodeAnnouncement val_conv;
32868         val_conv.inner = (void*)(val & (~1));
32869         val_conv.is_owned = (val & 1) || (val == 0);
32870         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32871         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
32872         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
32873 }
32874
32875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
32876         LDKSignature signature_arg_ref;
32877         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32878         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32879         LDKUnsignedNodeAnnouncement contents_arg_conv;
32880         contents_arg_conv.inner = (void*)(contents_arg & (~1));
32881         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
32882         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32883         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
32884         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
32885         int64_t ret_ref = 0;
32886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32889         ret_ref = (uintptr_t)ret_var.inner;
32890         if (ret_var.is_owned) {
32891                 ret_ref |= 1;
32892         }
32893         return ret_ref;
32894 }
32895
32896 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
32897         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
32898 int64_t ret_ref = 0;
32899 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32900 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32901 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32902 ret_ref = (uintptr_t)ret_var.inner;
32903 if (ret_var.is_owned) {
32904         ret_ref |= 1;
32905 }
32906         return ret_ref;
32907 }
32908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32909         LDKNodeAnnouncement arg_conv;
32910         arg_conv.inner = (void*)(arg & (~1));
32911         arg_conv.is_owned = false;
32912         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32913         int64_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
32914         return ret_val;
32915 }
32916
32917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32918         LDKNodeAnnouncement orig_conv;
32919         orig_conv.inner = (void*)(orig & (~1));
32920         orig_conv.is_owned = false;
32921         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32922         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
32923         int64_t ret_ref = 0;
32924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32927         ret_ref = (uintptr_t)ret_var.inner;
32928         if (ret_var.is_owned) {
32929                 ret_ref |= 1;
32930         }
32931         return ret_ref;
32932 }
32933
32934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32935         LDKUnsignedChannelAnnouncement this_obj_conv;
32936         this_obj_conv.inner = (void*)(this_obj & (~1));
32937         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32939         UnsignedChannelAnnouncement_free(this_obj_conv);
32940 }
32941
32942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32943         LDKUnsignedChannelAnnouncement this_ptr_conv;
32944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32945         this_ptr_conv.is_owned = false;
32946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32947         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
32948         int64_t ret_ref = 0;
32949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32952         ret_ref = (uintptr_t)ret_var.inner;
32953         if (ret_var.is_owned) {
32954                 ret_ref |= 1;
32955         }
32956         return ret_ref;
32957 }
32958
32959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32960         LDKUnsignedChannelAnnouncement this_ptr_conv;
32961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32962         this_ptr_conv.is_owned = false;
32963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32964         LDKChannelFeatures val_conv;
32965         val_conv.inner = (void*)(val & (~1));
32966         val_conv.is_owned = (val & 1) || (val == 0);
32967         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32968         val_conv = ChannelFeatures_clone(&val_conv);
32969         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
32970 }
32971
32972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32973         LDKUnsignedChannelAnnouncement this_ptr_conv;
32974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32975         this_ptr_conv.is_owned = false;
32976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32977         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32978         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
32979         return ret_arr;
32980 }
32981
32982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32983         LDKUnsignedChannelAnnouncement this_ptr_conv;
32984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32985         this_ptr_conv.is_owned = false;
32986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32987         LDKThirtyTwoBytes val_ref;
32988         CHECK((*env)->GetArrayLength(env, val) == 32);
32989         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32990         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
32991 }
32992
32993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32994         LDKUnsignedChannelAnnouncement this_ptr_conv;
32995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32996         this_ptr_conv.is_owned = false;
32997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32998         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
32999         return ret_val;
33000 }
33001
33002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33003         LDKUnsignedChannelAnnouncement this_ptr_conv;
33004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33005         this_ptr_conv.is_owned = false;
33006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33007         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
33008 }
33009
33010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33011         LDKUnsignedChannelAnnouncement this_ptr_conv;
33012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33013         this_ptr_conv.is_owned = false;
33014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33015         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33016         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
33017         return ret_arr;
33018 }
33019
33020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33021         LDKUnsignedChannelAnnouncement this_ptr_conv;
33022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33023         this_ptr_conv.is_owned = false;
33024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33025         LDKPublicKey val_ref;
33026         CHECK((*env)->GetArrayLength(env, val) == 33);
33027         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33028         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
33029 }
33030
33031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33032         LDKUnsignedChannelAnnouncement this_ptr_conv;
33033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33034         this_ptr_conv.is_owned = false;
33035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33036         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33037         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
33038         return ret_arr;
33039 }
33040
33041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33042         LDKUnsignedChannelAnnouncement this_ptr_conv;
33043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33044         this_ptr_conv.is_owned = false;
33045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33046         LDKPublicKey val_ref;
33047         CHECK((*env)->GetArrayLength(env, val) == 33);
33048         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33049         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
33050 }
33051
33052 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33053         LDKUnsignedChannelAnnouncement this_ptr_conv;
33054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33055         this_ptr_conv.is_owned = false;
33056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33057         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33058         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
33059         return ret_arr;
33060 }
33061
33062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33063         LDKUnsignedChannelAnnouncement this_ptr_conv;
33064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33065         this_ptr_conv.is_owned = false;
33066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33067         LDKPublicKey val_ref;
33068         CHECK((*env)->GetArrayLength(env, val) == 33);
33069         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33070         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
33071 }
33072
33073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33074         LDKUnsignedChannelAnnouncement this_ptr_conv;
33075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33076         this_ptr_conv.is_owned = false;
33077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33078         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33079         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
33080         return ret_arr;
33081 }
33082
33083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33084         LDKUnsignedChannelAnnouncement this_ptr_conv;
33085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33086         this_ptr_conv.is_owned = false;
33087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33088         LDKPublicKey val_ref;
33089         CHECK((*env)->GetArrayLength(env, val) == 33);
33090         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33091         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
33092 }
33093
33094 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
33095         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
33096 int64_t ret_ref = 0;
33097 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33098 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33099 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33100 ret_ref = (uintptr_t)ret_var.inner;
33101 if (ret_var.is_owned) {
33102         ret_ref |= 1;
33103 }
33104         return ret_ref;
33105 }
33106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33107         LDKUnsignedChannelAnnouncement arg_conv;
33108         arg_conv.inner = (void*)(arg & (~1));
33109         arg_conv.is_owned = false;
33110         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33111         int64_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
33112         return ret_val;
33113 }
33114
33115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33116         LDKUnsignedChannelAnnouncement orig_conv;
33117         orig_conv.inner = (void*)(orig & (~1));
33118         orig_conv.is_owned = false;
33119         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33120         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
33121         int64_t ret_ref = 0;
33122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33125         ret_ref = (uintptr_t)ret_var.inner;
33126         if (ret_var.is_owned) {
33127                 ret_ref |= 1;
33128         }
33129         return ret_ref;
33130 }
33131
33132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33133         LDKChannelAnnouncement this_obj_conv;
33134         this_obj_conv.inner = (void*)(this_obj & (~1));
33135         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33137         ChannelAnnouncement_free(this_obj_conv);
33138 }
33139
33140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33141         LDKChannelAnnouncement this_ptr_conv;
33142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33143         this_ptr_conv.is_owned = false;
33144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33145         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33146         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
33147         return ret_arr;
33148 }
33149
33150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33151         LDKChannelAnnouncement this_ptr_conv;
33152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33153         this_ptr_conv.is_owned = false;
33154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33155         LDKSignature val_ref;
33156         CHECK((*env)->GetArrayLength(env, val) == 64);
33157         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33158         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
33159 }
33160
33161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33162         LDKChannelAnnouncement this_ptr_conv;
33163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33164         this_ptr_conv.is_owned = false;
33165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33166         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33167         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
33168         return ret_arr;
33169 }
33170
33171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33172         LDKChannelAnnouncement this_ptr_conv;
33173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33174         this_ptr_conv.is_owned = false;
33175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33176         LDKSignature val_ref;
33177         CHECK((*env)->GetArrayLength(env, val) == 64);
33178         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33179         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
33180 }
33181
33182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33183         LDKChannelAnnouncement this_ptr_conv;
33184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33185         this_ptr_conv.is_owned = false;
33186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33187         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33188         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
33189         return ret_arr;
33190 }
33191
33192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33193         LDKChannelAnnouncement this_ptr_conv;
33194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33195         this_ptr_conv.is_owned = false;
33196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33197         LDKSignature val_ref;
33198         CHECK((*env)->GetArrayLength(env, val) == 64);
33199         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33200         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
33201 }
33202
33203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33204         LDKChannelAnnouncement this_ptr_conv;
33205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33206         this_ptr_conv.is_owned = false;
33207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33208         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33209         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
33210         return ret_arr;
33211 }
33212
33213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33214         LDKChannelAnnouncement this_ptr_conv;
33215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33216         this_ptr_conv.is_owned = false;
33217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33218         LDKSignature val_ref;
33219         CHECK((*env)->GetArrayLength(env, val) == 64);
33220         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33221         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
33222 }
33223
33224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33225         LDKChannelAnnouncement this_ptr_conv;
33226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33227         this_ptr_conv.is_owned = false;
33228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33229         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
33230         int64_t ret_ref = 0;
33231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33234         ret_ref = (uintptr_t)ret_var.inner;
33235         if (ret_var.is_owned) {
33236                 ret_ref |= 1;
33237         }
33238         return ret_ref;
33239 }
33240
33241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33242         LDKChannelAnnouncement this_ptr_conv;
33243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33244         this_ptr_conv.is_owned = false;
33245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33246         LDKUnsignedChannelAnnouncement val_conv;
33247         val_conv.inner = (void*)(val & (~1));
33248         val_conv.is_owned = (val & 1) || (val == 0);
33249         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33250         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
33251         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
33252 }
33253
33254 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) {
33255         LDKSignature node_signature_1_arg_ref;
33256         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
33257         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
33258         LDKSignature node_signature_2_arg_ref;
33259         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
33260         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
33261         LDKSignature bitcoin_signature_1_arg_ref;
33262         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
33263         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
33264         LDKSignature bitcoin_signature_2_arg_ref;
33265         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
33266         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
33267         LDKUnsignedChannelAnnouncement contents_arg_conv;
33268         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33269         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33270         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33271         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
33272         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);
33273         int64_t ret_ref = 0;
33274         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33275         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33277         ret_ref = (uintptr_t)ret_var.inner;
33278         if (ret_var.is_owned) {
33279                 ret_ref |= 1;
33280         }
33281         return ret_ref;
33282 }
33283
33284 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
33285         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
33286 int64_t ret_ref = 0;
33287 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33288 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33289 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33290 ret_ref = (uintptr_t)ret_var.inner;
33291 if (ret_var.is_owned) {
33292         ret_ref |= 1;
33293 }
33294         return ret_ref;
33295 }
33296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33297         LDKChannelAnnouncement arg_conv;
33298         arg_conv.inner = (void*)(arg & (~1));
33299         arg_conv.is_owned = false;
33300         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33301         int64_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
33302         return ret_val;
33303 }
33304
33305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33306         LDKChannelAnnouncement orig_conv;
33307         orig_conv.inner = (void*)(orig & (~1));
33308         orig_conv.is_owned = false;
33309         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33310         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
33311         int64_t ret_ref = 0;
33312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33315         ret_ref = (uintptr_t)ret_var.inner;
33316         if (ret_var.is_owned) {
33317                 ret_ref |= 1;
33318         }
33319         return ret_ref;
33320 }
33321
33322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33323         LDKUnsignedChannelUpdate this_obj_conv;
33324         this_obj_conv.inner = (void*)(this_obj & (~1));
33325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33327         UnsignedChannelUpdate_free(this_obj_conv);
33328 }
33329
33330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33331         LDKUnsignedChannelUpdate this_ptr_conv;
33332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33333         this_ptr_conv.is_owned = false;
33334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33335         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33336         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
33337         return ret_arr;
33338 }
33339
33340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33341         LDKUnsignedChannelUpdate this_ptr_conv;
33342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33343         this_ptr_conv.is_owned = false;
33344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33345         LDKThirtyTwoBytes val_ref;
33346         CHECK((*env)->GetArrayLength(env, val) == 32);
33347         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33348         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
33349 }
33350
33351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33352         LDKUnsignedChannelUpdate this_ptr_conv;
33353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33354         this_ptr_conv.is_owned = false;
33355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33356         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
33357         return ret_val;
33358 }
33359
33360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33361         LDKUnsignedChannelUpdate this_ptr_conv;
33362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33363         this_ptr_conv.is_owned = false;
33364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33365         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
33366 }
33367
33368 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
33369         LDKUnsignedChannelUpdate this_ptr_conv;
33370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33371         this_ptr_conv.is_owned = false;
33372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33373         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
33374         return ret_val;
33375 }
33376
33377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33378         LDKUnsignedChannelUpdate this_ptr_conv;
33379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33380         this_ptr_conv.is_owned = false;
33381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33382         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
33383 }
33384
33385 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
33386         LDKUnsignedChannelUpdate this_ptr_conv;
33387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33388         this_ptr_conv.is_owned = false;
33389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33390         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
33391         return ret_val;
33392 }
33393
33394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
33395         LDKUnsignedChannelUpdate this_ptr_conv;
33396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33397         this_ptr_conv.is_owned = false;
33398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33399         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
33400 }
33401
33402 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
33403         LDKUnsignedChannelUpdate this_ptr_conv;
33404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33405         this_ptr_conv.is_owned = false;
33406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33407         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
33408         return ret_val;
33409 }
33410
33411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33412         LDKUnsignedChannelUpdate this_ptr_conv;
33413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33414         this_ptr_conv.is_owned = false;
33415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33416         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
33417 }
33418
33419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33420         LDKUnsignedChannelUpdate this_ptr_conv;
33421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33422         this_ptr_conv.is_owned = false;
33423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33424         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
33425         return ret_val;
33426 }
33427
33428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33429         LDKUnsignedChannelUpdate this_ptr_conv;
33430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33431         this_ptr_conv.is_owned = false;
33432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33433         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
33434 }
33435
33436 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33437         LDKUnsignedChannelUpdate this_ptr_conv;
33438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33439         this_ptr_conv.is_owned = false;
33440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33441         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
33442         return ret_val;
33443 }
33444
33445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33446         LDKUnsignedChannelUpdate this_ptr_conv;
33447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33448         this_ptr_conv.is_owned = false;
33449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33450         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
33451 }
33452
33453 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
33454         LDKUnsignedChannelUpdate this_ptr_conv;
33455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33456         this_ptr_conv.is_owned = false;
33457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33458         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
33459         return ret_val;
33460 }
33461
33462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33463         LDKUnsignedChannelUpdate this_ptr_conv;
33464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33465         this_ptr_conv.is_owned = false;
33466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33467         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
33468 }
33469
33470 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
33471         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
33472 int64_t ret_ref = 0;
33473 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33474 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33475 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33476 ret_ref = (uintptr_t)ret_var.inner;
33477 if (ret_var.is_owned) {
33478         ret_ref |= 1;
33479 }
33480         return ret_ref;
33481 }
33482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33483         LDKUnsignedChannelUpdate arg_conv;
33484         arg_conv.inner = (void*)(arg & (~1));
33485         arg_conv.is_owned = false;
33486         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33487         int64_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
33488         return ret_val;
33489 }
33490
33491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33492         LDKUnsignedChannelUpdate orig_conv;
33493         orig_conv.inner = (void*)(orig & (~1));
33494         orig_conv.is_owned = false;
33495         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33496         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
33497         int64_t ret_ref = 0;
33498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33501         ret_ref = (uintptr_t)ret_var.inner;
33502         if (ret_var.is_owned) {
33503                 ret_ref |= 1;
33504         }
33505         return ret_ref;
33506 }
33507
33508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33509         LDKChannelUpdate this_obj_conv;
33510         this_obj_conv.inner = (void*)(this_obj & (~1));
33511         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33513         ChannelUpdate_free(this_obj_conv);
33514 }
33515
33516 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33517         LDKChannelUpdate 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33522         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
33523         return ret_arr;
33524 }
33525
33526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33527         LDKChannelUpdate this_ptr_conv;
33528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33529         this_ptr_conv.is_owned = false;
33530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33531         LDKSignature val_ref;
33532         CHECK((*env)->GetArrayLength(env, val) == 64);
33533         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33534         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
33535 }
33536
33537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33538         LDKChannelUpdate this_ptr_conv;
33539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33540         this_ptr_conv.is_owned = false;
33541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33542         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
33543         int64_t ret_ref = 0;
33544         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33545         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33547         ret_ref = (uintptr_t)ret_var.inner;
33548         if (ret_var.is_owned) {
33549                 ret_ref |= 1;
33550         }
33551         return ret_ref;
33552 }
33553
33554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33555         LDKChannelUpdate this_ptr_conv;
33556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33557         this_ptr_conv.is_owned = false;
33558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33559         LDKUnsignedChannelUpdate val_conv;
33560         val_conv.inner = (void*)(val & (~1));
33561         val_conv.is_owned = (val & 1) || (val == 0);
33562         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33563         val_conv = UnsignedChannelUpdate_clone(&val_conv);
33564         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
33565 }
33566
33567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
33568         LDKSignature signature_arg_ref;
33569         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33570         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33571         LDKUnsignedChannelUpdate contents_arg_conv;
33572         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33573         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33574         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33575         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
33576         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
33577         int64_t ret_ref = 0;
33578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33581         ret_ref = (uintptr_t)ret_var.inner;
33582         if (ret_var.is_owned) {
33583                 ret_ref |= 1;
33584         }
33585         return ret_ref;
33586 }
33587
33588 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
33589         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
33590 int64_t ret_ref = 0;
33591 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33592 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33593 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33594 ret_ref = (uintptr_t)ret_var.inner;
33595 if (ret_var.is_owned) {
33596         ret_ref |= 1;
33597 }
33598         return ret_ref;
33599 }
33600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33601         LDKChannelUpdate arg_conv;
33602         arg_conv.inner = (void*)(arg & (~1));
33603         arg_conv.is_owned = false;
33604         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33605         int64_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
33606         return ret_val;
33607 }
33608
33609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33610         LDKChannelUpdate orig_conv;
33611         orig_conv.inner = (void*)(orig & (~1));
33612         orig_conv.is_owned = false;
33613         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33614         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
33615         int64_t ret_ref = 0;
33616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33619         ret_ref = (uintptr_t)ret_var.inner;
33620         if (ret_var.is_owned) {
33621                 ret_ref |= 1;
33622         }
33623         return ret_ref;
33624 }
33625
33626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33627         LDKQueryChannelRange this_obj_conv;
33628         this_obj_conv.inner = (void*)(this_obj & (~1));
33629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33631         QueryChannelRange_free(this_obj_conv);
33632 }
33633
33634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33635         LDKQueryChannelRange this_ptr_conv;
33636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33637         this_ptr_conv.is_owned = false;
33638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33639         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33640         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
33641         return ret_arr;
33642 }
33643
33644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33645         LDKQueryChannelRange this_ptr_conv;
33646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33647         this_ptr_conv.is_owned = false;
33648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33649         LDKThirtyTwoBytes val_ref;
33650         CHECK((*env)->GetArrayLength(env, val) == 32);
33651         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33652         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
33653 }
33654
33655 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
33656         LDKQueryChannelRange this_ptr_conv;
33657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33658         this_ptr_conv.is_owned = false;
33659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33660         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
33661         return ret_val;
33662 }
33663
33664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33665         LDKQueryChannelRange this_ptr_conv;
33666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33667         this_ptr_conv.is_owned = false;
33668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33669         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
33670 }
33671
33672 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
33673         LDKQueryChannelRange this_ptr_conv;
33674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33675         this_ptr_conv.is_owned = false;
33676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33677         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
33678         return ret_val;
33679 }
33680
33681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33682         LDKQueryChannelRange this_ptr_conv;
33683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33684         this_ptr_conv.is_owned = false;
33685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33686         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
33687 }
33688
33689 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) {
33690         LDKThirtyTwoBytes chain_hash_arg_ref;
33691         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
33692         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
33693         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
33694         int64_t ret_ref = 0;
33695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33698         ret_ref = (uintptr_t)ret_var.inner;
33699         if (ret_var.is_owned) {
33700                 ret_ref |= 1;
33701         }
33702         return ret_ref;
33703 }
33704
33705 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
33706         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
33707 int64_t ret_ref = 0;
33708 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33709 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33710 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33711 ret_ref = (uintptr_t)ret_var.inner;
33712 if (ret_var.is_owned) {
33713         ret_ref |= 1;
33714 }
33715         return ret_ref;
33716 }
33717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33718         LDKQueryChannelRange arg_conv;
33719         arg_conv.inner = (void*)(arg & (~1));
33720         arg_conv.is_owned = false;
33721         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33722         int64_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
33723         return ret_val;
33724 }
33725
33726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33727         LDKQueryChannelRange orig_conv;
33728         orig_conv.inner = (void*)(orig & (~1));
33729         orig_conv.is_owned = false;
33730         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33731         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
33732         int64_t ret_ref = 0;
33733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33736         ret_ref = (uintptr_t)ret_var.inner;
33737         if (ret_var.is_owned) {
33738                 ret_ref |= 1;
33739         }
33740         return ret_ref;
33741 }
33742
33743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33744         LDKReplyChannelRange this_obj_conv;
33745         this_obj_conv.inner = (void*)(this_obj & (~1));
33746         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33748         ReplyChannelRange_free(this_obj_conv);
33749 }
33750
33751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33752         LDKReplyChannelRange this_ptr_conv;
33753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33754         this_ptr_conv.is_owned = false;
33755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33756         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33757         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
33758         return ret_arr;
33759 }
33760
33761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33762         LDKReplyChannelRange this_ptr_conv;
33763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33764         this_ptr_conv.is_owned = false;
33765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33766         LDKThirtyTwoBytes val_ref;
33767         CHECK((*env)->GetArrayLength(env, val) == 32);
33768         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33769         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
33770 }
33771
33772 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
33773         LDKReplyChannelRange this_ptr_conv;
33774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33775         this_ptr_conv.is_owned = false;
33776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33777         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
33778         return ret_val;
33779 }
33780
33781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33782         LDKReplyChannelRange this_ptr_conv;
33783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33784         this_ptr_conv.is_owned = false;
33785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33786         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
33787 }
33788
33789 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
33790         LDKReplyChannelRange this_ptr_conv;
33791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33792         this_ptr_conv.is_owned = false;
33793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33794         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
33795         return ret_val;
33796 }
33797
33798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33799         LDKReplyChannelRange this_ptr_conv;
33800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33801         this_ptr_conv.is_owned = false;
33802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33803         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
33804 }
33805
33806 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
33807         LDKReplyChannelRange this_ptr_conv;
33808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33809         this_ptr_conv.is_owned = false;
33810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33811         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
33812         return ret_val;
33813 }
33814
33815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
33816         LDKReplyChannelRange this_ptr_conv;
33817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33818         this_ptr_conv.is_owned = false;
33819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33820         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
33821 }
33822
33823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33824         LDKReplyChannelRange this_ptr_conv;
33825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33826         this_ptr_conv.is_owned = false;
33827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33828         LDKCVec_u64Z val_constr;
33829         val_constr.datalen = (*env)->GetArrayLength(env, val);
33830         if (val_constr.datalen > 0)
33831                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33832         else
33833                 val_constr.data = NULL;
33834         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33835         for (size_t g = 0; g < val_constr.datalen; g++) {
33836                 int64_t val_conv_6 = val_vals[g];
33837                 val_constr.data[g] = val_conv_6;
33838         }
33839         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33840         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
33841 }
33842
33843 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) {
33844         LDKThirtyTwoBytes chain_hash_arg_ref;
33845         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
33846         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
33847         LDKCVec_u64Z short_channel_ids_arg_constr;
33848         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
33849         if (short_channel_ids_arg_constr.datalen > 0)
33850                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33851         else
33852                 short_channel_ids_arg_constr.data = NULL;
33853         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
33854         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
33855                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
33856                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
33857         }
33858         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
33859         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
33860         int64_t ret_ref = 0;
33861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33864         ret_ref = (uintptr_t)ret_var.inner;
33865         if (ret_var.is_owned) {
33866                 ret_ref |= 1;
33867         }
33868         return ret_ref;
33869 }
33870
33871 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
33872         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
33873 int64_t ret_ref = 0;
33874 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33875 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33876 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33877 ret_ref = (uintptr_t)ret_var.inner;
33878 if (ret_var.is_owned) {
33879         ret_ref |= 1;
33880 }
33881         return ret_ref;
33882 }
33883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33884         LDKReplyChannelRange arg_conv;
33885         arg_conv.inner = (void*)(arg & (~1));
33886         arg_conv.is_owned = false;
33887         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33888         int64_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
33889         return ret_val;
33890 }
33891
33892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33893         LDKReplyChannelRange orig_conv;
33894         orig_conv.inner = (void*)(orig & (~1));
33895         orig_conv.is_owned = false;
33896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33897         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
33898         int64_t ret_ref = 0;
33899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33902         ret_ref = (uintptr_t)ret_var.inner;
33903         if (ret_var.is_owned) {
33904                 ret_ref |= 1;
33905         }
33906         return ret_ref;
33907 }
33908
33909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33910         LDKQueryShortChannelIds this_obj_conv;
33911         this_obj_conv.inner = (void*)(this_obj & (~1));
33912         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33914         QueryShortChannelIds_free(this_obj_conv);
33915 }
33916
33917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33918         LDKQueryShortChannelIds 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
33924         return ret_arr;
33925 }
33926
33927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33928         LDKQueryShortChannelIds this_ptr_conv;
33929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33930         this_ptr_conv.is_owned = false;
33931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33932         LDKThirtyTwoBytes val_ref;
33933         CHECK((*env)->GetArrayLength(env, val) == 32);
33934         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33935         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
33936 }
33937
33938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33939         LDKQueryShortChannelIds this_ptr_conv;
33940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33941         this_ptr_conv.is_owned = false;
33942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33943         LDKCVec_u64Z val_constr;
33944         val_constr.datalen = (*env)->GetArrayLength(env, val);
33945         if (val_constr.datalen > 0)
33946                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33947         else
33948                 val_constr.data = NULL;
33949         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33950         for (size_t g = 0; g < val_constr.datalen; g++) {
33951                 int64_t val_conv_6 = val_vals[g];
33952                 val_constr.data[g] = val_conv_6;
33953         }
33954         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33955         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
33956 }
33957
33958 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) {
33959         LDKThirtyTwoBytes chain_hash_arg_ref;
33960         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
33961         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
33962         LDKCVec_u64Z short_channel_ids_arg_constr;
33963         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
33964         if (short_channel_ids_arg_constr.datalen > 0)
33965                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33966         else
33967                 short_channel_ids_arg_constr.data = NULL;
33968         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
33969         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
33970                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
33971                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
33972         }
33973         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
33974         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
33975         int64_t ret_ref = 0;
33976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33979         ret_ref = (uintptr_t)ret_var.inner;
33980         if (ret_var.is_owned) {
33981                 ret_ref |= 1;
33982         }
33983         return ret_ref;
33984 }
33985
33986 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
33987         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
33988 int64_t ret_ref = 0;
33989 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33990 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33991 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33992 ret_ref = (uintptr_t)ret_var.inner;
33993 if (ret_var.is_owned) {
33994         ret_ref |= 1;
33995 }
33996         return ret_ref;
33997 }
33998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33999         LDKQueryShortChannelIds arg_conv;
34000         arg_conv.inner = (void*)(arg & (~1));
34001         arg_conv.is_owned = false;
34002         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34003         int64_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
34004         return ret_val;
34005 }
34006
34007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34008         LDKQueryShortChannelIds orig_conv;
34009         orig_conv.inner = (void*)(orig & (~1));
34010         orig_conv.is_owned = false;
34011         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34012         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
34013         int64_t ret_ref = 0;
34014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34017         ret_ref = (uintptr_t)ret_var.inner;
34018         if (ret_var.is_owned) {
34019                 ret_ref |= 1;
34020         }
34021         return ret_ref;
34022 }
34023
34024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34025         LDKReplyShortChannelIdsEnd this_obj_conv;
34026         this_obj_conv.inner = (void*)(this_obj & (~1));
34027         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34029         ReplyShortChannelIdsEnd_free(this_obj_conv);
34030 }
34031
34032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34033         LDKReplyShortChannelIdsEnd this_ptr_conv;
34034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34035         this_ptr_conv.is_owned = false;
34036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34037         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34038         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
34039         return ret_arr;
34040 }
34041
34042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34043         LDKReplyShortChannelIdsEnd this_ptr_conv;
34044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34045         this_ptr_conv.is_owned = false;
34046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34047         LDKThirtyTwoBytes val_ref;
34048         CHECK((*env)->GetArrayLength(env, val) == 32);
34049         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34050         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
34051 }
34052
34053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
34054         LDKReplyShortChannelIdsEnd this_ptr_conv;
34055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34056         this_ptr_conv.is_owned = false;
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34058         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
34059         return ret_val;
34060 }
34061
34062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34063         LDKReplyShortChannelIdsEnd this_ptr_conv;
34064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34065         this_ptr_conv.is_owned = false;
34066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34067         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
34068 }
34069
34070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
34071         LDKThirtyTwoBytes chain_hash_arg_ref;
34072         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34073         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34074         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
34075         int64_t ret_ref = 0;
34076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34079         ret_ref = (uintptr_t)ret_var.inner;
34080         if (ret_var.is_owned) {
34081                 ret_ref |= 1;
34082         }
34083         return ret_ref;
34084 }
34085
34086 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
34087         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
34088 int64_t ret_ref = 0;
34089 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34090 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34091 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34092 ret_ref = (uintptr_t)ret_var.inner;
34093 if (ret_var.is_owned) {
34094         ret_ref |= 1;
34095 }
34096         return ret_ref;
34097 }
34098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34099         LDKReplyShortChannelIdsEnd arg_conv;
34100         arg_conv.inner = (void*)(arg & (~1));
34101         arg_conv.is_owned = false;
34102         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34103         int64_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
34104         return ret_val;
34105 }
34106
34107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34108         LDKReplyShortChannelIdsEnd orig_conv;
34109         orig_conv.inner = (void*)(orig & (~1));
34110         orig_conv.is_owned = false;
34111         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34112         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
34113         int64_t ret_ref = 0;
34114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34117         ret_ref = (uintptr_t)ret_var.inner;
34118         if (ret_var.is_owned) {
34119                 ret_ref |= 1;
34120         }
34121         return ret_ref;
34122 }
34123
34124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34125         LDKGossipTimestampFilter this_obj_conv;
34126         this_obj_conv.inner = (void*)(this_obj & (~1));
34127         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34129         GossipTimestampFilter_free(this_obj_conv);
34130 }
34131
34132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34133         LDKGossipTimestampFilter this_ptr_conv;
34134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34135         this_ptr_conv.is_owned = false;
34136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34137         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34138         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
34139         return ret_arr;
34140 }
34141
34142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34143         LDKGossipTimestampFilter this_ptr_conv;
34144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34145         this_ptr_conv.is_owned = false;
34146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34147         LDKThirtyTwoBytes val_ref;
34148         CHECK((*env)->GetArrayLength(env, val) == 32);
34149         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34150         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
34151 }
34152
34153 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34154         LDKGossipTimestampFilter this_ptr_conv;
34155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34156         this_ptr_conv.is_owned = false;
34157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34158         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
34159         return ret_val;
34160 }
34161
34162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34163         LDKGossipTimestampFilter this_ptr_conv;
34164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34165         this_ptr_conv.is_owned = false;
34166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34167         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
34168 }
34169
34170 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
34171         LDKGossipTimestampFilter this_ptr_conv;
34172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34173         this_ptr_conv.is_owned = false;
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34175         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
34176         return ret_val;
34177 }
34178
34179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34180         LDKGossipTimestampFilter this_ptr_conv;
34181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34182         this_ptr_conv.is_owned = false;
34183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34184         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
34185 }
34186
34187 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) {
34188         LDKThirtyTwoBytes chain_hash_arg_ref;
34189         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34190         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34191         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
34192         int64_t ret_ref = 0;
34193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34196         ret_ref = (uintptr_t)ret_var.inner;
34197         if (ret_var.is_owned) {
34198                 ret_ref |= 1;
34199         }
34200         return ret_ref;
34201 }
34202
34203 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
34204         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
34205 int64_t ret_ref = 0;
34206 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34207 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34208 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34209 ret_ref = (uintptr_t)ret_var.inner;
34210 if (ret_var.is_owned) {
34211         ret_ref |= 1;
34212 }
34213         return ret_ref;
34214 }
34215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34216         LDKGossipTimestampFilter arg_conv;
34217         arg_conv.inner = (void*)(arg & (~1));
34218         arg_conv.is_owned = false;
34219         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34220         int64_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
34221         return ret_val;
34222 }
34223
34224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34225         LDKGossipTimestampFilter orig_conv;
34226         orig_conv.inner = (void*)(orig & (~1));
34227         orig_conv.is_owned = false;
34228         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34229         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
34230         int64_t ret_ref = 0;
34231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34234         ret_ref = (uintptr_t)ret_var.inner;
34235         if (ret_var.is_owned) {
34236                 ret_ref |= 1;
34237         }
34238         return ret_ref;
34239 }
34240
34241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34242         if ((this_ptr & 1) != 0) return;
34243         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34244         CHECK_ACCESS(this_ptr_ptr);
34245         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
34246         FREE((void*)this_ptr);
34247         ErrorAction_free(this_ptr_conv);
34248 }
34249
34250 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
34251         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34252         *ret_copy = ErrorAction_clone(arg);
34253 int64_t ret_ref = (uintptr_t)ret_copy;
34254         return ret_ref;
34255 }
34256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34257         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
34258         int64_t ret_val = ErrorAction_clone_ptr(arg_conv);
34259         return ret_val;
34260 }
34261
34262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34263         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
34264         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34265         *ret_copy = ErrorAction_clone(orig_conv);
34266         int64_t ret_ref = (uintptr_t)ret_copy;
34267         return ret_ref;
34268 }
34269
34270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
34271         LDKErrorMessage msg_conv;
34272         msg_conv.inner = (void*)(msg & (~1));
34273         msg_conv.is_owned = (msg & 1) || (msg == 0);
34274         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34275         msg_conv = ErrorMessage_clone(&msg_conv);
34276         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34277         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
34278         int64_t ret_ref = (uintptr_t)ret_copy;
34279         return ret_ref;
34280 }
34281
34282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
34283         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34284         *ret_copy = ErrorAction_ignore_error();
34285         int64_t ret_ref = (uintptr_t)ret_copy;
34286         return ret_ref;
34287 }
34288
34289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
34290         LDKLevel a_conv = LDKLevel_from_java(env, a);
34291         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34292         *ret_copy = ErrorAction_ignore_and_log(a_conv);
34293         int64_t ret_ref = (uintptr_t)ret_copy;
34294         return ret_ref;
34295 }
34296
34297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
34298         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34299         *ret_copy = ErrorAction_ignore_duplicate_gossip();
34300         int64_t ret_ref = (uintptr_t)ret_copy;
34301         return ret_ref;
34302 }
34303
34304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
34305         LDKErrorMessage msg_conv;
34306         msg_conv.inner = (void*)(msg & (~1));
34307         msg_conv.is_owned = (msg & 1) || (msg == 0);
34308         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34309         msg_conv = ErrorMessage_clone(&msg_conv);
34310         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34311         *ret_copy = ErrorAction_send_error_message(msg_conv);
34312         int64_t ret_ref = (uintptr_t)ret_copy;
34313         return ret_ref;
34314 }
34315
34316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
34317         LDKWarningMessage msg_conv;
34318         msg_conv.inner = (void*)(msg & (~1));
34319         msg_conv.is_owned = (msg & 1) || (msg == 0);
34320         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34321         msg_conv = WarningMessage_clone(&msg_conv);
34322         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
34323         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34324         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
34325         int64_t ret_ref = (uintptr_t)ret_copy;
34326         return ret_ref;
34327 }
34328
34329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34330         LDKLightningError this_obj_conv;
34331         this_obj_conv.inner = (void*)(this_obj & (~1));
34332         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34334         LightningError_free(this_obj_conv);
34335 }
34336
34337 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
34338         LDKLightningError this_ptr_conv;
34339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34340         this_ptr_conv.is_owned = false;
34341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34342         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
34343         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34344         Str_free(ret_str);
34345         return ret_conv;
34346 }
34347
34348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34349         LDKLightningError this_ptr_conv;
34350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34351         this_ptr_conv.is_owned = false;
34352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34353         LDKStr val_conv = java_to_owned_str(env, val);
34354         LightningError_set_err(&this_ptr_conv, val_conv);
34355 }
34356
34357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
34358         LDKLightningError this_ptr_conv;
34359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34360         this_ptr_conv.is_owned = false;
34361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34362         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34363         *ret_copy = LightningError_get_action(&this_ptr_conv);
34364         int64_t ret_ref = (uintptr_t)ret_copy;
34365         return ret_ref;
34366 }
34367
34368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34369         LDKLightningError this_ptr_conv;
34370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34371         this_ptr_conv.is_owned = false;
34372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34373         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34374         CHECK_ACCESS(val_ptr);
34375         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
34376         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
34377         LightningError_set_action(&this_ptr_conv, val_conv);
34378 }
34379
34380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
34381         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
34382         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
34383         CHECK_ACCESS(action_arg_ptr);
34384         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
34385         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
34386         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
34387         int64_t ret_ref = 0;
34388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34391         ret_ref = (uintptr_t)ret_var.inner;
34392         if (ret_var.is_owned) {
34393                 ret_ref |= 1;
34394         }
34395         return ret_ref;
34396 }
34397
34398 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
34399         LDKLightningError ret_var = LightningError_clone(arg);
34400 int64_t ret_ref = 0;
34401 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34402 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34403 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34404 ret_ref = (uintptr_t)ret_var.inner;
34405 if (ret_var.is_owned) {
34406         ret_ref |= 1;
34407 }
34408         return ret_ref;
34409 }
34410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34411         LDKLightningError arg_conv;
34412         arg_conv.inner = (void*)(arg & (~1));
34413         arg_conv.is_owned = false;
34414         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34415         int64_t ret_val = LightningError_clone_ptr(&arg_conv);
34416         return ret_val;
34417 }
34418
34419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34420         LDKLightningError orig_conv;
34421         orig_conv.inner = (void*)(orig & (~1));
34422         orig_conv.is_owned = false;
34423         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34424         LDKLightningError ret_var = LightningError_clone(&orig_conv);
34425         int64_t ret_ref = 0;
34426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34429         ret_ref = (uintptr_t)ret_var.inner;
34430         if (ret_var.is_owned) {
34431                 ret_ref |= 1;
34432         }
34433         return ret_ref;
34434 }
34435
34436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34437         LDKCommitmentUpdate this_obj_conv;
34438         this_obj_conv.inner = (void*)(this_obj & (~1));
34439         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34441         CommitmentUpdate_free(this_obj_conv);
34442 }
34443
34444 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34445         LDKCommitmentUpdate this_ptr_conv;
34446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34447         this_ptr_conv.is_owned = false;
34448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34449         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
34450         int64_tArray ret_arr = NULL;
34451         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34452         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34453         for (size_t p = 0; p < ret_var.datalen; p++) {
34454                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
34455                 int64_t ret_conv_15_ref = 0;
34456                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34457                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34458                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
34459                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
34460                 if (ret_conv_15_var.is_owned) {
34461                         ret_conv_15_ref |= 1;
34462                 }
34463                 ret_arr_ptr[p] = ret_conv_15_ref;
34464         }
34465         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34466         FREE(ret_var.data);
34467         return ret_arr;
34468 }
34469
34470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34471         LDKCommitmentUpdate this_ptr_conv;
34472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34473         this_ptr_conv.is_owned = false;
34474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34475         LDKCVec_UpdateAddHTLCZ val_constr;
34476         val_constr.datalen = (*env)->GetArrayLength(env, val);
34477         if (val_constr.datalen > 0)
34478                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
34479         else
34480                 val_constr.data = NULL;
34481         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34482         for (size_t p = 0; p < val_constr.datalen; p++) {
34483                 int64_t val_conv_15 = val_vals[p];
34484                 LDKUpdateAddHTLC val_conv_15_conv;
34485                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
34486                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
34487                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
34488                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
34489                 val_constr.data[p] = val_conv_15_conv;
34490         }
34491         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34492         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
34493 }
34494
34495 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34496         LDKCommitmentUpdate this_ptr_conv;
34497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34498         this_ptr_conv.is_owned = false;
34499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34500         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
34501         int64_tArray ret_arr = NULL;
34502         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34503         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34504         for (size_t t = 0; t < ret_var.datalen; t++) {
34505                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
34506                 int64_t ret_conv_19_ref = 0;
34507                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34508                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34509                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
34510                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
34511                 if (ret_conv_19_var.is_owned) {
34512                         ret_conv_19_ref |= 1;
34513                 }
34514                 ret_arr_ptr[t] = ret_conv_19_ref;
34515         }
34516         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34517         FREE(ret_var.data);
34518         return ret_arr;
34519 }
34520
34521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34522         LDKCommitmentUpdate this_ptr_conv;
34523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34524         this_ptr_conv.is_owned = false;
34525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34526         LDKCVec_UpdateFulfillHTLCZ val_constr;
34527         val_constr.datalen = (*env)->GetArrayLength(env, val);
34528         if (val_constr.datalen > 0)
34529                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
34530         else
34531                 val_constr.data = NULL;
34532         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34533         for (size_t t = 0; t < val_constr.datalen; t++) {
34534                 int64_t val_conv_19 = val_vals[t];
34535                 LDKUpdateFulfillHTLC val_conv_19_conv;
34536                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
34537                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
34538                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
34539                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
34540                 val_constr.data[t] = val_conv_19_conv;
34541         }
34542         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34543         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
34544 }
34545
34546 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34547         LDKCommitmentUpdate this_ptr_conv;
34548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34549         this_ptr_conv.is_owned = false;
34550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34551         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
34552         int64_tArray ret_arr = NULL;
34553         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34554         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34555         for (size_t q = 0; q < ret_var.datalen; q++) {
34556                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
34557                 int64_t ret_conv_16_ref = 0;
34558                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34559                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34560                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
34561                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
34562                 if (ret_conv_16_var.is_owned) {
34563                         ret_conv_16_ref |= 1;
34564                 }
34565                 ret_arr_ptr[q] = ret_conv_16_ref;
34566         }
34567         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34568         FREE(ret_var.data);
34569         return ret_arr;
34570 }
34571
34572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34573         LDKCommitmentUpdate this_ptr_conv;
34574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34575         this_ptr_conv.is_owned = false;
34576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34577         LDKCVec_UpdateFailHTLCZ val_constr;
34578         val_constr.datalen = (*env)->GetArrayLength(env, val);
34579         if (val_constr.datalen > 0)
34580                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
34581         else
34582                 val_constr.data = NULL;
34583         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34584         for (size_t q = 0; q < val_constr.datalen; q++) {
34585                 int64_t val_conv_16 = val_vals[q];
34586                 LDKUpdateFailHTLC val_conv_16_conv;
34587                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
34588                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
34589                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
34590                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
34591                 val_constr.data[q] = val_conv_16_conv;
34592         }
34593         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34594         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
34595 }
34596
34597 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34598         LDKCommitmentUpdate this_ptr_conv;
34599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34600         this_ptr_conv.is_owned = false;
34601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34602         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
34603         int64_tArray ret_arr = NULL;
34604         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34605         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34606         for (size_t z = 0; z < ret_var.datalen; z++) {
34607                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
34608                 int64_t ret_conv_25_ref = 0;
34609                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34610                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34611                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
34612                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
34613                 if (ret_conv_25_var.is_owned) {
34614                         ret_conv_25_ref |= 1;
34615                 }
34616                 ret_arr_ptr[z] = ret_conv_25_ref;
34617         }
34618         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34619         FREE(ret_var.data);
34620         return ret_arr;
34621 }
34622
34623 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) {
34624         LDKCommitmentUpdate this_ptr_conv;
34625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34626         this_ptr_conv.is_owned = false;
34627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34628         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
34629         val_constr.datalen = (*env)->GetArrayLength(env, val);
34630         if (val_constr.datalen > 0)
34631                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
34632         else
34633                 val_constr.data = NULL;
34634         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34635         for (size_t z = 0; z < val_constr.datalen; z++) {
34636                 int64_t val_conv_25 = val_vals[z];
34637                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
34638                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
34639                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
34640                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
34641                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
34642                 val_constr.data[z] = val_conv_25_conv;
34643         }
34644         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34645         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
34646 }
34647
34648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
34649         LDKCommitmentUpdate this_ptr_conv;
34650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34651         this_ptr_conv.is_owned = false;
34652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34653         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
34654         int64_t ret_ref = 0;
34655         if ((uintptr_t)ret_var.inner > 4096) {
34656                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34657                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34659                 ret_ref = (uintptr_t)ret_var.inner;
34660                 if (ret_var.is_owned) {
34661                         ret_ref |= 1;
34662                 }
34663         }
34664         return ret_ref;
34665 }
34666
34667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34668         LDKCommitmentUpdate this_ptr_conv;
34669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34670         this_ptr_conv.is_owned = false;
34671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34672         LDKUpdateFee val_conv;
34673         val_conv.inner = (void*)(val & (~1));
34674         val_conv.is_owned = (val & 1) || (val == 0);
34675         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34676         val_conv = UpdateFee_clone(&val_conv);
34677         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
34678 }
34679
34680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
34681         LDKCommitmentUpdate this_ptr_conv;
34682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34683         this_ptr_conv.is_owned = false;
34684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34685         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
34686         int64_t ret_ref = 0;
34687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34690         ret_ref = (uintptr_t)ret_var.inner;
34691         if (ret_var.is_owned) {
34692                 ret_ref |= 1;
34693         }
34694         return ret_ref;
34695 }
34696
34697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34698         LDKCommitmentUpdate this_ptr_conv;
34699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34700         this_ptr_conv.is_owned = false;
34701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34702         LDKCommitmentSigned val_conv;
34703         val_conv.inner = (void*)(val & (~1));
34704         val_conv.is_owned = (val & 1) || (val == 0);
34705         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34706         val_conv = CommitmentSigned_clone(&val_conv);
34707         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
34708 }
34709
34710 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) {
34711         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
34712         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
34713         if (update_add_htlcs_arg_constr.datalen > 0)
34714                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
34715         else
34716                 update_add_htlcs_arg_constr.data = NULL;
34717         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
34718         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
34719                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
34720                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
34721                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
34722                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
34723                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
34724                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
34725                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
34726         }
34727         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
34728         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
34729         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
34730         if (update_fulfill_htlcs_arg_constr.datalen > 0)
34731                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
34732         else
34733                 update_fulfill_htlcs_arg_constr.data = NULL;
34734         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
34735         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
34736                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
34737                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
34738                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
34739                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
34740                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
34741                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
34742                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
34743         }
34744         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
34745         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
34746         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
34747         if (update_fail_htlcs_arg_constr.datalen > 0)
34748                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
34749         else
34750                 update_fail_htlcs_arg_constr.data = NULL;
34751         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
34752         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
34753                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
34754                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
34755                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
34756                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
34757                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
34758                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
34759                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
34760         }
34761         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
34762         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
34763         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
34764         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
34765                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
34766         else
34767                 update_fail_malformed_htlcs_arg_constr.data = NULL;
34768         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
34769         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
34770                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
34771                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
34772                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
34773                 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);
34774                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
34775                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
34776                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
34777         }
34778         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
34779         LDKUpdateFee update_fee_arg_conv;
34780         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
34781         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
34782         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
34783         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
34784         LDKCommitmentSigned commitment_signed_arg_conv;
34785         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
34786         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
34787         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
34788         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
34789         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);
34790         int64_t ret_ref = 0;
34791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34794         ret_ref = (uintptr_t)ret_var.inner;
34795         if (ret_var.is_owned) {
34796                 ret_ref |= 1;
34797         }
34798         return ret_ref;
34799 }
34800
34801 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
34802         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
34803 int64_t ret_ref = 0;
34804 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34805 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34806 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34807 ret_ref = (uintptr_t)ret_var.inner;
34808 if (ret_var.is_owned) {
34809         ret_ref |= 1;
34810 }
34811         return ret_ref;
34812 }
34813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34814         LDKCommitmentUpdate arg_conv;
34815         arg_conv.inner = (void*)(arg & (~1));
34816         arg_conv.is_owned = false;
34817         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34818         int64_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
34819         return ret_val;
34820 }
34821
34822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34823         LDKCommitmentUpdate orig_conv;
34824         orig_conv.inner = (void*)(orig & (~1));
34825         orig_conv.is_owned = false;
34826         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34827         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
34828         int64_t ret_ref = 0;
34829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34832         ret_ref = (uintptr_t)ret_var.inner;
34833         if (ret_var.is_owned) {
34834                 ret_ref |= 1;
34835         }
34836         return ret_ref;
34837 }
34838
34839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34840         if ((this_ptr & 1) != 0) return;
34841         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34842         CHECK_ACCESS(this_ptr_ptr);
34843         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
34844         FREE((void*)this_ptr);
34845         ChannelMessageHandler_free(this_ptr_conv);
34846 }
34847
34848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34849         if ((this_ptr & 1) != 0) return;
34850         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34851         CHECK_ACCESS(this_ptr_ptr);
34852         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
34853         FREE((void*)this_ptr);
34854         RoutingMessageHandler_free(this_ptr_conv);
34855 }
34856
34857 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
34858         LDKAcceptChannel obj_conv;
34859         obj_conv.inner = (void*)(obj & (~1));
34860         obj_conv.is_owned = false;
34861         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34862         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
34863         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34864         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34865         CVec_u8Z_free(ret_var);
34866         return ret_arr;
34867 }
34868
34869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34870         LDKu8slice ser_ref;
34871         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34872         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34873         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
34874         *ret_conv = AcceptChannel_read(ser_ref);
34875         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34876         return (int64_t)ret_conv;
34877 }
34878
34879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34880         LDKAnnouncementSignatures obj_conv;
34881         obj_conv.inner = (void*)(obj & (~1));
34882         obj_conv.is_owned = false;
34883         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34884         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
34885         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34886         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34887         CVec_u8Z_free(ret_var);
34888         return ret_arr;
34889 }
34890
34891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34892         LDKu8slice ser_ref;
34893         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34894         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34895         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
34896         *ret_conv = AnnouncementSignatures_read(ser_ref);
34897         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34898         return (int64_t)ret_conv;
34899 }
34900
34901 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
34902         LDKChannelReestablish obj_conv;
34903         obj_conv.inner = (void*)(obj & (~1));
34904         obj_conv.is_owned = false;
34905         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34906         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
34907         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34908         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34909         CVec_u8Z_free(ret_var);
34910         return ret_arr;
34911 }
34912
34913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34914         LDKu8slice ser_ref;
34915         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34916         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34917         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
34918         *ret_conv = ChannelReestablish_read(ser_ref);
34919         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34920         return (int64_t)ret_conv;
34921 }
34922
34923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
34924         LDKClosingSigned obj_conv;
34925         obj_conv.inner = (void*)(obj & (~1));
34926         obj_conv.is_owned = false;
34927         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34928         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
34929         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34930         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34931         CVec_u8Z_free(ret_var);
34932         return ret_arr;
34933 }
34934
34935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34936         LDKu8slice ser_ref;
34937         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34938         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34939         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
34940         *ret_conv = ClosingSigned_read(ser_ref);
34941         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34942         return (int64_t)ret_conv;
34943 }
34944
34945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
34946         LDKClosingSignedFeeRange obj_conv;
34947         obj_conv.inner = (void*)(obj & (~1));
34948         obj_conv.is_owned = false;
34949         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34950         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
34951         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34952         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34953         CVec_u8Z_free(ret_var);
34954         return ret_arr;
34955 }
34956
34957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34958         LDKu8slice ser_ref;
34959         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34960         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34961         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
34962         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
34963         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34964         return (int64_t)ret_conv;
34965 }
34966
34967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
34968         LDKCommitmentSigned obj_conv;
34969         obj_conv.inner = (void*)(obj & (~1));
34970         obj_conv.is_owned = false;
34971         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34972         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
34973         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34974         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34975         CVec_u8Z_free(ret_var);
34976         return ret_arr;
34977 }
34978
34979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34980         LDKu8slice ser_ref;
34981         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34982         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34983         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
34984         *ret_conv = CommitmentSigned_read(ser_ref);
34985         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34986         return (int64_t)ret_conv;
34987 }
34988
34989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
34990         LDKFundingCreated obj_conv;
34991         obj_conv.inner = (void*)(obj & (~1));
34992         obj_conv.is_owned = false;
34993         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34994         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
34995         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34996         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34997         CVec_u8Z_free(ret_var);
34998         return ret_arr;
34999 }
35000
35001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35002         LDKu8slice ser_ref;
35003         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35004         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35005         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
35006         *ret_conv = FundingCreated_read(ser_ref);
35007         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35008         return (int64_t)ret_conv;
35009 }
35010
35011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35012         LDKFundingSigned obj_conv;
35013         obj_conv.inner = (void*)(obj & (~1));
35014         obj_conv.is_owned = false;
35015         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35016         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
35017         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35018         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35019         CVec_u8Z_free(ret_var);
35020         return ret_arr;
35021 }
35022
35023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35024         LDKu8slice ser_ref;
35025         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35026         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35027         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
35028         *ret_conv = FundingSigned_read(ser_ref);
35029         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35030         return (int64_t)ret_conv;
35031 }
35032
35033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
35034         LDKFundingLocked obj_conv;
35035         obj_conv.inner = (void*)(obj & (~1));
35036         obj_conv.is_owned = false;
35037         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35038         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
35039         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35040         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35041         CVec_u8Z_free(ret_var);
35042         return ret_arr;
35043 }
35044
35045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35046         LDKu8slice ser_ref;
35047         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35048         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35049         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
35050         *ret_conv = FundingLocked_read(ser_ref);
35051         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35052         return (int64_t)ret_conv;
35053 }
35054
35055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
35056         LDKInit obj_conv;
35057         obj_conv.inner = (void*)(obj & (~1));
35058         obj_conv.is_owned = false;
35059         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35060         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
35061         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35062         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35063         CVec_u8Z_free(ret_var);
35064         return ret_arr;
35065 }
35066
35067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35068         LDKu8slice ser_ref;
35069         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35070         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35071         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
35072         *ret_conv = Init_read(ser_ref);
35073         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35074         return (int64_t)ret_conv;
35075 }
35076
35077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
35078         LDKOpenChannel obj_conv;
35079         obj_conv.inner = (void*)(obj & (~1));
35080         obj_conv.is_owned = false;
35081         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35082         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
35083         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35084         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35085         CVec_u8Z_free(ret_var);
35086         return ret_arr;
35087 }
35088
35089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35090         LDKu8slice ser_ref;
35091         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35092         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35093         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
35094         *ret_conv = OpenChannel_read(ser_ref);
35095         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35096         return (int64_t)ret_conv;
35097 }
35098
35099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
35100         LDKRevokeAndACK obj_conv;
35101         obj_conv.inner = (void*)(obj & (~1));
35102         obj_conv.is_owned = false;
35103         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35104         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
35105         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35106         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35107         CVec_u8Z_free(ret_var);
35108         return ret_arr;
35109 }
35110
35111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35112         LDKu8slice ser_ref;
35113         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35114         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35115         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
35116         *ret_conv = RevokeAndACK_read(ser_ref);
35117         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35118         return (int64_t)ret_conv;
35119 }
35120
35121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
35122         LDKShutdown obj_conv;
35123         obj_conv.inner = (void*)(obj & (~1));
35124         obj_conv.is_owned = false;
35125         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35126         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
35127         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35128         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35129         CVec_u8Z_free(ret_var);
35130         return ret_arr;
35131 }
35132
35133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35134         LDKu8slice ser_ref;
35135         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35136         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35137         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
35138         *ret_conv = Shutdown_read(ser_ref);
35139         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35140         return (int64_t)ret_conv;
35141 }
35142
35143 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35144         LDKUpdateFailHTLC obj_conv;
35145         obj_conv.inner = (void*)(obj & (~1));
35146         obj_conv.is_owned = false;
35147         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35148         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
35149         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35150         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35151         CVec_u8Z_free(ret_var);
35152         return ret_arr;
35153 }
35154
35155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35156         LDKu8slice ser_ref;
35157         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35158         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35159         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
35160         *ret_conv = UpdateFailHTLC_read(ser_ref);
35161         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35162         return (int64_t)ret_conv;
35163 }
35164
35165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35166         LDKUpdateFailMalformedHTLC obj_conv;
35167         obj_conv.inner = (void*)(obj & (~1));
35168         obj_conv.is_owned = false;
35169         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35170         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
35171         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35172         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35173         CVec_u8Z_free(ret_var);
35174         return ret_arr;
35175 }
35176
35177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35178         LDKu8slice ser_ref;
35179         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35180         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35181         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
35182         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
35183         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35184         return (int64_t)ret_conv;
35185 }
35186
35187 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
35188         LDKUpdateFee obj_conv;
35189         obj_conv.inner = (void*)(obj & (~1));
35190         obj_conv.is_owned = false;
35191         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35192         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
35193         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35194         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35195         CVec_u8Z_free(ret_var);
35196         return ret_arr;
35197 }
35198
35199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35200         LDKu8slice ser_ref;
35201         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35202         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35203         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
35204         *ret_conv = UpdateFee_read(ser_ref);
35205         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35206         return (int64_t)ret_conv;
35207 }
35208
35209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35210         LDKUpdateFulfillHTLC obj_conv;
35211         obj_conv.inner = (void*)(obj & (~1));
35212         obj_conv.is_owned = false;
35213         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35214         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
35215         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35216         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35217         CVec_u8Z_free(ret_var);
35218         return ret_arr;
35219 }
35220
35221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35222         LDKu8slice ser_ref;
35223         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35224         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35225         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
35226         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
35227         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35228         return (int64_t)ret_conv;
35229 }
35230
35231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35232         LDKUpdateAddHTLC obj_conv;
35233         obj_conv.inner = (void*)(obj & (~1));
35234         obj_conv.is_owned = false;
35235         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35236         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
35237         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35238         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35239         CVec_u8Z_free(ret_var);
35240         return ret_arr;
35241 }
35242
35243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35244         LDKu8slice ser_ref;
35245         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35246         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35247         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
35248         *ret_conv = UpdateAddHTLC_read(ser_ref);
35249         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35250         return (int64_t)ret_conv;
35251 }
35252
35253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
35254         LDKPing obj_conv;
35255         obj_conv.inner = (void*)(obj & (~1));
35256         obj_conv.is_owned = false;
35257         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35258         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
35259         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35260         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35261         CVec_u8Z_free(ret_var);
35262         return ret_arr;
35263 }
35264
35265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35266         LDKu8slice ser_ref;
35267         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35268         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35269         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
35270         *ret_conv = Ping_read(ser_ref);
35271         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35272         return (int64_t)ret_conv;
35273 }
35274
35275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
35276         LDKPong obj_conv;
35277         obj_conv.inner = (void*)(obj & (~1));
35278         obj_conv.is_owned = false;
35279         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35280         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
35281         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35282         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35283         CVec_u8Z_free(ret_var);
35284         return ret_arr;
35285 }
35286
35287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35288         LDKu8slice ser_ref;
35289         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35290         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35291         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
35292         *ret_conv = Pong_read(ser_ref);
35293         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35294         return (int64_t)ret_conv;
35295 }
35296
35297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35298         LDKUnsignedChannelAnnouncement obj_conv;
35299         obj_conv.inner = (void*)(obj & (~1));
35300         obj_conv.is_owned = false;
35301         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35302         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
35303         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35304         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35305         CVec_u8Z_free(ret_var);
35306         return ret_arr;
35307 }
35308
35309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35310         LDKu8slice ser_ref;
35311         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35312         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35313         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
35314         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
35315         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35316         return (int64_t)ret_conv;
35317 }
35318
35319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35320         LDKChannelAnnouncement obj_conv;
35321         obj_conv.inner = (void*)(obj & (~1));
35322         obj_conv.is_owned = false;
35323         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35324         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
35325         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35326         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35327         CVec_u8Z_free(ret_var);
35328         return ret_arr;
35329 }
35330
35331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35332         LDKu8slice ser_ref;
35333         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35334         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35335         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
35336         *ret_conv = ChannelAnnouncement_read(ser_ref);
35337         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35338         return (int64_t)ret_conv;
35339 }
35340
35341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35342         LDKUnsignedChannelUpdate obj_conv;
35343         obj_conv.inner = (void*)(obj & (~1));
35344         obj_conv.is_owned = false;
35345         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35346         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
35347         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35348         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35349         CVec_u8Z_free(ret_var);
35350         return ret_arr;
35351 }
35352
35353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35354         LDKu8slice ser_ref;
35355         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35356         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35357         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
35358         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
35359         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35360         return (int64_t)ret_conv;
35361 }
35362
35363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35364         LDKChannelUpdate obj_conv;
35365         obj_conv.inner = (void*)(obj & (~1));
35366         obj_conv.is_owned = false;
35367         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35368         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
35369         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35370         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35371         CVec_u8Z_free(ret_var);
35372         return ret_arr;
35373 }
35374
35375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35376         LDKu8slice ser_ref;
35377         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35378         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35379         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
35380         *ret_conv = ChannelUpdate_read(ser_ref);
35381         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35382         return (int64_t)ret_conv;
35383 }
35384
35385 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35386         LDKErrorMessage obj_conv;
35387         obj_conv.inner = (void*)(obj & (~1));
35388         obj_conv.is_owned = false;
35389         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35390         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
35391         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35392         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35393         CVec_u8Z_free(ret_var);
35394         return ret_arr;
35395 }
35396
35397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35398         LDKu8slice ser_ref;
35399         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35400         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35401         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
35402         *ret_conv = ErrorMessage_read(ser_ref);
35403         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35404         return (int64_t)ret_conv;
35405 }
35406
35407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35408         LDKWarningMessage obj_conv;
35409         obj_conv.inner = (void*)(obj & (~1));
35410         obj_conv.is_owned = false;
35411         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35412         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
35413         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35414         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35415         CVec_u8Z_free(ret_var);
35416         return ret_arr;
35417 }
35418
35419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35420         LDKu8slice ser_ref;
35421         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35422         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35423         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
35424         *ret_conv = WarningMessage_read(ser_ref);
35425         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35426         return (int64_t)ret_conv;
35427 }
35428
35429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35430         LDKUnsignedNodeAnnouncement obj_conv;
35431         obj_conv.inner = (void*)(obj & (~1));
35432         obj_conv.is_owned = false;
35433         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35434         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
35435         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35436         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35437         CVec_u8Z_free(ret_var);
35438         return ret_arr;
35439 }
35440
35441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35442         LDKu8slice ser_ref;
35443         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35444         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35445         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
35446         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
35447         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35448         return (int64_t)ret_conv;
35449 }
35450
35451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35452         LDKNodeAnnouncement obj_conv;
35453         obj_conv.inner = (void*)(obj & (~1));
35454         obj_conv.is_owned = false;
35455         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35456         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
35457         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35458         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35459         CVec_u8Z_free(ret_var);
35460         return ret_arr;
35461 }
35462
35463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35464         LDKu8slice ser_ref;
35465         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35466         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35467         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
35468         *ret_conv = NodeAnnouncement_read(ser_ref);
35469         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35470         return (int64_t)ret_conv;
35471 }
35472
35473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35474         LDKu8slice ser_ref;
35475         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35476         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35477         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
35478         *ret_conv = QueryShortChannelIds_read(ser_ref);
35479         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35480         return (int64_t)ret_conv;
35481 }
35482
35483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
35484         LDKQueryShortChannelIds obj_conv;
35485         obj_conv.inner = (void*)(obj & (~1));
35486         obj_conv.is_owned = false;
35487         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35488         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
35489         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35490         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35491         CVec_u8Z_free(ret_var);
35492         return ret_arr;
35493 }
35494
35495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
35496         LDKReplyShortChannelIdsEnd obj_conv;
35497         obj_conv.inner = (void*)(obj & (~1));
35498         obj_conv.is_owned = false;
35499         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35500         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
35501         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35502         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35503         CVec_u8Z_free(ret_var);
35504         return ret_arr;
35505 }
35506
35507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35508         LDKu8slice ser_ref;
35509         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35510         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35511         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
35512         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
35513         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35514         return (int64_t)ret_conv;
35515 }
35516
35517 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
35518         LDKQueryChannelRange this_arg_conv;
35519         this_arg_conv.inner = (void*)(this_arg & (~1));
35520         this_arg_conv.is_owned = false;
35521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35522         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
35523         return ret_val;
35524 }
35525
35526 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
35527         LDKQueryChannelRange obj_conv;
35528         obj_conv.inner = (void*)(obj & (~1));
35529         obj_conv.is_owned = false;
35530         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35531         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
35532         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35533         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35534         CVec_u8Z_free(ret_var);
35535         return ret_arr;
35536 }
35537
35538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35539         LDKu8slice ser_ref;
35540         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35541         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35542         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
35543         *ret_conv = QueryChannelRange_read(ser_ref);
35544         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35545         return (int64_t)ret_conv;
35546 }
35547
35548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35549         LDKu8slice ser_ref;
35550         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35551         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35552         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
35553         *ret_conv = ReplyChannelRange_read(ser_ref);
35554         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35555         return (int64_t)ret_conv;
35556 }
35557
35558 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
35559         LDKReplyChannelRange obj_conv;
35560         obj_conv.inner = (void*)(obj & (~1));
35561         obj_conv.is_owned = false;
35562         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35563         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
35564         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35565         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35566         CVec_u8Z_free(ret_var);
35567         return ret_arr;
35568 }
35569
35570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
35571         LDKGossipTimestampFilter obj_conv;
35572         obj_conv.inner = (void*)(obj & (~1));
35573         obj_conv.is_owned = false;
35574         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35575         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
35576         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35577         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35578         CVec_u8Z_free(ret_var);
35579         return ret_arr;
35580 }
35581
35582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35583         LDKu8slice ser_ref;
35584         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35585         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35586         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
35587         *ret_conv = GossipTimestampFilter_read(ser_ref);
35588         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35589         return (int64_t)ret_conv;
35590 }
35591
35592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35593         if ((this_ptr & 1) != 0) return;
35594         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35595         CHECK_ACCESS(this_ptr_ptr);
35596         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
35597         FREE((void*)this_ptr);
35598         CustomMessageHandler_free(this_ptr_conv);
35599 }
35600
35601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35602         LDKIgnoringMessageHandler this_obj_conv;
35603         this_obj_conv.inner = (void*)(this_obj & (~1));
35604         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35606         IgnoringMessageHandler_free(this_obj_conv);
35607 }
35608
35609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
35610         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
35611         int64_t ret_ref = 0;
35612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35613         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35615         ret_ref = (uintptr_t)ret_var.inner;
35616         if (ret_var.is_owned) {
35617                 ret_ref |= 1;
35618         }
35619         return ret_ref;
35620 }
35621
35622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
35623         LDKIgnoringMessageHandler this_arg_conv;
35624         this_arg_conv.inner = (void*)(this_arg & (~1));
35625         this_arg_conv.is_owned = false;
35626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35627         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
35628         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
35629         return (int64_t)ret_ret;
35630 }
35631
35632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
35633         LDKIgnoringMessageHandler this_arg_conv;
35634         this_arg_conv.inner = (void*)(this_arg & (~1));
35635         this_arg_conv.is_owned = false;
35636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35637         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
35638         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
35639         return (int64_t)ret_ret;
35640 }
35641
35642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
35643         LDKIgnoringMessageHandler this_arg_conv;
35644         this_arg_conv.inner = (void*)(this_arg & (~1));
35645         this_arg_conv.is_owned = false;
35646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35647         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
35648         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
35649         return (int64_t)ret_ret;
35650 }
35651
35652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
35653         LDKIgnoringMessageHandler this_arg_conv;
35654         this_arg_conv.inner = (void*)(this_arg & (~1));
35655         this_arg_conv.is_owned = false;
35656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35657         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
35658         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
35659         return (int64_t)ret_ret;
35660 }
35661
35662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35663         LDKErroringMessageHandler this_obj_conv;
35664         this_obj_conv.inner = (void*)(this_obj & (~1));
35665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35667         ErroringMessageHandler_free(this_obj_conv);
35668 }
35669
35670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
35671         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
35672         int64_t ret_ref = 0;
35673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35676         ret_ref = (uintptr_t)ret_var.inner;
35677         if (ret_var.is_owned) {
35678                 ret_ref |= 1;
35679         }
35680         return ret_ref;
35681 }
35682
35683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
35684         LDKErroringMessageHandler this_arg_conv;
35685         this_arg_conv.inner = (void*)(this_arg & (~1));
35686         this_arg_conv.is_owned = false;
35687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35688         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
35689         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
35690         return (int64_t)ret_ret;
35691 }
35692
35693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
35694         LDKErroringMessageHandler this_arg_conv;
35695         this_arg_conv.inner = (void*)(this_arg & (~1));
35696         this_arg_conv.is_owned = false;
35697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35698         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
35699         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
35700         return (int64_t)ret_ret;
35701 }
35702
35703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35704         LDKMessageHandler this_obj_conv;
35705         this_obj_conv.inner = (void*)(this_obj & (~1));
35706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35708         MessageHandler_free(this_obj_conv);
35709 }
35710
35711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
35712         LDKMessageHandler this_ptr_conv;
35713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35714         this_ptr_conv.is_owned = false;
35715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35716         // WARNING: This object doesn't live past this scope, needs clone!
35717         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
35718         return ret_ret;
35719 }
35720
35721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35722         LDKMessageHandler this_ptr_conv;
35723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35724         this_ptr_conv.is_owned = false;
35725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35726         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35727         CHECK_ACCESS(val_ptr);
35728         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
35729         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
35730                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35731                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
35732         }
35733         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
35734 }
35735
35736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
35737         LDKMessageHandler this_ptr_conv;
35738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35739         this_ptr_conv.is_owned = false;
35740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35741         // WARNING: This object doesn't live past this scope, needs clone!
35742         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
35743         return ret_ret;
35744 }
35745
35746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35747         LDKMessageHandler this_ptr_conv;
35748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35749         this_ptr_conv.is_owned = false;
35750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35751         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35752         CHECK_ACCESS(val_ptr);
35753         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
35754         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
35755                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35756                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
35757         }
35758         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
35759 }
35760
35761 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) {
35762         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
35763         CHECK_ACCESS(chan_handler_arg_ptr);
35764         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
35765         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
35766                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35767                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
35768         }
35769         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
35770         CHECK_ACCESS(route_handler_arg_ptr);
35771         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
35772         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
35773                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35774                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
35775         }
35776         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
35777         int64_t ret_ref = 0;
35778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35781         ret_ref = (uintptr_t)ret_var.inner;
35782         if (ret_var.is_owned) {
35783                 ret_ref |= 1;
35784         }
35785         return ret_ref;
35786 }
35787
35788 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
35789         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
35790         *ret_ret = SocketDescriptor_clone(arg);
35791         return (int64_t)ret_ret;
35792 }
35793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35794         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
35795         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35796         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
35797         int64_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
35798         return ret_val;
35799 }
35800
35801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35802         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
35803         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35804         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
35805         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
35806         *ret_ret = SocketDescriptor_clone(orig_conv);
35807         return (int64_t)ret_ret;
35808 }
35809
35810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35811         if ((this_ptr & 1) != 0) return;
35812         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35813         CHECK_ACCESS(this_ptr_ptr);
35814         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
35815         FREE((void*)this_ptr);
35816         SocketDescriptor_free(this_ptr_conv);
35817 }
35818
35819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35820         LDKPeerHandleError this_obj_conv;
35821         this_obj_conv.inner = (void*)(this_obj & (~1));
35822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35824         PeerHandleError_free(this_obj_conv);
35825 }
35826
35827 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
35828         LDKPeerHandleError this_ptr_conv;
35829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35830         this_ptr_conv.is_owned = false;
35831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35832         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
35833         return ret_val;
35834 }
35835
35836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35837         LDKPeerHandleError this_ptr_conv;
35838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35839         this_ptr_conv.is_owned = false;
35840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35841         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
35842 }
35843
35844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
35845         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
35846         int64_t ret_ref = 0;
35847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35850         ret_ref = (uintptr_t)ret_var.inner;
35851         if (ret_var.is_owned) {
35852                 ret_ref |= 1;
35853         }
35854         return ret_ref;
35855 }
35856
35857 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
35858         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
35859 int64_t ret_ref = 0;
35860 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35861 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35862 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35863 ret_ref = (uintptr_t)ret_var.inner;
35864 if (ret_var.is_owned) {
35865         ret_ref |= 1;
35866 }
35867         return ret_ref;
35868 }
35869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35870         LDKPeerHandleError arg_conv;
35871         arg_conv.inner = (void*)(arg & (~1));
35872         arg_conv.is_owned = false;
35873         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35874         int64_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
35875         return ret_val;
35876 }
35877
35878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35879         LDKPeerHandleError orig_conv;
35880         orig_conv.inner = (void*)(orig & (~1));
35881         orig_conv.is_owned = false;
35882         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35883         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
35884         int64_t ret_ref = 0;
35885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35888         ret_ref = (uintptr_t)ret_var.inner;
35889         if (ret_var.is_owned) {
35890                 ret_ref |= 1;
35891         }
35892         return ret_ref;
35893 }
35894
35895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35896         LDKPeerManager this_obj_conv;
35897         this_obj_conv.inner = (void*)(this_obj & (~1));
35898         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35900         PeerManager_free(this_obj_conv);
35901 }
35902
35903 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) {
35904         LDKMessageHandler message_handler_conv;
35905         message_handler_conv.inner = (void*)(message_handler & (~1));
35906         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
35907         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
35908         // WARNING: we need a move here but no clone is available for LDKMessageHandler
35909         LDKSecretKey our_node_secret_ref;
35910         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
35911         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
35912         unsigned char ephemeral_random_data_arr[32];
35913         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
35914         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
35915         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
35916         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
35917         CHECK_ACCESS(logger_ptr);
35918         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
35919         if (logger_conv.free == LDKLogger_JCalls_free) {
35920                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35921                 LDKLogger_JCalls_cloned(&logger_conv);
35922         }
35923         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
35924         CHECK_ACCESS(custom_message_handler_ptr);
35925         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
35926         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
35927                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35928                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
35929         }
35930         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
35931         int64_t ret_ref = 0;
35932         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35933         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35935         ret_ref = (uintptr_t)ret_var.inner;
35936         if (ret_var.is_owned) {
35937                 ret_ref |= 1;
35938         }
35939         return ret_ref;
35940 }
35941
35942 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
35943         LDKPeerManager this_arg_conv;
35944         this_arg_conv.inner = (void*)(this_arg & (~1));
35945         this_arg_conv.is_owned = false;
35946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35947         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
35948         jobjectArray ret_arr = NULL;
35949         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
35950         ;
35951         for (size_t i = 0; i < ret_var.datalen; i++) {
35952                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
35953                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
35954                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
35955         }
35956         
35957         FREE(ret_var.data);
35958         return ret_arr;
35959 }
35960
35961 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) {
35962         LDKPeerManager this_arg_conv;
35963         this_arg_conv.inner = (void*)(this_arg & (~1));
35964         this_arg_conv.is_owned = false;
35965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35966         LDKPublicKey their_node_id_ref;
35967         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
35968         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
35969         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35970         CHECK_ACCESS(descriptor_ptr);
35971         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
35972         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
35973                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35974                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
35975         }
35976         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
35977         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
35978         return (int64_t)ret_conv;
35979 }
35980
35981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
35982         LDKPeerManager this_arg_conv;
35983         this_arg_conv.inner = (void*)(this_arg & (~1));
35984         this_arg_conv.is_owned = false;
35985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35986         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35987         CHECK_ACCESS(descriptor_ptr);
35988         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
35989         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
35990                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35991                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
35992         }
35993         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
35994         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
35995         return (int64_t)ret_conv;
35996 }
35997
35998 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) {
35999         LDKPeerManager this_arg_conv;
36000         this_arg_conv.inner = (void*)(this_arg & (~1));
36001         this_arg_conv.is_owned = false;
36002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36003         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36004         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
36005         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
36006         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
36007         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
36008         return (int64_t)ret_conv;
36009 }
36010
36011 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) {
36012         LDKPeerManager this_arg_conv;
36013         this_arg_conv.inner = (void*)(this_arg & (~1));
36014         this_arg_conv.is_owned = false;
36015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36016         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
36017         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
36018         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
36019         LDKu8slice data_ref;
36020         data_ref.datalen = (*env)->GetArrayLength(env, data);
36021         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
36022         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
36023         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
36024         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
36025         return (int64_t)ret_conv;
36026 }
36027
36028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
36029         LDKPeerManager this_arg_conv;
36030         this_arg_conv.inner = (void*)(this_arg & (~1));
36031         this_arg_conv.is_owned = false;
36032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36033         PeerManager_process_events(&this_arg_conv);
36034 }
36035
36036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
36037         LDKPeerManager this_arg_conv;
36038         this_arg_conv.inner = (void*)(this_arg & (~1));
36039         this_arg_conv.is_owned = false;
36040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36041         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36042         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
36043         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
36044         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
36045 }
36046
36047 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) {
36048         LDKPeerManager this_arg_conv;
36049         this_arg_conv.inner = (void*)(this_arg & (~1));
36050         this_arg_conv.is_owned = false;
36051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36052         LDKPublicKey node_id_ref;
36053         CHECK((*env)->GetArrayLength(env, node_id) == 33);
36054         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
36055         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
36056 }
36057
36058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
36059         LDKPeerManager this_arg_conv;
36060         this_arg_conv.inner = (void*)(this_arg & (~1));
36061         this_arg_conv.is_owned = false;
36062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36063         PeerManager_disconnect_all_peers(&this_arg_conv);
36064 }
36065
36066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
36067         LDKPeerManager this_arg_conv;
36068         this_arg_conv.inner = (void*)(this_arg & (~1));
36069         this_arg_conv.is_owned = false;
36070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36071         PeerManager_timer_tick_occurred(&this_arg_conv);
36072 }
36073
36074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
36075         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
36076         return ret_val;
36077 }
36078
36079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
36080         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
36081         return ret_val;
36082 }
36083
36084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
36085         unsigned char commitment_seed_arr[32];
36086         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
36087         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
36088         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
36089         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36090         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
36091         return ret_arr;
36092 }
36093
36094 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) {
36095         LDKCVec_u8Z to_holder_script_ref;
36096         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
36097         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36098         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
36099         LDKCVec_u8Z to_counterparty_script_ref;
36100         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
36101         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36102         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
36103         LDKOutPoint funding_outpoint_conv;
36104         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36105         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36106         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36107         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36108         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);
36109         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36110         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36111         Transaction_free(ret_var);
36112         return ret_arr;
36113 }
36114
36115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36116         LDKCounterpartyCommitmentSecrets this_obj_conv;
36117         this_obj_conv.inner = (void*)(this_obj & (~1));
36118         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36120         CounterpartyCommitmentSecrets_free(this_obj_conv);
36121 }
36122
36123 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
36124         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
36125 int64_t ret_ref = 0;
36126 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36127 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36128 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36129 ret_ref = (uintptr_t)ret_var.inner;
36130 if (ret_var.is_owned) {
36131         ret_ref |= 1;
36132 }
36133         return ret_ref;
36134 }
36135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36136         LDKCounterpartyCommitmentSecrets arg_conv;
36137         arg_conv.inner = (void*)(arg & (~1));
36138         arg_conv.is_owned = false;
36139         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36140         int64_t ret_val = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
36141         return ret_val;
36142 }
36143
36144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36145         LDKCounterpartyCommitmentSecrets orig_conv;
36146         orig_conv.inner = (void*)(orig & (~1));
36147         orig_conv.is_owned = false;
36148         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36149         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
36150         int64_t ret_ref = 0;
36151         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36152         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36154         ret_ref = (uintptr_t)ret_var.inner;
36155         if (ret_var.is_owned) {
36156                 ret_ref |= 1;
36157         }
36158         return ret_ref;
36159 }
36160
36161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
36162         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
36163         int64_t ret_ref = 0;
36164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36167         ret_ref = (uintptr_t)ret_var.inner;
36168         if (ret_var.is_owned) {
36169                 ret_ref |= 1;
36170         }
36171         return ret_ref;
36172 }
36173
36174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
36175         LDKCounterpartyCommitmentSecrets this_arg_conv;
36176         this_arg_conv.inner = (void*)(this_arg & (~1));
36177         this_arg_conv.is_owned = false;
36178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36179         int64_t ret_val = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
36180         return ret_val;
36181 }
36182
36183 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) {
36184         LDKCounterpartyCommitmentSecrets this_arg_conv;
36185         this_arg_conv.inner = (void*)(this_arg & (~1));
36186         this_arg_conv.is_owned = false;
36187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36188         LDKThirtyTwoBytes secret_ref;
36189         CHECK((*env)->GetArrayLength(env, secret) == 32);
36190         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
36191         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
36192         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
36193         return (int64_t)ret_conv;
36194 }
36195
36196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
36197         LDKCounterpartyCommitmentSecrets this_arg_conv;
36198         this_arg_conv.inner = (void*)(this_arg & (~1));
36199         this_arg_conv.is_owned = false;
36200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36201         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
36203         return ret_arr;
36204 }
36205
36206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
36207         LDKCounterpartyCommitmentSecrets obj_conv;
36208         obj_conv.inner = (void*)(obj & (~1));
36209         obj_conv.is_owned = false;
36210         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36211         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
36212         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36213         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36214         CVec_u8Z_free(ret_var);
36215         return ret_arr;
36216 }
36217
36218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36219         LDKu8slice ser_ref;
36220         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36221         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36222         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
36223         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
36224         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36225         return (int64_t)ret_conv;
36226 }
36227
36228 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) {
36229         LDKPublicKey per_commitment_point_ref;
36230         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36231         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36232         unsigned char base_secret_arr[32];
36233         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
36234         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
36235         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
36236         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36237         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
36238         return (int64_t)ret_conv;
36239 }
36240
36241 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) {
36242         LDKPublicKey per_commitment_point_ref;
36243         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36244         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36245         LDKPublicKey base_point_ref;
36246         CHECK((*env)->GetArrayLength(env, base_point) == 33);
36247         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
36248         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36249         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
36250         return (int64_t)ret_conv;
36251 }
36252
36253 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) {
36254         unsigned char per_commitment_secret_arr[32];
36255         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
36256         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
36257         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
36258         unsigned char countersignatory_revocation_base_secret_arr[32];
36259         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
36260         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
36261         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
36262         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36263         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
36264         return (int64_t)ret_conv;
36265 }
36266
36267 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) {
36268         LDKPublicKey per_commitment_point_ref;
36269         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36270         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36271         LDKPublicKey countersignatory_revocation_base_point_ref;
36272         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
36273         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
36274         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36275         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
36276         return (int64_t)ret_conv;
36277 }
36278
36279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36280         LDKTxCreationKeys this_obj_conv;
36281         this_obj_conv.inner = (void*)(this_obj & (~1));
36282         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36284         TxCreationKeys_free(this_obj_conv);
36285 }
36286
36287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36288         LDKTxCreationKeys this_ptr_conv;
36289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36290         this_ptr_conv.is_owned = false;
36291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36292         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36293         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
36294         return ret_arr;
36295 }
36296
36297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36298         LDKTxCreationKeys this_ptr_conv;
36299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36300         this_ptr_conv.is_owned = false;
36301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36302         LDKPublicKey val_ref;
36303         CHECK((*env)->GetArrayLength(env, val) == 33);
36304         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36305         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
36306 }
36307
36308 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36309         LDKTxCreationKeys this_ptr_conv;
36310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36311         this_ptr_conv.is_owned = false;
36312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36313         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36314         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
36315         return ret_arr;
36316 }
36317
36318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36319         LDKTxCreationKeys this_ptr_conv;
36320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36321         this_ptr_conv.is_owned = false;
36322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36323         LDKPublicKey val_ref;
36324         CHECK((*env)->GetArrayLength(env, val) == 33);
36325         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36326         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
36327 }
36328
36329 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36330         LDKTxCreationKeys this_ptr_conv;
36331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36332         this_ptr_conv.is_owned = false;
36333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36334         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36335         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
36336         return ret_arr;
36337 }
36338
36339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36340         LDKTxCreationKeys this_ptr_conv;
36341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36342         this_ptr_conv.is_owned = false;
36343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36344         LDKPublicKey val_ref;
36345         CHECK((*env)->GetArrayLength(env, val) == 33);
36346         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36347         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
36348 }
36349
36350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36351         LDKTxCreationKeys this_ptr_conv;
36352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36353         this_ptr_conv.is_owned = false;
36354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36355         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36356         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
36357         return ret_arr;
36358 }
36359
36360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36361         LDKTxCreationKeys this_ptr_conv;
36362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36363         this_ptr_conv.is_owned = false;
36364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36365         LDKPublicKey val_ref;
36366         CHECK((*env)->GetArrayLength(env, val) == 33);
36367         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36368         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
36369 }
36370
36371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36372         LDKTxCreationKeys this_ptr_conv;
36373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36374         this_ptr_conv.is_owned = false;
36375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36376         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36377         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
36378         return ret_arr;
36379 }
36380
36381 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) {
36382         LDKTxCreationKeys this_ptr_conv;
36383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36384         this_ptr_conv.is_owned = false;
36385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36386         LDKPublicKey val_ref;
36387         CHECK((*env)->GetArrayLength(env, val) == 33);
36388         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36389         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
36390 }
36391
36392 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) {
36393         LDKPublicKey per_commitment_point_arg_ref;
36394         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
36395         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
36396         LDKPublicKey revocation_key_arg_ref;
36397         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
36398         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
36399         LDKPublicKey broadcaster_htlc_key_arg_ref;
36400         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
36401         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
36402         LDKPublicKey countersignatory_htlc_key_arg_ref;
36403         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
36404         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
36405         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
36406         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
36407         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
36408         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);
36409         int64_t ret_ref = 0;
36410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36413         ret_ref = (uintptr_t)ret_var.inner;
36414         if (ret_var.is_owned) {
36415                 ret_ref |= 1;
36416         }
36417         return ret_ref;
36418 }
36419
36420 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
36421         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
36422 int64_t ret_ref = 0;
36423 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36424 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36425 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36426 ret_ref = (uintptr_t)ret_var.inner;
36427 if (ret_var.is_owned) {
36428         ret_ref |= 1;
36429 }
36430         return ret_ref;
36431 }
36432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36433         LDKTxCreationKeys arg_conv;
36434         arg_conv.inner = (void*)(arg & (~1));
36435         arg_conv.is_owned = false;
36436         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36437         int64_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
36438         return ret_val;
36439 }
36440
36441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36442         LDKTxCreationKeys orig_conv;
36443         orig_conv.inner = (void*)(orig & (~1));
36444         orig_conv.is_owned = false;
36445         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36446         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
36447         int64_t ret_ref = 0;
36448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36451         ret_ref = (uintptr_t)ret_var.inner;
36452         if (ret_var.is_owned) {
36453                 ret_ref |= 1;
36454         }
36455         return ret_ref;
36456 }
36457
36458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
36459         LDKTxCreationKeys obj_conv;
36460         obj_conv.inner = (void*)(obj & (~1));
36461         obj_conv.is_owned = false;
36462         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36463         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
36464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36466         CVec_u8Z_free(ret_var);
36467         return ret_arr;
36468 }
36469
36470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36471         LDKu8slice ser_ref;
36472         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36473         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36474         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
36475         *ret_conv = TxCreationKeys_read(ser_ref);
36476         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36477         return (int64_t)ret_conv;
36478 }
36479
36480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36481         LDKChannelPublicKeys this_obj_conv;
36482         this_obj_conv.inner = (void*)(this_obj & (~1));
36483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36485         ChannelPublicKeys_free(this_obj_conv);
36486 }
36487
36488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36489         LDKChannelPublicKeys this_ptr_conv;
36490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36491         this_ptr_conv.is_owned = false;
36492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36493         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36494         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
36495         return ret_arr;
36496 }
36497
36498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36499         LDKChannelPublicKeys this_ptr_conv;
36500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36501         this_ptr_conv.is_owned = false;
36502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36503         LDKPublicKey val_ref;
36504         CHECK((*env)->GetArrayLength(env, val) == 33);
36505         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36506         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
36507 }
36508
36509 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
36510         LDKChannelPublicKeys this_ptr_conv;
36511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36512         this_ptr_conv.is_owned = false;
36513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36514         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36515         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
36516         return ret_arr;
36517 }
36518
36519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36520         LDKChannelPublicKeys this_ptr_conv;
36521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36522         this_ptr_conv.is_owned = false;
36523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36524         LDKPublicKey val_ref;
36525         CHECK((*env)->GetArrayLength(env, val) == 33);
36526         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36527         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
36528 }
36529
36530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36531         LDKChannelPublicKeys this_ptr_conv;
36532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36533         this_ptr_conv.is_owned = false;
36534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36535         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
36537         return ret_arr;
36538 }
36539
36540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36541         LDKChannelPublicKeys this_ptr_conv;
36542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36543         this_ptr_conv.is_owned = false;
36544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36545         LDKPublicKey val_ref;
36546         CHECK((*env)->GetArrayLength(env, val) == 33);
36547         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36548         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
36549 }
36550
36551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
36552         LDKChannelPublicKeys this_ptr_conv;
36553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36554         this_ptr_conv.is_owned = false;
36555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36556         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36557         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
36558         return ret_arr;
36559 }
36560
36561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36562         LDKChannelPublicKeys this_ptr_conv;
36563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36564         this_ptr_conv.is_owned = false;
36565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36566         LDKPublicKey val_ref;
36567         CHECK((*env)->GetArrayLength(env, val) == 33);
36568         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36569         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
36570 }
36571
36572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
36573         LDKChannelPublicKeys this_ptr_conv;
36574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36575         this_ptr_conv.is_owned = false;
36576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36577         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36578         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
36579         return ret_arr;
36580 }
36581
36582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36583         LDKChannelPublicKeys this_ptr_conv;
36584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36585         this_ptr_conv.is_owned = false;
36586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36587         LDKPublicKey val_ref;
36588         CHECK((*env)->GetArrayLength(env, val) == 33);
36589         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36590         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
36591 }
36592
36593 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) {
36594         LDKPublicKey funding_pubkey_arg_ref;
36595         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
36596         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
36597         LDKPublicKey revocation_basepoint_arg_ref;
36598         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
36599         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
36600         LDKPublicKey payment_point_arg_ref;
36601         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
36602         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
36603         LDKPublicKey delayed_payment_basepoint_arg_ref;
36604         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
36605         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
36606         LDKPublicKey htlc_basepoint_arg_ref;
36607         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
36608         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
36609         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);
36610         int64_t ret_ref = 0;
36611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36614         ret_ref = (uintptr_t)ret_var.inner;
36615         if (ret_var.is_owned) {
36616                 ret_ref |= 1;
36617         }
36618         return ret_ref;
36619 }
36620
36621 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
36622         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
36623 int64_t ret_ref = 0;
36624 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36625 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36626 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36627 ret_ref = (uintptr_t)ret_var.inner;
36628 if (ret_var.is_owned) {
36629         ret_ref |= 1;
36630 }
36631         return ret_ref;
36632 }
36633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36634         LDKChannelPublicKeys arg_conv;
36635         arg_conv.inner = (void*)(arg & (~1));
36636         arg_conv.is_owned = false;
36637         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36638         int64_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
36639         return ret_val;
36640 }
36641
36642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36643         LDKChannelPublicKeys orig_conv;
36644         orig_conv.inner = (void*)(orig & (~1));
36645         orig_conv.is_owned = false;
36646         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36647         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
36648         int64_t ret_ref = 0;
36649         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36650         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36652         ret_ref = (uintptr_t)ret_var.inner;
36653         if (ret_var.is_owned) {
36654                 ret_ref |= 1;
36655         }
36656         return ret_ref;
36657 }
36658
36659 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
36660         LDKChannelPublicKeys obj_conv;
36661         obj_conv.inner = (void*)(obj & (~1));
36662         obj_conv.is_owned = false;
36663         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36664         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
36665         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36666         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36667         CVec_u8Z_free(ret_var);
36668         return ret_arr;
36669 }
36670
36671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36672         LDKu8slice ser_ref;
36673         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36674         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36675         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
36676         *ret_conv = ChannelPublicKeys_read(ser_ref);
36677         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36678         return (int64_t)ret_conv;
36679 }
36680
36681 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) {
36682         LDKPublicKey per_commitment_point_ref;
36683         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36684         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36685         LDKPublicKey broadcaster_delayed_payment_base_ref;
36686         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
36687         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
36688         LDKPublicKey broadcaster_htlc_base_ref;
36689         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
36690         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
36691         LDKPublicKey countersignatory_revocation_base_ref;
36692         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
36693         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
36694         LDKPublicKey countersignatory_htlc_base_ref;
36695         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
36696         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
36697         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
36698         *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);
36699         return (int64_t)ret_conv;
36700 }
36701
36702 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) {
36703         LDKPublicKey per_commitment_point_ref;
36704         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36705         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36706         LDKChannelPublicKeys broadcaster_keys_conv;
36707         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
36708         broadcaster_keys_conv.is_owned = false;
36709         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
36710         LDKChannelPublicKeys countersignatory_keys_conv;
36711         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
36712         countersignatory_keys_conv.is_owned = false;
36713         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
36714         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
36715         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
36716         return (int64_t)ret_conv;
36717 }
36718
36719 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) {
36720         LDKPublicKey revocation_key_ref;
36721         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
36722         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
36723         LDKPublicKey broadcaster_delayed_payment_key_ref;
36724         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
36725         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
36726         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
36727         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36728         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36729         CVec_u8Z_free(ret_var);
36730         return ret_arr;
36731 }
36732
36733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36734         LDKHTLCOutputInCommitment this_obj_conv;
36735         this_obj_conv.inner = (void*)(this_obj & (~1));
36736         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36738         HTLCOutputInCommitment_free(this_obj_conv);
36739 }
36740
36741 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
36742         LDKHTLCOutputInCommitment this_ptr_conv;
36743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36744         this_ptr_conv.is_owned = false;
36745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36746         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
36747         return ret_val;
36748 }
36749
36750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36751         LDKHTLCOutputInCommitment this_ptr_conv;
36752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36753         this_ptr_conv.is_owned = false;
36754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36755         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
36756 }
36757
36758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36759         LDKHTLCOutputInCommitment this_ptr_conv;
36760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36761         this_ptr_conv.is_owned = false;
36762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36763         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
36764         return ret_val;
36765 }
36766
36767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36768         LDKHTLCOutputInCommitment this_ptr_conv;
36769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36770         this_ptr_conv.is_owned = false;
36771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36772         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
36773 }
36774
36775 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
36776         LDKHTLCOutputInCommitment this_ptr_conv;
36777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36778         this_ptr_conv.is_owned = false;
36779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36780         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
36781         return ret_val;
36782 }
36783
36784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36785         LDKHTLCOutputInCommitment this_ptr_conv;
36786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36787         this_ptr_conv.is_owned = false;
36788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36789         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
36790 }
36791
36792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36793         LDKHTLCOutputInCommitment this_ptr_conv;
36794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36795         this_ptr_conv.is_owned = false;
36796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36797         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36798         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
36799         return ret_arr;
36800 }
36801
36802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36803         LDKHTLCOutputInCommitment this_ptr_conv;
36804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36805         this_ptr_conv.is_owned = false;
36806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36807         LDKThirtyTwoBytes val_ref;
36808         CHECK((*env)->GetArrayLength(env, val) == 32);
36809         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36810         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
36811 }
36812
36813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
36814         LDKHTLCOutputInCommitment this_ptr_conv;
36815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36816         this_ptr_conv.is_owned = false;
36817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36818         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
36819         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
36820         int64_t ret_ref = (uintptr_t)ret_copy;
36821         return ret_ref;
36822 }
36823
36824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36825         LDKHTLCOutputInCommitment this_ptr_conv;
36826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36827         this_ptr_conv.is_owned = false;
36828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36829         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36830         CHECK_ACCESS(val_ptr);
36831         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
36832         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
36833         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
36834 }
36835
36836 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) {
36837         LDKThirtyTwoBytes payment_hash_arg_ref;
36838         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
36839         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
36840         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
36841         CHECK_ACCESS(transaction_output_index_arg_ptr);
36842         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
36843         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
36844         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
36845         int64_t ret_ref = 0;
36846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36849         ret_ref = (uintptr_t)ret_var.inner;
36850         if (ret_var.is_owned) {
36851                 ret_ref |= 1;
36852         }
36853         return ret_ref;
36854 }
36855
36856 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
36857         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
36858 int64_t ret_ref = 0;
36859 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36860 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36861 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36862 ret_ref = (uintptr_t)ret_var.inner;
36863 if (ret_var.is_owned) {
36864         ret_ref |= 1;
36865 }
36866         return ret_ref;
36867 }
36868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36869         LDKHTLCOutputInCommitment arg_conv;
36870         arg_conv.inner = (void*)(arg & (~1));
36871         arg_conv.is_owned = false;
36872         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36873         int64_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
36874         return ret_val;
36875 }
36876
36877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36878         LDKHTLCOutputInCommitment orig_conv;
36879         orig_conv.inner = (void*)(orig & (~1));
36880         orig_conv.is_owned = false;
36881         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36882         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
36883         int64_t ret_ref = 0;
36884         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36885         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36887         ret_ref = (uintptr_t)ret_var.inner;
36888         if (ret_var.is_owned) {
36889                 ret_ref |= 1;
36890         }
36891         return ret_ref;
36892 }
36893
36894 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
36895         LDKHTLCOutputInCommitment obj_conv;
36896         obj_conv.inner = (void*)(obj & (~1));
36897         obj_conv.is_owned = false;
36898         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36899         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
36900         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36901         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36902         CVec_u8Z_free(ret_var);
36903         return ret_arr;
36904 }
36905
36906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36907         LDKu8slice ser_ref;
36908         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36909         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36910         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
36911         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
36912         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36913         return (int64_t)ret_conv;
36914 }
36915
36916 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) {
36917         LDKHTLCOutputInCommitment htlc_conv;
36918         htlc_conv.inner = (void*)(htlc & (~1));
36919         htlc_conv.is_owned = false;
36920         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
36921         LDKTxCreationKeys keys_conv;
36922         keys_conv.inner = (void*)(keys & (~1));
36923         keys_conv.is_owned = false;
36924         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
36925         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
36926         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36927         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36928         CVec_u8Z_free(ret_var);
36929         return ret_arr;
36930 }
36931
36932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
36933         LDKPublicKey broadcaster_ref;
36934         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
36935         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
36936         LDKPublicKey countersignatory_ref;
36937         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
36938         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
36939         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
36940         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36941         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36942         CVec_u8Z_free(ret_var);
36943         return ret_arr;
36944 }
36945
36946 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) {
36947         unsigned char commitment_txid_arr[32];
36948         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
36949         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
36950         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
36951         LDKHTLCOutputInCommitment htlc_conv;
36952         htlc_conv.inner = (void*)(htlc & (~1));
36953         htlc_conv.is_owned = false;
36954         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
36955         LDKPublicKey broadcaster_delayed_payment_key_ref;
36956         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
36957         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
36958         LDKPublicKey revocation_key_ref;
36959         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
36960         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
36961         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);
36962         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36963         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36964         Transaction_free(ret_var);
36965         return ret_arr;
36966 }
36967
36968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
36969         LDKPublicKey funding_pubkey_ref;
36970         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
36971         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
36972         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
36973         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36974         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36975         CVec_u8Z_free(ret_var);
36976         return ret_arr;
36977 }
36978
36979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36980         LDKChannelTransactionParameters this_obj_conv;
36981         this_obj_conv.inner = (void*)(this_obj & (~1));
36982         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36984         ChannelTransactionParameters_free(this_obj_conv);
36985 }
36986
36987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
36988         LDKChannelTransactionParameters this_ptr_conv;
36989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36990         this_ptr_conv.is_owned = false;
36991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36992         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
36993         int64_t ret_ref = 0;
36994         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36995         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36997         ret_ref = (uintptr_t)ret_var.inner;
36998         if (ret_var.is_owned) {
36999                 ret_ref |= 1;
37000         }
37001         return ret_ref;
37002 }
37003
37004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37005         LDKChannelTransactionParameters this_ptr_conv;
37006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37007         this_ptr_conv.is_owned = false;
37008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37009         LDKChannelPublicKeys val_conv;
37010         val_conv.inner = (void*)(val & (~1));
37011         val_conv.is_owned = (val & 1) || (val == 0);
37012         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37013         val_conv = ChannelPublicKeys_clone(&val_conv);
37014         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
37015 }
37016
37017 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
37018         LDKChannelTransactionParameters this_ptr_conv;
37019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37020         this_ptr_conv.is_owned = false;
37021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37022         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
37023         return ret_val;
37024 }
37025
37026 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) {
37027         LDKChannelTransactionParameters this_ptr_conv;
37028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37029         this_ptr_conv.is_owned = false;
37030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37031         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
37032 }
37033
37034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
37035         LDKChannelTransactionParameters this_ptr_conv;
37036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37037         this_ptr_conv.is_owned = false;
37038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37039         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
37040         return ret_val;
37041 }
37042
37043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37044         LDKChannelTransactionParameters this_ptr_conv;
37045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37046         this_ptr_conv.is_owned = false;
37047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37048         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
37049 }
37050
37051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
37052         LDKChannelTransactionParameters this_ptr_conv;
37053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37054         this_ptr_conv.is_owned = false;
37055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37056         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
37057         int64_t ret_ref = 0;
37058         if ((uintptr_t)ret_var.inner > 4096) {
37059                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37060                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37062                 ret_ref = (uintptr_t)ret_var.inner;
37063                 if (ret_var.is_owned) {
37064                         ret_ref |= 1;
37065                 }
37066         }
37067         return ret_ref;
37068 }
37069
37070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37071         LDKChannelTransactionParameters this_ptr_conv;
37072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37073         this_ptr_conv.is_owned = false;
37074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37075         LDKCounterpartyChannelTransactionParameters val_conv;
37076         val_conv.inner = (void*)(val & (~1));
37077         val_conv.is_owned = (val & 1) || (val == 0);
37078         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37079         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
37080         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
37081 }
37082
37083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37084         LDKChannelTransactionParameters this_ptr_conv;
37085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37086         this_ptr_conv.is_owned = false;
37087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37088         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
37089         int64_t ret_ref = 0;
37090         if ((uintptr_t)ret_var.inner > 4096) {
37091                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37092                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37094                 ret_ref = (uintptr_t)ret_var.inner;
37095                 if (ret_var.is_owned) {
37096                         ret_ref |= 1;
37097                 }
37098         }
37099         return ret_ref;
37100 }
37101
37102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37103         LDKChannelTransactionParameters this_ptr_conv;
37104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37105         this_ptr_conv.is_owned = false;
37106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37107         LDKOutPoint val_conv;
37108         val_conv.inner = (void*)(val & (~1));
37109         val_conv.is_owned = (val & 1) || (val == 0);
37110         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37111         val_conv = OutPoint_clone(&val_conv);
37112         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
37113 }
37114
37115 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
37116         LDKChannelTransactionParameters this_ptr_conv;
37117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37118         this_ptr_conv.is_owned = false;
37119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37120         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
37121         return ret_conv;
37122 }
37123
37124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
37125         LDKChannelTransactionParameters this_ptr_conv;
37126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37127         this_ptr_conv.is_owned = false;
37128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37129         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
37130         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
37131 }
37132
37133 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) {
37134         LDKChannelPublicKeys holder_pubkeys_arg_conv;
37135         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
37136         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
37137         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
37138         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
37139         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
37140         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
37141         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
37142         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
37143         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
37144         LDKOutPoint funding_outpoint_arg_conv;
37145         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
37146         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
37147         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
37148         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
37149         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
37150         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);
37151         int64_t ret_ref = 0;
37152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37155         ret_ref = (uintptr_t)ret_var.inner;
37156         if (ret_var.is_owned) {
37157                 ret_ref |= 1;
37158         }
37159         return ret_ref;
37160 }
37161
37162 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
37163         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
37164 int64_t ret_ref = 0;
37165 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37166 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37167 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37168 ret_ref = (uintptr_t)ret_var.inner;
37169 if (ret_var.is_owned) {
37170         ret_ref |= 1;
37171 }
37172         return ret_ref;
37173 }
37174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37175         LDKChannelTransactionParameters arg_conv;
37176         arg_conv.inner = (void*)(arg & (~1));
37177         arg_conv.is_owned = false;
37178         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37179         int64_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
37180         return ret_val;
37181 }
37182
37183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37184         LDKChannelTransactionParameters orig_conv;
37185         orig_conv.inner = (void*)(orig & (~1));
37186         orig_conv.is_owned = false;
37187         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37188         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
37189         int64_t ret_ref = 0;
37190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37193         ret_ref = (uintptr_t)ret_var.inner;
37194         if (ret_var.is_owned) {
37195                 ret_ref |= 1;
37196         }
37197         return ret_ref;
37198 }
37199
37200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37201         LDKCounterpartyChannelTransactionParameters this_obj_conv;
37202         this_obj_conv.inner = (void*)(this_obj & (~1));
37203         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37205         CounterpartyChannelTransactionParameters_free(this_obj_conv);
37206 }
37207
37208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
37209         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37211         this_ptr_conv.is_owned = false;
37212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37213         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
37214         int64_t ret_ref = 0;
37215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37218         ret_ref = (uintptr_t)ret_var.inner;
37219         if (ret_var.is_owned) {
37220                 ret_ref |= 1;
37221         }
37222         return ret_ref;
37223 }
37224
37225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37226         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37228         this_ptr_conv.is_owned = false;
37229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37230         LDKChannelPublicKeys val_conv;
37231         val_conv.inner = (void*)(val & (~1));
37232         val_conv.is_owned = (val & 1) || (val == 0);
37233         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37234         val_conv = ChannelPublicKeys_clone(&val_conv);
37235         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
37236 }
37237
37238 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
37239         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37241         this_ptr_conv.is_owned = false;
37242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37243         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
37244         return ret_val;
37245 }
37246
37247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37248         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37250         this_ptr_conv.is_owned = false;
37251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37252         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
37253 }
37254
37255 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) {
37256         LDKChannelPublicKeys pubkeys_arg_conv;
37257         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
37258         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
37259         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
37260         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
37261         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
37262         int64_t ret_ref = 0;
37263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37266         ret_ref = (uintptr_t)ret_var.inner;
37267         if (ret_var.is_owned) {
37268                 ret_ref |= 1;
37269         }
37270         return ret_ref;
37271 }
37272
37273 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
37274         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
37275 int64_t ret_ref = 0;
37276 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37277 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37278 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37279 ret_ref = (uintptr_t)ret_var.inner;
37280 if (ret_var.is_owned) {
37281         ret_ref |= 1;
37282 }
37283         return ret_ref;
37284 }
37285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37286         LDKCounterpartyChannelTransactionParameters arg_conv;
37287         arg_conv.inner = (void*)(arg & (~1));
37288         arg_conv.is_owned = false;
37289         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37290         int64_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
37291         return ret_val;
37292 }
37293
37294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37295         LDKCounterpartyChannelTransactionParameters orig_conv;
37296         orig_conv.inner = (void*)(orig & (~1));
37297         orig_conv.is_owned = false;
37298         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37299         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
37300         int64_t ret_ref = 0;
37301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37304         ret_ref = (uintptr_t)ret_var.inner;
37305         if (ret_var.is_owned) {
37306                 ret_ref |= 1;
37307         }
37308         return ret_ref;
37309 }
37310
37311 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
37312         LDKChannelTransactionParameters this_arg_conv;
37313         this_arg_conv.inner = (void*)(this_arg & (~1));
37314         this_arg_conv.is_owned = false;
37315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37316         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
37317         return ret_val;
37318 }
37319
37320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37321         LDKChannelTransactionParameters this_arg_conv;
37322         this_arg_conv.inner = (void*)(this_arg & (~1));
37323         this_arg_conv.is_owned = false;
37324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37325         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
37326         int64_t ret_ref = 0;
37327         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37328         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37330         ret_ref = (uintptr_t)ret_var.inner;
37331         if (ret_var.is_owned) {
37332                 ret_ref |= 1;
37333         }
37334         return ret_ref;
37335 }
37336
37337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37338         LDKChannelTransactionParameters this_arg_conv;
37339         this_arg_conv.inner = (void*)(this_arg & (~1));
37340         this_arg_conv.is_owned = false;
37341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37342         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
37343         int64_t ret_ref = 0;
37344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37347         ret_ref = (uintptr_t)ret_var.inner;
37348         if (ret_var.is_owned) {
37349                 ret_ref |= 1;
37350         }
37351         return ret_ref;
37352 }
37353
37354 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37355         LDKCounterpartyChannelTransactionParameters obj_conv;
37356         obj_conv.inner = (void*)(obj & (~1));
37357         obj_conv.is_owned = false;
37358         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37359         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
37360         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37361         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37362         CVec_u8Z_free(ret_var);
37363         return ret_arr;
37364 }
37365
37366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37367         LDKu8slice ser_ref;
37368         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37369         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37370         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
37371         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
37372         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37373         return (int64_t)ret_conv;
37374 }
37375
37376 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37377         LDKChannelTransactionParameters obj_conv;
37378         obj_conv.inner = (void*)(obj & (~1));
37379         obj_conv.is_owned = false;
37380         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37381         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
37382         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37383         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37384         CVec_u8Z_free(ret_var);
37385         return ret_arr;
37386 }
37387
37388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37389         LDKu8slice ser_ref;
37390         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37391         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37392         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
37393         *ret_conv = ChannelTransactionParameters_read(ser_ref);
37394         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37395         return (int64_t)ret_conv;
37396 }
37397
37398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37399         LDKDirectedChannelTransactionParameters this_obj_conv;
37400         this_obj_conv.inner = (void*)(this_obj & (~1));
37401         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37403         DirectedChannelTransactionParameters_free(this_obj_conv);
37404 }
37405
37406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37407         LDKDirectedChannelTransactionParameters this_arg_conv;
37408         this_arg_conv.inner = (void*)(this_arg & (~1));
37409         this_arg_conv.is_owned = false;
37410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37411         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
37412         int64_t ret_ref = 0;
37413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37416         ret_ref = (uintptr_t)ret_var.inner;
37417         if (ret_var.is_owned) {
37418                 ret_ref |= 1;
37419         }
37420         return ret_ref;
37421 }
37422
37423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37424         LDKDirectedChannelTransactionParameters this_arg_conv;
37425         this_arg_conv.inner = (void*)(this_arg & (~1));
37426         this_arg_conv.is_owned = false;
37427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37428         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
37429         int64_t ret_ref = 0;
37430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37433         ret_ref = (uintptr_t)ret_var.inner;
37434         if (ret_var.is_owned) {
37435                 ret_ref |= 1;
37436         }
37437         return ret_ref;
37438 }
37439
37440 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
37441         LDKDirectedChannelTransactionParameters this_arg_conv;
37442         this_arg_conv.inner = (void*)(this_arg & (~1));
37443         this_arg_conv.is_owned = false;
37444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37445         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
37446         return ret_val;
37447 }
37448
37449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
37450         LDKDirectedChannelTransactionParameters this_arg_conv;
37451         this_arg_conv.inner = (void*)(this_arg & (~1));
37452         this_arg_conv.is_owned = false;
37453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37454         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
37455         return ret_val;
37456 }
37457
37458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
37459         LDKDirectedChannelTransactionParameters this_arg_conv;
37460         this_arg_conv.inner = (void*)(this_arg & (~1));
37461         this_arg_conv.is_owned = false;
37462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37463         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
37464         int64_t ret_ref = 0;
37465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37468         ret_ref = (uintptr_t)ret_var.inner;
37469         if (ret_var.is_owned) {
37470                 ret_ref |= 1;
37471         }
37472         return ret_ref;
37473 }
37474
37475 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
37476         LDKDirectedChannelTransactionParameters this_arg_conv;
37477         this_arg_conv.inner = (void*)(this_arg & (~1));
37478         this_arg_conv.is_owned = false;
37479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37480         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
37481         return ret_val;
37482 }
37483
37484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37485         LDKHolderCommitmentTransaction this_obj_conv;
37486         this_obj_conv.inner = (void*)(this_obj & (~1));
37487         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37489         HolderCommitmentTransaction_free(this_obj_conv);
37490 }
37491
37492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
37493         LDKHolderCommitmentTransaction this_ptr_conv;
37494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37495         this_ptr_conv.is_owned = false;
37496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37497         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
37499         return ret_arr;
37500 }
37501
37502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37503         LDKHolderCommitmentTransaction this_ptr_conv;
37504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37505         this_ptr_conv.is_owned = false;
37506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37507         LDKSignature val_ref;
37508         CHECK((*env)->GetArrayLength(env, val) == 64);
37509         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37510         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
37511 }
37512
37513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
37514         LDKHolderCommitmentTransaction this_ptr_conv;
37515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37516         this_ptr_conv.is_owned = false;
37517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37518         LDKCVec_SignatureZ val_constr;
37519         val_constr.datalen = (*env)->GetArrayLength(env, val);
37520         if (val_constr.datalen > 0)
37521                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37522         else
37523                 val_constr.data = NULL;
37524         for (size_t i = 0; i < val_constr.datalen; i++) {
37525                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
37526                 LDKSignature val_conv_8_ref;
37527                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
37528                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
37529                 val_constr.data[i] = val_conv_8_ref;
37530         }
37531         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
37532 }
37533
37534 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
37535         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
37536 int64_t ret_ref = 0;
37537 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37538 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37539 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37540 ret_ref = (uintptr_t)ret_var.inner;
37541 if (ret_var.is_owned) {
37542         ret_ref |= 1;
37543 }
37544         return ret_ref;
37545 }
37546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37547         LDKHolderCommitmentTransaction arg_conv;
37548         arg_conv.inner = (void*)(arg & (~1));
37549         arg_conv.is_owned = false;
37550         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37551         int64_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
37552         return ret_val;
37553 }
37554
37555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37556         LDKHolderCommitmentTransaction orig_conv;
37557         orig_conv.inner = (void*)(orig & (~1));
37558         orig_conv.is_owned = false;
37559         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37560         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
37561         int64_t ret_ref = 0;
37562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37565         ret_ref = (uintptr_t)ret_var.inner;
37566         if (ret_var.is_owned) {
37567                 ret_ref |= 1;
37568         }
37569         return ret_ref;
37570 }
37571
37572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
37573         LDKHolderCommitmentTransaction obj_conv;
37574         obj_conv.inner = (void*)(obj & (~1));
37575         obj_conv.is_owned = false;
37576         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37577         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
37578         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37579         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37580         CVec_u8Z_free(ret_var);
37581         return ret_arr;
37582 }
37583
37584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37585         LDKu8slice ser_ref;
37586         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37587         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37588         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
37589         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
37590         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37591         return (int64_t)ret_conv;
37592 }
37593
37594 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) {
37595         LDKCommitmentTransaction commitment_tx_conv;
37596         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
37597         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
37598         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
37599         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
37600         LDKSignature counterparty_sig_ref;
37601         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
37602         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
37603         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
37604         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
37605         if (counterparty_htlc_sigs_constr.datalen > 0)
37606                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37607         else
37608                 counterparty_htlc_sigs_constr.data = NULL;
37609         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
37610                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
37611                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
37612                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
37613                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
37614                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
37615         }
37616         LDKPublicKey holder_funding_key_ref;
37617         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
37618         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
37619         LDKPublicKey counterparty_funding_key_ref;
37620         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
37621         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
37622         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
37623         int64_t ret_ref = 0;
37624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37627         ret_ref = (uintptr_t)ret_var.inner;
37628         if (ret_var.is_owned) {
37629                 ret_ref |= 1;
37630         }
37631         return ret_ref;
37632 }
37633
37634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37635         LDKBuiltCommitmentTransaction this_obj_conv;
37636         this_obj_conv.inner = (void*)(this_obj & (~1));
37637         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37639         BuiltCommitmentTransaction_free(this_obj_conv);
37640 }
37641
37642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
37643         LDKBuiltCommitmentTransaction this_ptr_conv;
37644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37645         this_ptr_conv.is_owned = false;
37646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37647         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
37648         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37649         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37650         Transaction_free(ret_var);
37651         return ret_arr;
37652 }
37653
37654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37655         LDKBuiltCommitmentTransaction this_ptr_conv;
37656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37657         this_ptr_conv.is_owned = false;
37658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37659         LDKTransaction val_ref;
37660         val_ref.datalen = (*env)->GetArrayLength(env, val);
37661         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
37662         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
37663         val_ref.data_is_owned = true;
37664         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
37665 }
37666
37667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
37668         LDKBuiltCommitmentTransaction this_ptr_conv;
37669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37670         this_ptr_conv.is_owned = false;
37671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37672         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37673         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
37674         return ret_arr;
37675 }
37676
37677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37678         LDKBuiltCommitmentTransaction this_ptr_conv;
37679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37680         this_ptr_conv.is_owned = false;
37681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37682         LDKThirtyTwoBytes val_ref;
37683         CHECK((*env)->GetArrayLength(env, val) == 32);
37684         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37685         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
37686 }
37687
37688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
37689         LDKTransaction transaction_arg_ref;
37690         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
37691         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
37692         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
37693         transaction_arg_ref.data_is_owned = true;
37694         LDKThirtyTwoBytes txid_arg_ref;
37695         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
37696         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
37697         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
37698         int64_t ret_ref = 0;
37699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37702         ret_ref = (uintptr_t)ret_var.inner;
37703         if (ret_var.is_owned) {
37704                 ret_ref |= 1;
37705         }
37706         return ret_ref;
37707 }
37708
37709 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
37710         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
37711 int64_t ret_ref = 0;
37712 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37713 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37714 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37715 ret_ref = (uintptr_t)ret_var.inner;
37716 if (ret_var.is_owned) {
37717         ret_ref |= 1;
37718 }
37719         return ret_ref;
37720 }
37721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37722         LDKBuiltCommitmentTransaction arg_conv;
37723         arg_conv.inner = (void*)(arg & (~1));
37724         arg_conv.is_owned = false;
37725         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37726         int64_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
37727         return ret_val;
37728 }
37729
37730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37731         LDKBuiltCommitmentTransaction orig_conv;
37732         orig_conv.inner = (void*)(orig & (~1));
37733         orig_conv.is_owned = false;
37734         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37735         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
37736         int64_t ret_ref = 0;
37737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37740         ret_ref = (uintptr_t)ret_var.inner;
37741         if (ret_var.is_owned) {
37742                 ret_ref |= 1;
37743         }
37744         return ret_ref;
37745 }
37746
37747 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
37748         LDKBuiltCommitmentTransaction obj_conv;
37749         obj_conv.inner = (void*)(obj & (~1));
37750         obj_conv.is_owned = false;
37751         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37752         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
37753         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37754         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37755         CVec_u8Z_free(ret_var);
37756         return ret_arr;
37757 }
37758
37759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37760         LDKu8slice ser_ref;
37761         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37762         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37763         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
37764         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
37765         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37766         return (int64_t)ret_conv;
37767 }
37768
37769 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) {
37770         LDKBuiltCommitmentTransaction this_arg_conv;
37771         this_arg_conv.inner = (void*)(this_arg & (~1));
37772         this_arg_conv.is_owned = false;
37773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37774         LDKu8slice funding_redeemscript_ref;
37775         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
37776         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
37777         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
37779         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
37780         return ret_arr;
37781 }
37782
37783 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) {
37784         LDKBuiltCommitmentTransaction this_arg_conv;
37785         this_arg_conv.inner = (void*)(this_arg & (~1));
37786         this_arg_conv.is_owned = false;
37787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37788         unsigned char funding_key_arr[32];
37789         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
37790         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
37791         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
37792         LDKu8slice funding_redeemscript_ref;
37793         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
37794         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
37795         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37796         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
37797         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
37798         return ret_arr;
37799 }
37800
37801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37802         LDKClosingTransaction this_obj_conv;
37803         this_obj_conv.inner = (void*)(this_obj & (~1));
37804         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37806         ClosingTransaction_free(this_obj_conv);
37807 }
37808
37809 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
37810         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
37811 int64_t ret_ref = 0;
37812 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37813 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37814 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37815 ret_ref = (uintptr_t)ret_var.inner;
37816 if (ret_var.is_owned) {
37817         ret_ref |= 1;
37818 }
37819         return ret_ref;
37820 }
37821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37822         LDKClosingTransaction arg_conv;
37823         arg_conv.inner = (void*)(arg & (~1));
37824         arg_conv.is_owned = false;
37825         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37826         int64_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
37827         return ret_val;
37828 }
37829
37830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37831         LDKClosingTransaction orig_conv;
37832         orig_conv.inner = (void*)(orig & (~1));
37833         orig_conv.is_owned = false;
37834         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37835         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
37836         int64_t ret_ref = 0;
37837         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37838         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37840         ret_ref = (uintptr_t)ret_var.inner;
37841         if (ret_var.is_owned) {
37842                 ret_ref |= 1;
37843         }
37844         return ret_ref;
37845 }
37846
37847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
37848         LDKClosingTransaction o_conv;
37849         o_conv.inner = (void*)(o & (~1));
37850         o_conv.is_owned = false;
37851         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37852         int64_t ret_val = ClosingTransaction_hash(&o_conv);
37853         return ret_val;
37854 }
37855
37856 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) {
37857         LDKCVec_u8Z to_holder_script_ref;
37858         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
37859         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
37860         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
37861         LDKCVec_u8Z to_counterparty_script_ref;
37862         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
37863         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
37864         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
37865         LDKOutPoint funding_outpoint_conv;
37866         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
37867         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
37868         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
37869         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
37870         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
37871         int64_t ret_ref = 0;
37872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37875         ret_ref = (uintptr_t)ret_var.inner;
37876         if (ret_var.is_owned) {
37877                 ret_ref |= 1;
37878         }
37879         return ret_ref;
37880 }
37881
37882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
37883         LDKClosingTransaction this_arg_conv;
37884         this_arg_conv.inner = (void*)(this_arg & (~1));
37885         this_arg_conv.is_owned = false;
37886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37887         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
37888         int64_t ret_ref = 0;
37889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37892         ret_ref = (uintptr_t)ret_var.inner;
37893         if (ret_var.is_owned) {
37894                 ret_ref |= 1;
37895         }
37896         return ret_ref;
37897 }
37898
37899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
37900         LDKClosingTransaction this_arg_conv;
37901         this_arg_conv.inner = (void*)(this_arg & (~1));
37902         this_arg_conv.is_owned = false;
37903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37904         LDKOutPoint funding_outpoint_conv;
37905         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
37906         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
37907         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
37908         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
37909         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
37910         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
37911         return (int64_t)ret_conv;
37912 }
37913
37914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
37915         LDKClosingTransaction this_arg_conv;
37916         this_arg_conv.inner = (void*)(this_arg & (~1));
37917         this_arg_conv.is_owned = false;
37918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37919         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
37920         return ret_val;
37921 }
37922
37923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
37924         LDKClosingTransaction this_arg_conv;
37925         this_arg_conv.inner = (void*)(this_arg & (~1));
37926         this_arg_conv.is_owned = false;
37927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37928         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
37929         return ret_val;
37930 }
37931
37932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
37933         LDKClosingTransaction this_arg_conv;
37934         this_arg_conv.inner = (void*)(this_arg & (~1));
37935         this_arg_conv.is_owned = false;
37936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37937         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
37938         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37939         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37940         return ret_arr;
37941 }
37942
37943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
37944         LDKClosingTransaction this_arg_conv;
37945         this_arg_conv.inner = (void*)(this_arg & (~1));
37946         this_arg_conv.is_owned = false;
37947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37948         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
37949         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37950         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37951         return ret_arr;
37952 }
37953
37954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37955         LDKTrustedClosingTransaction this_obj_conv;
37956         this_obj_conv.inner = (void*)(this_obj & (~1));
37957         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37959         TrustedClosingTransaction_free(this_obj_conv);
37960 }
37961
37962 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
37963         LDKTrustedClosingTransaction this_arg_conv;
37964         this_arg_conv.inner = (void*)(this_arg & (~1));
37965         this_arg_conv.is_owned = false;
37966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37967         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
37968         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37969         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37970         Transaction_free(ret_var);
37971         return ret_arr;
37972 }
37973
37974 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) {
37975         LDKTrustedClosingTransaction this_arg_conv;
37976         this_arg_conv.inner = (void*)(this_arg & (~1));
37977         this_arg_conv.is_owned = false;
37978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37979         LDKu8slice funding_redeemscript_ref;
37980         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
37981         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
37982         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37983         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
37984         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
37985         return ret_arr;
37986 }
37987
37988 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) {
37989         LDKTrustedClosingTransaction this_arg_conv;
37990         this_arg_conv.inner = (void*)(this_arg & (~1));
37991         this_arg_conv.is_owned = false;
37992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37993         unsigned char funding_key_arr[32];
37994         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
37995         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
37996         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
37997         LDKu8slice funding_redeemscript_ref;
37998         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
37999         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38000         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38001         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
38002         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38003         return ret_arr;
38004 }
38005
38006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38007         LDKCommitmentTransaction this_obj_conv;
38008         this_obj_conv.inner = (void*)(this_obj & (~1));
38009         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38011         CommitmentTransaction_free(this_obj_conv);
38012 }
38013
38014 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
38015         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
38016 int64_t ret_ref = 0;
38017 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38018 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38019 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38020 ret_ref = (uintptr_t)ret_var.inner;
38021 if (ret_var.is_owned) {
38022         ret_ref |= 1;
38023 }
38024         return ret_ref;
38025 }
38026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38027         LDKCommitmentTransaction arg_conv;
38028         arg_conv.inner = (void*)(arg & (~1));
38029         arg_conv.is_owned = false;
38030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38031         int64_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
38032         return ret_val;
38033 }
38034
38035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38036         LDKCommitmentTransaction orig_conv;
38037         orig_conv.inner = (void*)(orig & (~1));
38038         orig_conv.is_owned = false;
38039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38040         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
38041         int64_t ret_ref = 0;
38042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38045         ret_ref = (uintptr_t)ret_var.inner;
38046         if (ret_var.is_owned) {
38047                 ret_ref |= 1;
38048         }
38049         return ret_ref;
38050 }
38051
38052 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38053         LDKCommitmentTransaction obj_conv;
38054         obj_conv.inner = (void*)(obj & (~1));
38055         obj_conv.is_owned = false;
38056         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38057         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
38058         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38059         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38060         CVec_u8Z_free(ret_var);
38061         return ret_arr;
38062 }
38063
38064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38065         LDKu8slice ser_ref;
38066         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38067         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38068         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
38069         *ret_conv = CommitmentTransaction_read(ser_ref);
38070         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38071         return (int64_t)ret_conv;
38072 }
38073
38074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
38075         LDKCommitmentTransaction this_arg_conv;
38076         this_arg_conv.inner = (void*)(this_arg & (~1));
38077         this_arg_conv.is_owned = false;
38078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38079         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
38080         return ret_val;
38081 }
38082
38083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38084         LDKCommitmentTransaction this_arg_conv;
38085         this_arg_conv.inner = (void*)(this_arg & (~1));
38086         this_arg_conv.is_owned = false;
38087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38088         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
38089         return ret_val;
38090 }
38091
38092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38093         LDKCommitmentTransaction this_arg_conv;
38094         this_arg_conv.inner = (void*)(this_arg & (~1));
38095         this_arg_conv.is_owned = false;
38096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38097         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
38098         return ret_val;
38099 }
38100
38101 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
38102         LDKCommitmentTransaction this_arg_conv;
38103         this_arg_conv.inner = (void*)(this_arg & (~1));
38104         this_arg_conv.is_owned = false;
38105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38106         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
38107         return ret_val;
38108 }
38109
38110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
38111         LDKCommitmentTransaction this_arg_conv;
38112         this_arg_conv.inner = (void*)(this_arg & (~1));
38113         this_arg_conv.is_owned = false;
38114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38115         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
38116         int64_t ret_ref = 0;
38117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38120         ret_ref = (uintptr_t)ret_var.inner;
38121         if (ret_var.is_owned) {
38122                 ret_ref |= 1;
38123         }
38124         return ret_ref;
38125 }
38126
38127 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) {
38128         LDKCommitmentTransaction this_arg_conv;
38129         this_arg_conv.inner = (void*)(this_arg & (~1));
38130         this_arg_conv.is_owned = false;
38131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38132         LDKDirectedChannelTransactionParameters channel_parameters_conv;
38133         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
38134         channel_parameters_conv.is_owned = false;
38135         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
38136         LDKChannelPublicKeys broadcaster_keys_conv;
38137         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
38138         broadcaster_keys_conv.is_owned = false;
38139         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
38140         LDKChannelPublicKeys countersignatory_keys_conv;
38141         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
38142         countersignatory_keys_conv.is_owned = false;
38143         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
38144         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
38145         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
38146         return (int64_t)ret_conv;
38147 }
38148
38149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38150         LDKTrustedCommitmentTransaction this_obj_conv;
38151         this_obj_conv.inner = (void*)(this_obj & (~1));
38152         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38154         TrustedCommitmentTransaction_free(this_obj_conv);
38155 }
38156
38157 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
38158         LDKTrustedCommitmentTransaction this_arg_conv;
38159         this_arg_conv.inner = (void*)(this_arg & (~1));
38160         this_arg_conv.is_owned = false;
38161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38162         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38163         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
38164         return ret_arr;
38165 }
38166
38167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
38168         LDKTrustedCommitmentTransaction this_arg_conv;
38169         this_arg_conv.inner = (void*)(this_arg & (~1));
38170         this_arg_conv.is_owned = false;
38171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38172         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
38173         int64_t ret_ref = 0;
38174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38177         ret_ref = (uintptr_t)ret_var.inner;
38178         if (ret_var.is_owned) {
38179                 ret_ref |= 1;
38180         }
38181         return ret_ref;
38182 }
38183
38184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
38185         LDKTrustedCommitmentTransaction this_arg_conv;
38186         this_arg_conv.inner = (void*)(this_arg & (~1));
38187         this_arg_conv.is_owned = false;
38188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38189         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
38190         int64_t ret_ref = 0;
38191         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38192         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38194         ret_ref = (uintptr_t)ret_var.inner;
38195         if (ret_var.is_owned) {
38196                 ret_ref |= 1;
38197         }
38198         return ret_ref;
38199 }
38200
38201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
38202         LDKTrustedCommitmentTransaction this_arg_conv;
38203         this_arg_conv.inner = (void*)(this_arg & (~1));
38204         this_arg_conv.is_owned = false;
38205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38206         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
38207         return ret_val;
38208 }
38209
38210 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) {
38211         LDKTrustedCommitmentTransaction this_arg_conv;
38212         this_arg_conv.inner = (void*)(this_arg & (~1));
38213         this_arg_conv.is_owned = false;
38214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38215         unsigned char htlc_base_key_arr[32];
38216         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
38217         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
38218         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
38219         LDKDirectedChannelTransactionParameters channel_parameters_conv;
38220         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
38221         channel_parameters_conv.is_owned = false;
38222         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
38223         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
38224         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
38225         return (int64_t)ret_conv;
38226 }
38227
38228 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) {
38229         LDKPublicKey broadcaster_payment_basepoint_ref;
38230         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
38231         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
38232         LDKPublicKey countersignatory_payment_basepoint_ref;
38233         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
38234         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
38235         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
38236         return ret_val;
38237 }
38238
38239 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38240         LDKInitFeatures a_conv;
38241         a_conv.inner = (void*)(a & (~1));
38242         a_conv.is_owned = false;
38243         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38244         LDKInitFeatures b_conv;
38245         b_conv.inner = (void*)(b & (~1));
38246         b_conv.is_owned = false;
38247         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38248         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
38249         return ret_val;
38250 }
38251
38252 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38253         LDKNodeFeatures a_conv;
38254         a_conv.inner = (void*)(a & (~1));
38255         a_conv.is_owned = false;
38256         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38257         LDKNodeFeatures b_conv;
38258         b_conv.inner = (void*)(b & (~1));
38259         b_conv.is_owned = false;
38260         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38261         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
38262         return ret_val;
38263 }
38264
38265 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38266         LDKChannelFeatures a_conv;
38267         a_conv.inner = (void*)(a & (~1));
38268         a_conv.is_owned = false;
38269         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38270         LDKChannelFeatures b_conv;
38271         b_conv.inner = (void*)(b & (~1));
38272         b_conv.is_owned = false;
38273         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38274         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
38275         return ret_val;
38276 }
38277
38278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38279         LDKInvoiceFeatures a_conv;
38280         a_conv.inner = (void*)(a & (~1));
38281         a_conv.is_owned = false;
38282         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38283         LDKInvoiceFeatures b_conv;
38284         b_conv.inner = (void*)(b & (~1));
38285         b_conv.is_owned = false;
38286         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38287         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
38288         return ret_val;
38289 }
38290
38291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38292         LDKChannelTypeFeatures a_conv;
38293         a_conv.inner = (void*)(a & (~1));
38294         a_conv.is_owned = false;
38295         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38296         LDKChannelTypeFeatures b_conv;
38297         b_conv.inner = (void*)(b & (~1));
38298         b_conv.is_owned = false;
38299         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38300         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
38301         return ret_val;
38302 }
38303
38304 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
38305         LDKInitFeatures ret_var = InitFeatures_clone(arg);
38306 int64_t ret_ref = 0;
38307 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38308 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38309 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38310 ret_ref = (uintptr_t)ret_var.inner;
38311 if (ret_var.is_owned) {
38312         ret_ref |= 1;
38313 }
38314         return ret_ref;
38315 }
38316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38317         LDKInitFeatures arg_conv;
38318         arg_conv.inner = (void*)(arg & (~1));
38319         arg_conv.is_owned = false;
38320         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38321         int64_t ret_val = InitFeatures_clone_ptr(&arg_conv);
38322         return ret_val;
38323 }
38324
38325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38326         LDKInitFeatures orig_conv;
38327         orig_conv.inner = (void*)(orig & (~1));
38328         orig_conv.is_owned = false;
38329         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38330         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
38331         int64_t ret_ref = 0;
38332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38335         ret_ref = (uintptr_t)ret_var.inner;
38336         if (ret_var.is_owned) {
38337                 ret_ref |= 1;
38338         }
38339         return ret_ref;
38340 }
38341
38342 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
38343         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
38344 int64_t ret_ref = 0;
38345 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38346 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38347 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38348 ret_ref = (uintptr_t)ret_var.inner;
38349 if (ret_var.is_owned) {
38350         ret_ref |= 1;
38351 }
38352         return ret_ref;
38353 }
38354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38355         LDKNodeFeatures arg_conv;
38356         arg_conv.inner = (void*)(arg & (~1));
38357         arg_conv.is_owned = false;
38358         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38359         int64_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
38360         return ret_val;
38361 }
38362
38363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38364         LDKNodeFeatures orig_conv;
38365         orig_conv.inner = (void*)(orig & (~1));
38366         orig_conv.is_owned = false;
38367         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38368         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
38369         int64_t ret_ref = 0;
38370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38373         ret_ref = (uintptr_t)ret_var.inner;
38374         if (ret_var.is_owned) {
38375                 ret_ref |= 1;
38376         }
38377         return ret_ref;
38378 }
38379
38380 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
38381         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
38382 int64_t ret_ref = 0;
38383 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38384 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38385 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38386 ret_ref = (uintptr_t)ret_var.inner;
38387 if (ret_var.is_owned) {
38388         ret_ref |= 1;
38389 }
38390         return ret_ref;
38391 }
38392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38393         LDKChannelFeatures arg_conv;
38394         arg_conv.inner = (void*)(arg & (~1));
38395         arg_conv.is_owned = false;
38396         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38397         int64_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
38398         return ret_val;
38399 }
38400
38401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38402         LDKChannelFeatures orig_conv;
38403         orig_conv.inner = (void*)(orig & (~1));
38404         orig_conv.is_owned = false;
38405         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38406         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
38407         int64_t ret_ref = 0;
38408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38411         ret_ref = (uintptr_t)ret_var.inner;
38412         if (ret_var.is_owned) {
38413                 ret_ref |= 1;
38414         }
38415         return ret_ref;
38416 }
38417
38418 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
38419         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
38420 int64_t ret_ref = 0;
38421 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38422 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38423 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38424 ret_ref = (uintptr_t)ret_var.inner;
38425 if (ret_var.is_owned) {
38426         ret_ref |= 1;
38427 }
38428         return ret_ref;
38429 }
38430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38431         LDKInvoiceFeatures arg_conv;
38432         arg_conv.inner = (void*)(arg & (~1));
38433         arg_conv.is_owned = false;
38434         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38435         int64_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
38436         return ret_val;
38437 }
38438
38439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38440         LDKInvoiceFeatures orig_conv;
38441         orig_conv.inner = (void*)(orig & (~1));
38442         orig_conv.is_owned = false;
38443         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38444         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
38445         int64_t ret_ref = 0;
38446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38449         ret_ref = (uintptr_t)ret_var.inner;
38450         if (ret_var.is_owned) {
38451                 ret_ref |= 1;
38452         }
38453         return ret_ref;
38454 }
38455
38456 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
38457         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
38458 int64_t ret_ref = 0;
38459 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38460 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38461 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38462 ret_ref = (uintptr_t)ret_var.inner;
38463 if (ret_var.is_owned) {
38464         ret_ref |= 1;
38465 }
38466         return ret_ref;
38467 }
38468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38469         LDKChannelTypeFeatures arg_conv;
38470         arg_conv.inner = (void*)(arg & (~1));
38471         arg_conv.is_owned = false;
38472         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38473         int64_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
38474         return ret_val;
38475 }
38476
38477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38478         LDKChannelTypeFeatures orig_conv;
38479         orig_conv.inner = (void*)(orig & (~1));
38480         orig_conv.is_owned = false;
38481         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38482         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
38483         int64_t ret_ref = 0;
38484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38487         ret_ref = (uintptr_t)ret_var.inner;
38488         if (ret_var.is_owned) {
38489                 ret_ref |= 1;
38490         }
38491         return ret_ref;
38492 }
38493
38494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38495         LDKInitFeatures this_obj_conv;
38496         this_obj_conv.inner = (void*)(this_obj & (~1));
38497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38499         InitFeatures_free(this_obj_conv);
38500 }
38501
38502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38503         LDKNodeFeatures this_obj_conv;
38504         this_obj_conv.inner = (void*)(this_obj & (~1));
38505         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38507         NodeFeatures_free(this_obj_conv);
38508 }
38509
38510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38511         LDKChannelFeatures this_obj_conv;
38512         this_obj_conv.inner = (void*)(this_obj & (~1));
38513         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38515         ChannelFeatures_free(this_obj_conv);
38516 }
38517
38518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38519         LDKInvoiceFeatures this_obj_conv;
38520         this_obj_conv.inner = (void*)(this_obj & (~1));
38521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38523         InvoiceFeatures_free(this_obj_conv);
38524 }
38525
38526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38527         LDKChannelTypeFeatures this_obj_conv;
38528         this_obj_conv.inner = (void*)(this_obj & (~1));
38529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38531         ChannelTypeFeatures_free(this_obj_conv);
38532 }
38533
38534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
38535         LDKInitFeatures ret_var = InitFeatures_empty();
38536         int64_t ret_ref = 0;
38537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38540         ret_ref = (uintptr_t)ret_var.inner;
38541         if (ret_var.is_owned) {
38542                 ret_ref |= 1;
38543         }
38544         return ret_ref;
38545 }
38546
38547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
38548         LDKInitFeatures ret_var = InitFeatures_known();
38549         int64_t ret_ref = 0;
38550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38553         ret_ref = (uintptr_t)ret_var.inner;
38554         if (ret_var.is_owned) {
38555                 ret_ref |= 1;
38556         }
38557         return ret_ref;
38558 }
38559
38560 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38561         LDKInitFeatures this_arg_conv;
38562         this_arg_conv.inner = (void*)(this_arg & (~1));
38563         this_arg_conv.is_owned = false;
38564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38565         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
38566         return ret_val;
38567 }
38568
38569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
38570         LDKNodeFeatures ret_var = NodeFeatures_empty();
38571         int64_t ret_ref = 0;
38572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38575         ret_ref = (uintptr_t)ret_var.inner;
38576         if (ret_var.is_owned) {
38577                 ret_ref |= 1;
38578         }
38579         return ret_ref;
38580 }
38581
38582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
38583         LDKNodeFeatures ret_var = NodeFeatures_known();
38584         int64_t ret_ref = 0;
38585         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38586         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38588         ret_ref = (uintptr_t)ret_var.inner;
38589         if (ret_var.is_owned) {
38590                 ret_ref |= 1;
38591         }
38592         return ret_ref;
38593 }
38594
38595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38596         LDKNodeFeatures this_arg_conv;
38597         this_arg_conv.inner = (void*)(this_arg & (~1));
38598         this_arg_conv.is_owned = false;
38599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38600         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
38601         return ret_val;
38602 }
38603
38604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
38605         LDKChannelFeatures ret_var = ChannelFeatures_empty();
38606         int64_t ret_ref = 0;
38607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38610         ret_ref = (uintptr_t)ret_var.inner;
38611         if (ret_var.is_owned) {
38612                 ret_ref |= 1;
38613         }
38614         return ret_ref;
38615 }
38616
38617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
38618         LDKChannelFeatures ret_var = ChannelFeatures_known();
38619         int64_t ret_ref = 0;
38620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38623         ret_ref = (uintptr_t)ret_var.inner;
38624         if (ret_var.is_owned) {
38625                 ret_ref |= 1;
38626         }
38627         return ret_ref;
38628 }
38629
38630 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38631         LDKChannelFeatures this_arg_conv;
38632         this_arg_conv.inner = (void*)(this_arg & (~1));
38633         this_arg_conv.is_owned = false;
38634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38635         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
38636         return ret_val;
38637 }
38638
38639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
38640         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
38641         int64_t ret_ref = 0;
38642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38645         ret_ref = (uintptr_t)ret_var.inner;
38646         if (ret_var.is_owned) {
38647                 ret_ref |= 1;
38648         }
38649         return ret_ref;
38650 }
38651
38652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
38653         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
38654         int64_t ret_ref = 0;
38655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38658         ret_ref = (uintptr_t)ret_var.inner;
38659         if (ret_var.is_owned) {
38660                 ret_ref |= 1;
38661         }
38662         return ret_ref;
38663 }
38664
38665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38666         LDKInvoiceFeatures this_arg_conv;
38667         this_arg_conv.inner = (void*)(this_arg & (~1));
38668         this_arg_conv.is_owned = false;
38669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38670         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
38671         return ret_val;
38672 }
38673
38674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
38675         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
38676         int64_t ret_ref = 0;
38677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38680         ret_ref = (uintptr_t)ret_var.inner;
38681         if (ret_var.is_owned) {
38682                 ret_ref |= 1;
38683         }
38684         return ret_ref;
38685 }
38686
38687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
38688         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
38689         int64_t ret_ref = 0;
38690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38693         ret_ref = (uintptr_t)ret_var.inner;
38694         if (ret_var.is_owned) {
38695                 ret_ref |= 1;
38696         }
38697         return ret_ref;
38698 }
38699
38700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38701         LDKChannelTypeFeatures this_arg_conv;
38702         this_arg_conv.inner = (void*)(this_arg & (~1));
38703         this_arg_conv.is_owned = false;
38704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38705         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
38706         return ret_val;
38707 }
38708
38709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38710         LDKInitFeatures obj_conv;
38711         obj_conv.inner = (void*)(obj & (~1));
38712         obj_conv.is_owned = false;
38713         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38714         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
38715         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38716         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38717         CVec_u8Z_free(ret_var);
38718         return ret_arr;
38719 }
38720
38721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38722         LDKu8slice ser_ref;
38723         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38724         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38725         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
38726         *ret_conv = InitFeatures_read(ser_ref);
38727         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38728         return (int64_t)ret_conv;
38729 }
38730
38731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38732         LDKChannelFeatures obj_conv;
38733         obj_conv.inner = (void*)(obj & (~1));
38734         obj_conv.is_owned = false;
38735         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38736         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
38737         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38738         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38739         CVec_u8Z_free(ret_var);
38740         return ret_arr;
38741 }
38742
38743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38744         LDKu8slice ser_ref;
38745         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38746         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38747         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
38748         *ret_conv = ChannelFeatures_read(ser_ref);
38749         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38750         return (int64_t)ret_conv;
38751 }
38752
38753 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38754         LDKNodeFeatures obj_conv;
38755         obj_conv.inner = (void*)(obj & (~1));
38756         obj_conv.is_owned = false;
38757         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38758         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
38759         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38760         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38761         CVec_u8Z_free(ret_var);
38762         return ret_arr;
38763 }
38764
38765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38766         LDKu8slice ser_ref;
38767         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38768         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38769         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
38770         *ret_conv = NodeFeatures_read(ser_ref);
38771         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38772         return (int64_t)ret_conv;
38773 }
38774
38775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38776         LDKInvoiceFeatures obj_conv;
38777         obj_conv.inner = (void*)(obj & (~1));
38778         obj_conv.is_owned = false;
38779         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38780         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
38781         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38782         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38783         CVec_u8Z_free(ret_var);
38784         return ret_arr;
38785 }
38786
38787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38788         LDKu8slice ser_ref;
38789         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38790         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38791         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
38792         *ret_conv = InvoiceFeatures_read(ser_ref);
38793         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38794         return (int64_t)ret_conv;
38795 }
38796
38797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38798         LDKChannelTypeFeatures obj_conv;
38799         obj_conv.inner = (void*)(obj & (~1));
38800         obj_conv.is_owned = false;
38801         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38802         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
38803         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38804         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38805         CVec_u8Z_free(ret_var);
38806         return ret_arr;
38807 }
38808
38809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38810         LDKu8slice ser_ref;
38811         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38812         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38813         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
38814         *ret_conv = ChannelTypeFeatures_read(ser_ref);
38815         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38816         return (int64_t)ret_conv;
38817 }
38818
38819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38820         LDKShutdownScript this_obj_conv;
38821         this_obj_conv.inner = (void*)(this_obj & (~1));
38822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38824         ShutdownScript_free(this_obj_conv);
38825 }
38826
38827 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
38828         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
38829 int64_t ret_ref = 0;
38830 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38831 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38832 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38833 ret_ref = (uintptr_t)ret_var.inner;
38834 if (ret_var.is_owned) {
38835         ret_ref |= 1;
38836 }
38837         return ret_ref;
38838 }
38839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38840         LDKShutdownScript arg_conv;
38841         arg_conv.inner = (void*)(arg & (~1));
38842         arg_conv.is_owned = false;
38843         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38844         int64_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
38845         return ret_val;
38846 }
38847
38848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38849         LDKShutdownScript orig_conv;
38850         orig_conv.inner = (void*)(orig & (~1));
38851         orig_conv.is_owned = false;
38852         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38853         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
38854         int64_t ret_ref = 0;
38855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38858         ret_ref = (uintptr_t)ret_var.inner;
38859         if (ret_var.is_owned) {
38860                 ret_ref |= 1;
38861         }
38862         return ret_ref;
38863 }
38864
38865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38866         LDKInvalidShutdownScript this_obj_conv;
38867         this_obj_conv.inner = (void*)(this_obj & (~1));
38868         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38870         InvalidShutdownScript_free(this_obj_conv);
38871 }
38872
38873 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
38874         LDKInvalidShutdownScript this_ptr_conv;
38875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38876         this_ptr_conv.is_owned = false;
38877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38878         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
38879         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38880         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38881         return ret_arr;
38882 }
38883
38884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38885         LDKInvalidShutdownScript this_ptr_conv;
38886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38887         this_ptr_conv.is_owned = false;
38888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38889         LDKCVec_u8Z val_ref;
38890         val_ref.datalen = (*env)->GetArrayLength(env, val);
38891         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38892         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
38893         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
38894 }
38895
38896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
38897         LDKCVec_u8Z script_arg_ref;
38898         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
38899         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
38900         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
38901         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
38902         int64_t ret_ref = 0;
38903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38906         ret_ref = (uintptr_t)ret_var.inner;
38907         if (ret_var.is_owned) {
38908                 ret_ref |= 1;
38909         }
38910         return ret_ref;
38911 }
38912
38913 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
38914         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
38915 int64_t ret_ref = 0;
38916 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38917 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38918 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38919 ret_ref = (uintptr_t)ret_var.inner;
38920 if (ret_var.is_owned) {
38921         ret_ref |= 1;
38922 }
38923         return ret_ref;
38924 }
38925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38926         LDKInvalidShutdownScript arg_conv;
38927         arg_conv.inner = (void*)(arg & (~1));
38928         arg_conv.is_owned = false;
38929         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38930         int64_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
38931         return ret_val;
38932 }
38933
38934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38935         LDKInvalidShutdownScript orig_conv;
38936         orig_conv.inner = (void*)(orig & (~1));
38937         orig_conv.is_owned = false;
38938         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38939         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
38940         int64_t ret_ref = 0;
38941         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38942         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38944         ret_ref = (uintptr_t)ret_var.inner;
38945         if (ret_var.is_owned) {
38946                 ret_ref |= 1;
38947         }
38948         return ret_ref;
38949 }
38950
38951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
38952         LDKShutdownScript obj_conv;
38953         obj_conv.inner = (void*)(obj & (~1));
38954         obj_conv.is_owned = false;
38955         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38956         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
38957         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38958         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38959         CVec_u8Z_free(ret_var);
38960         return ret_arr;
38961 }
38962
38963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38964         LDKu8slice ser_ref;
38965         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38966         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38967         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
38968         *ret_conv = ShutdownScript_read(ser_ref);
38969         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38970         return (int64_t)ret_conv;
38971 }
38972
38973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
38974         unsigned char pubkey_hash_arr[20];
38975         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
38976         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
38977         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
38978         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
38979         int64_t ret_ref = 0;
38980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38983         ret_ref = (uintptr_t)ret_var.inner;
38984         if (ret_var.is_owned) {
38985                 ret_ref |= 1;
38986         }
38987         return ret_ref;
38988 }
38989
38990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
38991         unsigned char script_hash_arr[32];
38992         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
38993         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
38994         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
38995         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
38996         int64_t ret_ref = 0;
38997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39000         ret_ref = (uintptr_t)ret_var.inner;
39001         if (ret_var.is_owned) {
39002                 ret_ref |= 1;
39003         }
39004         return ret_ref;
39005 }
39006
39007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
39008         LDKu8slice program_ref;
39009         program_ref.datalen = (*env)->GetArrayLength(env, program);
39010         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
39011         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
39012         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
39013         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
39014         return (int64_t)ret_conv;
39015 }
39016
39017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
39018         LDKShutdownScript this_arg_conv;
39019         this_arg_conv.inner = (void*)(this_arg & (~1));
39020         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39022         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
39023         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
39024         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39025         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39026         CVec_u8Z_free(ret_var);
39027         return ret_arr;
39028 }
39029
39030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
39031         LDKShutdownScript this_arg_conv;
39032         this_arg_conv.inner = (void*)(this_arg & (~1));
39033         this_arg_conv.is_owned = false;
39034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39035         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39036         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
39037         return ret_arr;
39038 }
39039
39040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
39041         LDKShutdownScript this_arg_conv;
39042         this_arg_conv.inner = (void*)(this_arg & (~1));
39043         this_arg_conv.is_owned = false;
39044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39045         LDKInitFeatures features_conv;
39046         features_conv.inner = (void*)(features & (~1));
39047         features_conv.is_owned = false;
39048         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
39049         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
39050         return ret_val;
39051 }
39052
39053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39054         if ((this_ptr & 1) != 0) return;
39055         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39056         CHECK_ACCESS(this_ptr_ptr);
39057         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
39058         FREE((void*)this_ptr);
39059         CustomMessageReader_free(this_ptr_conv);
39060 }
39061
39062 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
39063         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39064         *ret_ret = Type_clone(arg);
39065         return (int64_t)ret_ret;
39066 }
39067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39068         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
39069         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
39070         LDKType* arg_conv = (LDKType*)arg_ptr;
39071         int64_t ret_val = Type_clone_ptr(arg_conv);
39072         return ret_val;
39073 }
39074
39075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39076         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
39077         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
39078         LDKType* orig_conv = (LDKType*)orig_ptr;
39079         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39080         *ret_ret = Type_clone(orig_conv);
39081         return (int64_t)ret_ret;
39082 }
39083
39084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39085         if ((this_ptr & 1) != 0) return;
39086         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39087         CHECK_ACCESS(this_ptr_ptr);
39088         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
39089         FREE((void*)this_ptr);
39090         Type_free(this_ptr_conv);
39091 }
39092
39093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39094         LDKNodeId this_obj_conv;
39095         this_obj_conv.inner = (void*)(this_obj & (~1));
39096         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39098         NodeId_free(this_obj_conv);
39099 }
39100
39101 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
39102         LDKNodeId ret_var = NodeId_clone(arg);
39103 int64_t ret_ref = 0;
39104 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39105 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39106 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39107 ret_ref = (uintptr_t)ret_var.inner;
39108 if (ret_var.is_owned) {
39109         ret_ref |= 1;
39110 }
39111         return ret_ref;
39112 }
39113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39114         LDKNodeId arg_conv;
39115         arg_conv.inner = (void*)(arg & (~1));
39116         arg_conv.is_owned = false;
39117         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39118         int64_t ret_val = NodeId_clone_ptr(&arg_conv);
39119         return ret_val;
39120 }
39121
39122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39123         LDKNodeId orig_conv;
39124         orig_conv.inner = (void*)(orig & (~1));
39125         orig_conv.is_owned = false;
39126         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39127         LDKNodeId ret_var = NodeId_clone(&orig_conv);
39128         int64_t ret_ref = 0;
39129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39132         ret_ref = (uintptr_t)ret_var.inner;
39133         if (ret_var.is_owned) {
39134                 ret_ref |= 1;
39135         }
39136         return ret_ref;
39137 }
39138
39139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
39140         LDKPublicKey pubkey_ref;
39141         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
39142         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
39143         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
39144         int64_t ret_ref = 0;
39145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39148         ret_ref = (uintptr_t)ret_var.inner;
39149         if (ret_var.is_owned) {
39150                 ret_ref |= 1;
39151         }
39152         return ret_ref;
39153 }
39154
39155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
39156         LDKNodeId this_arg_conv;
39157         this_arg_conv.inner = (void*)(this_arg & (~1));
39158         this_arg_conv.is_owned = false;
39159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39160         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
39161         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39162         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39163         return ret_arr;
39164 }
39165
39166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
39167         LDKNodeId o_conv;
39168         o_conv.inner = (void*)(o & (~1));
39169         o_conv.is_owned = false;
39170         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39171         int64_t ret_val = NodeId_hash(&o_conv);
39172         return ret_val;
39173 }
39174
39175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
39176         LDKNodeId obj_conv;
39177         obj_conv.inner = (void*)(obj & (~1));
39178         obj_conv.is_owned = false;
39179         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39180         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
39181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39183         CVec_u8Z_free(ret_var);
39184         return ret_arr;
39185 }
39186
39187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39188         LDKu8slice ser_ref;
39189         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39190         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39191         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
39192         *ret_conv = NodeId_read(ser_ref);
39193         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39194         return (int64_t)ret_conv;
39195 }
39196
39197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39198         LDKNetworkGraph this_obj_conv;
39199         this_obj_conv.inner = (void*)(this_obj & (~1));
39200         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39202         NetworkGraph_free(this_obj_conv);
39203 }
39204
39205 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
39206         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
39207 int64_t ret_ref = 0;
39208 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39209 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39210 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39211 ret_ref = (uintptr_t)ret_var.inner;
39212 if (ret_var.is_owned) {
39213         ret_ref |= 1;
39214 }
39215         return ret_ref;
39216 }
39217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39218         LDKNetworkGraph arg_conv;
39219         arg_conv.inner = (void*)(arg & (~1));
39220         arg_conv.is_owned = false;
39221         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39222         int64_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
39223         return ret_val;
39224 }
39225
39226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39227         LDKNetworkGraph orig_conv;
39228         orig_conv.inner = (void*)(orig & (~1));
39229         orig_conv.is_owned = false;
39230         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39231         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
39232         int64_t ret_ref = 0;
39233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39236         ret_ref = (uintptr_t)ret_var.inner;
39237         if (ret_var.is_owned) {
39238                 ret_ref |= 1;
39239         }
39240         return ret_ref;
39241 }
39242
39243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39244         LDKReadOnlyNetworkGraph this_obj_conv;
39245         this_obj_conv.inner = (void*)(this_obj & (~1));
39246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39248         ReadOnlyNetworkGraph_free(this_obj_conv);
39249 }
39250
39251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39252         if ((this_ptr & 1) != 0) return;
39253         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39254         CHECK_ACCESS(this_ptr_ptr);
39255         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
39256         FREE((void*)this_ptr);
39257         NetworkUpdate_free(this_ptr_conv);
39258 }
39259
39260 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
39261         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39262         *ret_copy = NetworkUpdate_clone(arg);
39263 int64_t ret_ref = (uintptr_t)ret_copy;
39264         return ret_ref;
39265 }
39266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39267         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
39268         int64_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
39269         return ret_val;
39270 }
39271
39272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39273         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
39274         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39275         *ret_copy = NetworkUpdate_clone(orig_conv);
39276         int64_t ret_ref = (uintptr_t)ret_copy;
39277         return ret_ref;
39278 }
39279
39280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
39281         LDKChannelUpdate msg_conv;
39282         msg_conv.inner = (void*)(msg & (~1));
39283         msg_conv.is_owned = (msg & 1) || (msg == 0);
39284         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39285         msg_conv = ChannelUpdate_clone(&msg_conv);
39286         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39287         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
39288         int64_t ret_ref = (uintptr_t)ret_copy;
39289         return ret_ref;
39290 }
39291
39292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
39293         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39294         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
39295         int64_t ret_ref = (uintptr_t)ret_copy;
39296         return ret_ref;
39297 }
39298
39299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
39300         LDKPublicKey node_id_ref;
39301         CHECK((*env)->GetArrayLength(env, node_id) == 33);
39302         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
39303         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39304         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
39305         int64_t ret_ref = (uintptr_t)ret_copy;
39306         return ret_ref;
39307 }
39308
39309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
39310         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
39311         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
39312         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39313         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39314         CVec_u8Z_free(ret_var);
39315         return ret_arr;
39316 }
39317
39318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39319         LDKu8slice ser_ref;
39320         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39321         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39322         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
39323         *ret_conv = NetworkUpdate_read(ser_ref);
39324         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39325         return (int64_t)ret_conv;
39326 }
39327
39328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39329         LDKNetGraphMsgHandler this_arg_conv;
39330         this_arg_conv.inner = (void*)(this_arg & (~1));
39331         this_arg_conv.is_owned = false;
39332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39333         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
39334         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
39335         return (int64_t)ret_ret;
39336 }
39337
39338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39339         LDKNetGraphMsgHandler this_obj_conv;
39340         this_obj_conv.inner = (void*)(this_obj & (~1));
39341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39343         NetGraphMsgHandler_free(this_obj_conv);
39344 }
39345
39346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
39347         LDKNetworkGraph network_graph_conv;
39348         network_graph_conv.inner = (void*)(network_graph & (~1));
39349         network_graph_conv.is_owned = false;
39350         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39351         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39352         CHECK_ACCESS(chain_access_ptr);
39353         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39354         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39355         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39356                 // Manually implement clone for Java trait instances
39357                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39358                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39359                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39360                 }
39361         }
39362         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39363         CHECK_ACCESS(logger_ptr);
39364         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39365         if (logger_conv.free == LDKLogger_JCalls_free) {
39366                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39367                 LDKLogger_JCalls_cloned(&logger_conv);
39368         }
39369         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
39370         int64_t ret_ref = 0;
39371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39374         ret_ref = (uintptr_t)ret_var.inner;
39375         if (ret_var.is_owned) {
39376                 ret_ref |= 1;
39377         }
39378         return ret_ref;
39379 }
39380
39381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
39382         LDKNetGraphMsgHandler this_arg_conv;
39383         this_arg_conv.inner = (void*)(this_arg & (~1));
39384         this_arg_conv.is_owned = false;
39385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39386         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39387         CHECK_ACCESS(chain_access_ptr);
39388         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39389         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39390         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39391                 // Manually implement clone for Java trait instances
39392                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39393                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39394                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39395                 }
39396         }
39397         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
39398 }
39399
39400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39401         LDKNetGraphMsgHandler this_arg_conv;
39402         this_arg_conv.inner = (void*)(this_arg & (~1));
39403         this_arg_conv.is_owned = false;
39404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39405         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39406         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
39407         return (int64_t)ret_ret;
39408 }
39409
39410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39411         LDKNetGraphMsgHandler this_arg_conv;
39412         this_arg_conv.inner = (void*)(this_arg & (~1));
39413         this_arg_conv.is_owned = false;
39414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39415         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39416         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
39417         return (int64_t)ret_ret;
39418 }
39419
39420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39421         LDKChannelUpdateInfo this_obj_conv;
39422         this_obj_conv.inner = (void*)(this_obj & (~1));
39423         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39425         ChannelUpdateInfo_free(this_obj_conv);
39426 }
39427
39428 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
39429         LDKChannelUpdateInfo 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         int32_t ret_val = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
39434         return ret_val;
39435 }
39436
39437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39438         LDKChannelUpdateInfo this_ptr_conv;
39439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39440         this_ptr_conv.is_owned = false;
39441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39442         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
39443 }
39444
39445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
39446         LDKChannelUpdateInfo this_ptr_conv;
39447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39448         this_ptr_conv.is_owned = false;
39449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39450         jboolean ret_val = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
39451         return ret_val;
39452 }
39453
39454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39455         LDKChannelUpdateInfo this_ptr_conv;
39456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39457         this_ptr_conv.is_owned = false;
39458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39459         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
39460 }
39461
39462 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39463         LDKChannelUpdateInfo this_ptr_conv;
39464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39465         this_ptr_conv.is_owned = false;
39466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39467         int16_t ret_val = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
39468         return ret_val;
39469 }
39470
39471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39472         LDKChannelUpdateInfo this_ptr_conv;
39473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39474         this_ptr_conv.is_owned = false;
39475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39476         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
39477 }
39478
39479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39480         LDKChannelUpdateInfo this_ptr_conv;
39481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39482         this_ptr_conv.is_owned = false;
39483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39484         int64_t ret_val = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
39485         return ret_val;
39486 }
39487
39488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39489         LDKChannelUpdateInfo this_ptr_conv;
39490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39491         this_ptr_conv.is_owned = false;
39492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39493         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
39494 }
39495
39496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39497         LDKChannelUpdateInfo this_ptr_conv;
39498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39499         this_ptr_conv.is_owned = false;
39500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39501         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39502         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
39503         int64_t ret_ref = (uintptr_t)ret_copy;
39504         return ret_ref;
39505 }
39506
39507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39508         LDKChannelUpdateInfo this_ptr_conv;
39509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39510         this_ptr_conv.is_owned = false;
39511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39512         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39513         CHECK_ACCESS(val_ptr);
39514         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39515         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39516         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
39517 }
39518
39519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
39520         LDKChannelUpdateInfo this_ptr_conv;
39521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39522         this_ptr_conv.is_owned = false;
39523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39524         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
39525         int64_t ret_ref = 0;
39526         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39527         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39529         ret_ref = (uintptr_t)ret_var.inner;
39530         if (ret_var.is_owned) {
39531                 ret_ref |= 1;
39532         }
39533         return ret_ref;
39534 }
39535
39536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39537         LDKChannelUpdateInfo this_ptr_conv;
39538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39539         this_ptr_conv.is_owned = false;
39540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39541         LDKRoutingFees val_conv;
39542         val_conv.inner = (void*)(val & (~1));
39543         val_conv.is_owned = (val & 1) || (val == 0);
39544         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39545         val_conv = RoutingFees_clone(&val_conv);
39546         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
39547 }
39548
39549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
39550         LDKChannelUpdateInfo this_ptr_conv;
39551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39552         this_ptr_conv.is_owned = false;
39553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39554         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
39555         int64_t ret_ref = 0;
39556         if ((uintptr_t)ret_var.inner > 4096) {
39557                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39558                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39560                 ret_ref = (uintptr_t)ret_var.inner;
39561                 if (ret_var.is_owned) {
39562                         ret_ref |= 1;
39563                 }
39564         }
39565         return ret_ref;
39566 }
39567
39568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39569         LDKChannelUpdateInfo this_ptr_conv;
39570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39571         this_ptr_conv.is_owned = false;
39572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39573         LDKChannelUpdate val_conv;
39574         val_conv.inner = (void*)(val & (~1));
39575         val_conv.is_owned = (val & 1) || (val == 0);
39576         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39577         val_conv = ChannelUpdate_clone(&val_conv);
39578         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
39579 }
39580
39581 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) {
39582         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
39583         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
39584         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
39585         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
39586         LDKRoutingFees fees_arg_conv;
39587         fees_arg_conv.inner = (void*)(fees_arg & (~1));
39588         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
39589         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
39590         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
39591         LDKChannelUpdate last_update_message_arg_conv;
39592         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
39593         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
39594         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
39595         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
39596         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
39597         int64_t ret_ref = 0;
39598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39601         ret_ref = (uintptr_t)ret_var.inner;
39602         if (ret_var.is_owned) {
39603                 ret_ref |= 1;
39604         }
39605         return ret_ref;
39606 }
39607
39608 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
39609         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
39610 int64_t ret_ref = 0;
39611 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39612 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39613 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39614 ret_ref = (uintptr_t)ret_var.inner;
39615 if (ret_var.is_owned) {
39616         ret_ref |= 1;
39617 }
39618         return ret_ref;
39619 }
39620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39621         LDKChannelUpdateInfo arg_conv;
39622         arg_conv.inner = (void*)(arg & (~1));
39623         arg_conv.is_owned = false;
39624         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39625         int64_t ret_val = ChannelUpdateInfo_clone_ptr(&arg_conv);
39626         return ret_val;
39627 }
39628
39629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39630         LDKChannelUpdateInfo orig_conv;
39631         orig_conv.inner = (void*)(orig & (~1));
39632         orig_conv.is_owned = false;
39633         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39634         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
39635         int64_t ret_ref = 0;
39636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39639         ret_ref = (uintptr_t)ret_var.inner;
39640         if (ret_var.is_owned) {
39641                 ret_ref |= 1;
39642         }
39643         return ret_ref;
39644 }
39645
39646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
39647         LDKChannelUpdateInfo obj_conv;
39648         obj_conv.inner = (void*)(obj & (~1));
39649         obj_conv.is_owned = false;
39650         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39651         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
39652         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39653         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39654         CVec_u8Z_free(ret_var);
39655         return ret_arr;
39656 }
39657
39658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39659         LDKu8slice ser_ref;
39660         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39661         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39662         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
39663         *ret_conv = ChannelUpdateInfo_read(ser_ref);
39664         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39665         return (int64_t)ret_conv;
39666 }
39667
39668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39669         LDKChannelInfo this_obj_conv;
39670         this_obj_conv.inner = (void*)(this_obj & (~1));
39671         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39673         ChannelInfo_free(this_obj_conv);
39674 }
39675
39676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
39677         LDKChannelInfo this_ptr_conv;
39678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39679         this_ptr_conv.is_owned = false;
39680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39681         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
39682         int64_t ret_ref = 0;
39683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39686         ret_ref = (uintptr_t)ret_var.inner;
39687         if (ret_var.is_owned) {
39688                 ret_ref |= 1;
39689         }
39690         return ret_ref;
39691 }
39692
39693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39694         LDKChannelInfo this_ptr_conv;
39695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39696         this_ptr_conv.is_owned = false;
39697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39698         LDKChannelFeatures val_conv;
39699         val_conv.inner = (void*)(val & (~1));
39700         val_conv.is_owned = (val & 1) || (val == 0);
39701         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39702         val_conv = ChannelFeatures_clone(&val_conv);
39703         ChannelInfo_set_features(&this_ptr_conv, val_conv);
39704 }
39705
39706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
39707         LDKChannelInfo this_ptr_conv;
39708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39709         this_ptr_conv.is_owned = false;
39710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39711         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
39712         int64_t ret_ref = 0;
39713         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39714         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39716         ret_ref = (uintptr_t)ret_var.inner;
39717         if (ret_var.is_owned) {
39718                 ret_ref |= 1;
39719         }
39720         return ret_ref;
39721 }
39722
39723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39724         LDKChannelInfo this_ptr_conv;
39725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39726         this_ptr_conv.is_owned = false;
39727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39728         LDKNodeId val_conv;
39729         val_conv.inner = (void*)(val & (~1));
39730         val_conv.is_owned = (val & 1) || (val == 0);
39731         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39732         val_conv = NodeId_clone(&val_conv);
39733         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
39734 }
39735
39736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
39737         LDKChannelInfo this_ptr_conv;
39738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39739         this_ptr_conv.is_owned = false;
39740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39741         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
39742         int64_t ret_ref = 0;
39743         if ((uintptr_t)ret_var.inner > 4096) {
39744                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39745                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39747                 ret_ref = (uintptr_t)ret_var.inner;
39748                 if (ret_var.is_owned) {
39749                         ret_ref |= 1;
39750                 }
39751         }
39752         return ret_ref;
39753 }
39754
39755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39756         LDKChannelInfo this_ptr_conv;
39757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39758         this_ptr_conv.is_owned = false;
39759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39760         LDKChannelUpdateInfo val_conv;
39761         val_conv.inner = (void*)(val & (~1));
39762         val_conv.is_owned = (val & 1) || (val == 0);
39763         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39764         val_conv = ChannelUpdateInfo_clone(&val_conv);
39765         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
39766 }
39767
39768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
39769         LDKChannelInfo 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         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
39774         int64_t ret_ref = 0;
39775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39778         ret_ref = (uintptr_t)ret_var.inner;
39779         if (ret_var.is_owned) {
39780                 ret_ref |= 1;
39781         }
39782         return ret_ref;
39783 }
39784
39785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39786         LDKChannelInfo this_ptr_conv;
39787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39788         this_ptr_conv.is_owned = false;
39789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39790         LDKNodeId val_conv;
39791         val_conv.inner = (void*)(val & (~1));
39792         val_conv.is_owned = (val & 1) || (val == 0);
39793         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39794         val_conv = NodeId_clone(&val_conv);
39795         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
39796 }
39797
39798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
39799         LDKChannelInfo this_ptr_conv;
39800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39801         this_ptr_conv.is_owned = false;
39802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39803         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
39804         int64_t ret_ref = 0;
39805         if ((uintptr_t)ret_var.inner > 4096) {
39806                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39807                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39809                 ret_ref = (uintptr_t)ret_var.inner;
39810                 if (ret_var.is_owned) {
39811                         ret_ref |= 1;
39812                 }
39813         }
39814         return ret_ref;
39815 }
39816
39817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39818         LDKChannelInfo this_ptr_conv;
39819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39820         this_ptr_conv.is_owned = false;
39821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39822         LDKChannelUpdateInfo val_conv;
39823         val_conv.inner = (void*)(val & (~1));
39824         val_conv.is_owned = (val & 1) || (val == 0);
39825         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39826         val_conv = ChannelUpdateInfo_clone(&val_conv);
39827         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
39828 }
39829
39830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
39831         LDKChannelInfo this_ptr_conv;
39832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39833         this_ptr_conv.is_owned = false;
39834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39835         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39836         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
39837         int64_t ret_ref = (uintptr_t)ret_copy;
39838         return ret_ref;
39839 }
39840
39841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39842         LDKChannelInfo this_ptr_conv;
39843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39844         this_ptr_conv.is_owned = false;
39845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39846         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39847         CHECK_ACCESS(val_ptr);
39848         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39849         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39850         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
39851 }
39852
39853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
39854         LDKChannelInfo this_ptr_conv;
39855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39856         this_ptr_conv.is_owned = false;
39857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39858         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
39859         int64_t ret_ref = 0;
39860         if ((uintptr_t)ret_var.inner > 4096) {
39861                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39862                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39864                 ret_ref = (uintptr_t)ret_var.inner;
39865                 if (ret_var.is_owned) {
39866                         ret_ref |= 1;
39867                 }
39868         }
39869         return ret_ref;
39870 }
39871
39872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39873         LDKChannelInfo this_ptr_conv;
39874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39875         this_ptr_conv.is_owned = false;
39876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39877         LDKChannelAnnouncement val_conv;
39878         val_conv.inner = (void*)(val & (~1));
39879         val_conv.is_owned = (val & 1) || (val == 0);
39880         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39881         val_conv = ChannelAnnouncement_clone(&val_conv);
39882         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
39883 }
39884
39885 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
39886         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
39887 int64_t ret_ref = 0;
39888 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39889 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39890 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39891 ret_ref = (uintptr_t)ret_var.inner;
39892 if (ret_var.is_owned) {
39893         ret_ref |= 1;
39894 }
39895         return ret_ref;
39896 }
39897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39898         LDKChannelInfo arg_conv;
39899         arg_conv.inner = (void*)(arg & (~1));
39900         arg_conv.is_owned = false;
39901         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39902         int64_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
39903         return ret_val;
39904 }
39905
39906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39907         LDKChannelInfo orig_conv;
39908         orig_conv.inner = (void*)(orig & (~1));
39909         orig_conv.is_owned = false;
39910         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39911         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
39912         int64_t ret_ref = 0;
39913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39916         ret_ref = (uintptr_t)ret_var.inner;
39917         if (ret_var.is_owned) {
39918                 ret_ref |= 1;
39919         }
39920         return ret_ref;
39921 }
39922
39923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
39924         LDKChannelInfo obj_conv;
39925         obj_conv.inner = (void*)(obj & (~1));
39926         obj_conv.is_owned = false;
39927         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39928         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
39929         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39930         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39931         CVec_u8Z_free(ret_var);
39932         return ret_arr;
39933 }
39934
39935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39936         LDKu8slice ser_ref;
39937         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39938         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39939         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
39940         *ret_conv = ChannelInfo_read(ser_ref);
39941         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39942         return (int64_t)ret_conv;
39943 }
39944
39945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39946         LDKDirectedChannelInfo this_obj_conv;
39947         this_obj_conv.inner = (void*)(this_obj & (~1));
39948         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39950         DirectedChannelInfo_free(this_obj_conv);
39951 }
39952
39953 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
39954         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
39955 int64_t ret_ref = 0;
39956 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39957 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39958 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39959 ret_ref = (uintptr_t)ret_var.inner;
39960 if (ret_var.is_owned) {
39961         ret_ref |= 1;
39962 }
39963         return ret_ref;
39964 }
39965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39966         LDKDirectedChannelInfo arg_conv;
39967         arg_conv.inner = (void*)(arg & (~1));
39968         arg_conv.is_owned = false;
39969         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39970         int64_t ret_val = DirectedChannelInfo_clone_ptr(&arg_conv);
39971         return ret_val;
39972 }
39973
39974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39975         LDKDirectedChannelInfo orig_conv;
39976         orig_conv.inner = (void*)(orig & (~1));
39977         orig_conv.is_owned = false;
39978         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39979         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
39980         int64_t ret_ref = 0;
39981         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39982         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39984         ret_ref = (uintptr_t)ret_var.inner;
39985         if (ret_var.is_owned) {
39986                 ret_ref |= 1;
39987         }
39988         return ret_ref;
39989 }
39990
39991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
39992         LDKDirectedChannelInfo this_arg_conv;
39993         this_arg_conv.inner = (void*)(this_arg & (~1));
39994         this_arg_conv.is_owned = false;
39995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39996         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
39997         int64_t ret_ref = 0;
39998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40001         ret_ref = (uintptr_t)ret_var.inner;
40002         if (ret_var.is_owned) {
40003                 ret_ref |= 1;
40004         }
40005         return ret_ref;
40006 }
40007
40008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
40009         LDKDirectedChannelInfo this_arg_conv;
40010         this_arg_conv.inner = (void*)(this_arg & (~1));
40011         this_arg_conv.is_owned = false;
40012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40013         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
40014         int64_t ret_ref = 0;
40015         if ((uintptr_t)ret_var.inner > 4096) {
40016                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40017                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40019                 ret_ref = (uintptr_t)ret_var.inner;
40020                 if (ret_var.is_owned) {
40021                         ret_ref |= 1;
40022                 }
40023         }
40024         return ret_ref;
40025 }
40026
40027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
40028         LDKDirectedChannelInfo this_arg_conv;
40029         this_arg_conv.inner = (void*)(this_arg & (~1));
40030         this_arg_conv.is_owned = false;
40031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40032         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40033         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
40034         int64_t ret_ref = (uintptr_t)ret_copy;
40035         return ret_ref;
40036 }
40037
40038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40039         if ((this_ptr & 1) != 0) return;
40040         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40041         CHECK_ACCESS(this_ptr_ptr);
40042         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
40043         FREE((void*)this_ptr);
40044         EffectiveCapacity_free(this_ptr_conv);
40045 }
40046
40047 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
40048         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40049         *ret_copy = EffectiveCapacity_clone(arg);
40050 int64_t ret_ref = (uintptr_t)ret_copy;
40051         return ret_ref;
40052 }
40053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40054         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
40055         int64_t ret_val = EffectiveCapacity_clone_ptr(arg_conv);
40056         return ret_val;
40057 }
40058
40059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40060         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
40061         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40062         *ret_copy = EffectiveCapacity_clone(orig_conv);
40063         int64_t ret_ref = (uintptr_t)ret_copy;
40064         return ret_ref;
40065 }
40066
40067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
40068         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40069         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
40070         int64_t ret_ref = (uintptr_t)ret_copy;
40071         return ret_ref;
40072 }
40073
40074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
40075         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40076         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
40077         int64_t ret_ref = (uintptr_t)ret_copy;
40078         return ret_ref;
40079 }
40080
40081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat) {
40082         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40083         *ret_copy = EffectiveCapacity_total(capacity_msat);
40084         int64_t ret_ref = (uintptr_t)ret_copy;
40085         return ret_ref;
40086 }
40087
40088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
40089         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40090         *ret_copy = EffectiveCapacity_infinite();
40091         int64_t ret_ref = (uintptr_t)ret_copy;
40092         return ret_ref;
40093 }
40094
40095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
40096         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40097         *ret_copy = EffectiveCapacity_unknown();
40098         int64_t ret_ref = (uintptr_t)ret_copy;
40099         return ret_ref;
40100 }
40101
40102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
40103         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
40104         int64_t ret_val = EffectiveCapacity_as_msat(this_arg_conv);
40105         return ret_val;
40106 }
40107
40108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40109         LDKRoutingFees this_obj_conv;
40110         this_obj_conv.inner = (void*)(this_obj & (~1));
40111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40113         RoutingFees_free(this_obj_conv);
40114 }
40115
40116 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40117         LDKRoutingFees this_ptr_conv;
40118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40119         this_ptr_conv.is_owned = false;
40120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40121         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
40122         return ret_val;
40123 }
40124
40125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40126         LDKRoutingFees this_ptr_conv;
40127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40128         this_ptr_conv.is_owned = false;
40129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40130         RoutingFees_set_base_msat(&this_ptr_conv, val);
40131 }
40132
40133 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
40134         LDKRoutingFees this_ptr_conv;
40135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40136         this_ptr_conv.is_owned = false;
40137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40138         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
40139         return ret_val;
40140 }
40141
40142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40143         LDKRoutingFees this_ptr_conv;
40144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40145         this_ptr_conv.is_owned = false;
40146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40147         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
40148 }
40149
40150 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) {
40151         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
40152         int64_t ret_ref = 0;
40153         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40154         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40156         ret_ref = (uintptr_t)ret_var.inner;
40157         if (ret_var.is_owned) {
40158                 ret_ref |= 1;
40159         }
40160         return ret_ref;
40161 }
40162
40163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40164         LDKRoutingFees a_conv;
40165         a_conv.inner = (void*)(a & (~1));
40166         a_conv.is_owned = false;
40167         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40168         LDKRoutingFees b_conv;
40169         b_conv.inner = (void*)(b & (~1));
40170         b_conv.is_owned = false;
40171         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40172         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
40173         return ret_val;
40174 }
40175
40176 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
40177         LDKRoutingFees ret_var = RoutingFees_clone(arg);
40178 int64_t ret_ref = 0;
40179 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40180 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40181 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40182 ret_ref = (uintptr_t)ret_var.inner;
40183 if (ret_var.is_owned) {
40184         ret_ref |= 1;
40185 }
40186         return ret_ref;
40187 }
40188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40189         LDKRoutingFees arg_conv;
40190         arg_conv.inner = (void*)(arg & (~1));
40191         arg_conv.is_owned = false;
40192         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40193         int64_t ret_val = RoutingFees_clone_ptr(&arg_conv);
40194         return ret_val;
40195 }
40196
40197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40198         LDKRoutingFees orig_conv;
40199         orig_conv.inner = (void*)(orig & (~1));
40200         orig_conv.is_owned = false;
40201         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40202         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
40203         int64_t ret_ref = 0;
40204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40207         ret_ref = (uintptr_t)ret_var.inner;
40208         if (ret_var.is_owned) {
40209                 ret_ref |= 1;
40210         }
40211         return ret_ref;
40212 }
40213
40214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
40215         LDKRoutingFees o_conv;
40216         o_conv.inner = (void*)(o & (~1));
40217         o_conv.is_owned = false;
40218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40219         int64_t ret_val = RoutingFees_hash(&o_conv);
40220         return ret_val;
40221 }
40222
40223 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
40224         LDKRoutingFees obj_conv;
40225         obj_conv.inner = (void*)(obj & (~1));
40226         obj_conv.is_owned = false;
40227         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40228         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
40229         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40230         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40231         CVec_u8Z_free(ret_var);
40232         return ret_arr;
40233 }
40234
40235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40236         LDKu8slice ser_ref;
40237         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40238         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40239         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
40240         *ret_conv = RoutingFees_read(ser_ref);
40241         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40242         return (int64_t)ret_conv;
40243 }
40244
40245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40246         LDKNodeAnnouncementInfo this_obj_conv;
40247         this_obj_conv.inner = (void*)(this_obj & (~1));
40248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40250         NodeAnnouncementInfo_free(this_obj_conv);
40251 }
40252
40253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40254         LDKNodeAnnouncementInfo this_ptr_conv;
40255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40256         this_ptr_conv.is_owned = false;
40257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40258         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
40259         int64_t ret_ref = 0;
40260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40263         ret_ref = (uintptr_t)ret_var.inner;
40264         if (ret_var.is_owned) {
40265                 ret_ref |= 1;
40266         }
40267         return ret_ref;
40268 }
40269
40270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40271         LDKNodeAnnouncementInfo this_ptr_conv;
40272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40273         this_ptr_conv.is_owned = false;
40274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40275         LDKNodeFeatures val_conv;
40276         val_conv.inner = (void*)(val & (~1));
40277         val_conv.is_owned = (val & 1) || (val == 0);
40278         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40279         val_conv = NodeFeatures_clone(&val_conv);
40280         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
40281 }
40282
40283 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
40284         LDKNodeAnnouncementInfo this_ptr_conv;
40285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40286         this_ptr_conv.is_owned = false;
40287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40288         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
40289         return ret_val;
40290 }
40291
40292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40293         LDKNodeAnnouncementInfo this_ptr_conv;
40294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40295         this_ptr_conv.is_owned = false;
40296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40297         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
40298 }
40299
40300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
40301         LDKNodeAnnouncementInfo this_ptr_conv;
40302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40303         this_ptr_conv.is_owned = false;
40304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40305         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
40306         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
40307         return ret_arr;
40308 }
40309
40310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40311         LDKNodeAnnouncementInfo this_ptr_conv;
40312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40313         this_ptr_conv.is_owned = false;
40314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40315         LDKThreeBytes val_ref;
40316         CHECK((*env)->GetArrayLength(env, val) == 3);
40317         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
40318         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
40319 }
40320
40321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
40322         LDKNodeAnnouncementInfo this_ptr_conv;
40323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40324         this_ptr_conv.is_owned = false;
40325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40326         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40327         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
40328         return ret_arr;
40329 }
40330
40331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40332         LDKNodeAnnouncementInfo this_ptr_conv;
40333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40334         this_ptr_conv.is_owned = false;
40335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40336         LDKThirtyTwoBytes val_ref;
40337         CHECK((*env)->GetArrayLength(env, val) == 32);
40338         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40339         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
40340 }
40341
40342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40343         LDKNodeAnnouncementInfo this_ptr_conv;
40344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40345         this_ptr_conv.is_owned = false;
40346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40347         LDKCVec_NetAddressZ val_constr;
40348         val_constr.datalen = (*env)->GetArrayLength(env, val);
40349         if (val_constr.datalen > 0)
40350                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40351         else
40352                 val_constr.data = NULL;
40353         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40354         for (size_t m = 0; m < val_constr.datalen; m++) {
40355                 int64_t val_conv_12 = val_vals[m];
40356                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
40357                 CHECK_ACCESS(val_conv_12_ptr);
40358                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
40359                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
40360                 val_constr.data[m] = val_conv_12_conv;
40361         }
40362         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40363         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
40364 }
40365
40366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40367         LDKNodeAnnouncementInfo this_ptr_conv;
40368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40369         this_ptr_conv.is_owned = false;
40370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40371         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
40372         int64_t ret_ref = 0;
40373         if ((uintptr_t)ret_var.inner > 4096) {
40374                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40375                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40377                 ret_ref = (uintptr_t)ret_var.inner;
40378                 if (ret_var.is_owned) {
40379                         ret_ref |= 1;
40380                 }
40381         }
40382         return ret_ref;
40383 }
40384
40385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40386         LDKNodeAnnouncementInfo this_ptr_conv;
40387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40388         this_ptr_conv.is_owned = false;
40389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40390         LDKNodeAnnouncement val_conv;
40391         val_conv.inner = (void*)(val & (~1));
40392         val_conv.is_owned = (val & 1) || (val == 0);
40393         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40394         val_conv = NodeAnnouncement_clone(&val_conv);
40395         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
40396 }
40397
40398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
40399         LDKNodeFeatures features_arg_conv;
40400         features_arg_conv.inner = (void*)(features_arg & (~1));
40401         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
40402         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40403         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
40404         LDKThreeBytes rgb_arg_ref;
40405         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
40406         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
40407         LDKThirtyTwoBytes alias_arg_ref;
40408         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
40409         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
40410         LDKCVec_NetAddressZ addresses_arg_constr;
40411         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
40412         if (addresses_arg_constr.datalen > 0)
40413                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40414         else
40415                 addresses_arg_constr.data = NULL;
40416         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
40417         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
40418                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
40419                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
40420                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
40421                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
40422                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
40423         }
40424         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
40425         LDKNodeAnnouncement announcement_message_arg_conv;
40426         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
40427         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
40428         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
40429         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
40430         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
40431         int64_t ret_ref = 0;
40432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40435         ret_ref = (uintptr_t)ret_var.inner;
40436         if (ret_var.is_owned) {
40437                 ret_ref |= 1;
40438         }
40439         return ret_ref;
40440 }
40441
40442 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
40443         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
40444 int64_t ret_ref = 0;
40445 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40446 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40448 ret_ref = (uintptr_t)ret_var.inner;
40449 if (ret_var.is_owned) {
40450         ret_ref |= 1;
40451 }
40452         return ret_ref;
40453 }
40454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40455         LDKNodeAnnouncementInfo arg_conv;
40456         arg_conv.inner = (void*)(arg & (~1));
40457         arg_conv.is_owned = false;
40458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40459         int64_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
40460         return ret_val;
40461 }
40462
40463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40464         LDKNodeAnnouncementInfo orig_conv;
40465         orig_conv.inner = (void*)(orig & (~1));
40466         orig_conv.is_owned = false;
40467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40468         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
40469         int64_t ret_ref = 0;
40470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40473         ret_ref = (uintptr_t)ret_var.inner;
40474         if (ret_var.is_owned) {
40475                 ret_ref |= 1;
40476         }
40477         return ret_ref;
40478 }
40479
40480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40481         LDKNodeAnnouncementInfo obj_conv;
40482         obj_conv.inner = (void*)(obj & (~1));
40483         obj_conv.is_owned = false;
40484         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40485         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
40486         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40487         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40488         CVec_u8Z_free(ret_var);
40489         return ret_arr;
40490 }
40491
40492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40493         LDKu8slice ser_ref;
40494         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40495         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40496         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
40497         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
40498         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40499         return (int64_t)ret_conv;
40500 }
40501
40502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40503         LDKNodeInfo this_obj_conv;
40504         this_obj_conv.inner = (void*)(this_obj & (~1));
40505         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40507         NodeInfo_free(this_obj_conv);
40508 }
40509
40510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40511         LDKNodeInfo this_ptr_conv;
40512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40513         this_ptr_conv.is_owned = false;
40514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40515         LDKCVec_u64Z val_constr;
40516         val_constr.datalen = (*env)->GetArrayLength(env, val);
40517         if (val_constr.datalen > 0)
40518                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40519         else
40520                 val_constr.data = NULL;
40521         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40522         for (size_t g = 0; g < val_constr.datalen; g++) {
40523                 int64_t val_conv_6 = val_vals[g];
40524                 val_constr.data[g] = val_conv_6;
40525         }
40526         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40527         NodeInfo_set_channels(&this_ptr_conv, val_constr);
40528 }
40529
40530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
40531         LDKNodeInfo this_ptr_conv;
40532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40533         this_ptr_conv.is_owned = false;
40534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40535         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
40536         int64_t ret_ref = 0;
40537         if ((uintptr_t)ret_var.inner > 4096) {
40538                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40539                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40541                 ret_ref = (uintptr_t)ret_var.inner;
40542                 if (ret_var.is_owned) {
40543                         ret_ref |= 1;
40544                 }
40545         }
40546         return ret_ref;
40547 }
40548
40549 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) {
40550         LDKNodeInfo this_ptr_conv;
40551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40552         this_ptr_conv.is_owned = false;
40553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40554         LDKRoutingFees val_conv;
40555         val_conv.inner = (void*)(val & (~1));
40556         val_conv.is_owned = (val & 1) || (val == 0);
40557         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40558         val_conv = RoutingFees_clone(&val_conv);
40559         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
40560 }
40561
40562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
40563         LDKNodeInfo this_ptr_conv;
40564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40565         this_ptr_conv.is_owned = false;
40566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40567         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
40568         int64_t ret_ref = 0;
40569         if ((uintptr_t)ret_var.inner > 4096) {
40570                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40571                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40573                 ret_ref = (uintptr_t)ret_var.inner;
40574                 if (ret_var.is_owned) {
40575                         ret_ref |= 1;
40576                 }
40577         }
40578         return ret_ref;
40579 }
40580
40581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40582         LDKNodeInfo this_ptr_conv;
40583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40584         this_ptr_conv.is_owned = false;
40585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40586         LDKNodeAnnouncementInfo val_conv;
40587         val_conv.inner = (void*)(val & (~1));
40588         val_conv.is_owned = (val & 1) || (val == 0);
40589         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40590         val_conv = NodeAnnouncementInfo_clone(&val_conv);
40591         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
40592 }
40593
40594 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) {
40595         LDKCVec_u64Z channels_arg_constr;
40596         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
40597         if (channels_arg_constr.datalen > 0)
40598                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40599         else
40600                 channels_arg_constr.data = NULL;
40601         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
40602         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
40603                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
40604                 channels_arg_constr.data[g] = channels_arg_conv_6;
40605         }
40606         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
40607         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
40608         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
40609         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
40610         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
40611         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
40612         LDKNodeAnnouncementInfo announcement_info_arg_conv;
40613         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
40614         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
40615         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
40616         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
40617         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
40618         int64_t ret_ref = 0;
40619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40622         ret_ref = (uintptr_t)ret_var.inner;
40623         if (ret_var.is_owned) {
40624                 ret_ref |= 1;
40625         }
40626         return ret_ref;
40627 }
40628
40629 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
40630         LDKNodeInfo ret_var = NodeInfo_clone(arg);
40631 int64_t ret_ref = 0;
40632 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40633 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40634 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40635 ret_ref = (uintptr_t)ret_var.inner;
40636 if (ret_var.is_owned) {
40637         ret_ref |= 1;
40638 }
40639         return ret_ref;
40640 }
40641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40642         LDKNodeInfo arg_conv;
40643         arg_conv.inner = (void*)(arg & (~1));
40644         arg_conv.is_owned = false;
40645         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40646         int64_t ret_val = NodeInfo_clone_ptr(&arg_conv);
40647         return ret_val;
40648 }
40649
40650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40651         LDKNodeInfo orig_conv;
40652         orig_conv.inner = (void*)(orig & (~1));
40653         orig_conv.is_owned = false;
40654         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40655         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
40656         int64_t ret_ref = 0;
40657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40660         ret_ref = (uintptr_t)ret_var.inner;
40661         if (ret_var.is_owned) {
40662                 ret_ref |= 1;
40663         }
40664         return ret_ref;
40665 }
40666
40667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40668         LDKNodeInfo obj_conv;
40669         obj_conv.inner = (void*)(obj & (~1));
40670         obj_conv.is_owned = false;
40671         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40672         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
40673         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40674         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40675         CVec_u8Z_free(ret_var);
40676         return ret_arr;
40677 }
40678
40679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40680         LDKu8slice ser_ref;
40681         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40682         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40683         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
40684         *ret_conv = NodeInfo_read(ser_ref);
40685         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40686         return (int64_t)ret_conv;
40687 }
40688
40689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
40690         LDKNetworkGraph obj_conv;
40691         obj_conv.inner = (void*)(obj & (~1));
40692         obj_conv.is_owned = false;
40693         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40694         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
40695         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40696         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40697         CVec_u8Z_free(ret_var);
40698         return ret_arr;
40699 }
40700
40701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40702         LDKu8slice ser_ref;
40703         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40704         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40705         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
40706         *ret_conv = NetworkGraph_read(ser_ref);
40707         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40708         return (int64_t)ret_conv;
40709 }
40710
40711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
40712         LDKThirtyTwoBytes genesis_hash_ref;
40713         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
40714         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
40715         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
40716         int64_t ret_ref = 0;
40717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40720         ret_ref = (uintptr_t)ret_var.inner;
40721         if (ret_var.is_owned) {
40722                 ret_ref |= 1;
40723         }
40724         return ret_ref;
40725 }
40726
40727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
40728         LDKNetworkGraph this_arg_conv;
40729         this_arg_conv.inner = (void*)(this_arg & (~1));
40730         this_arg_conv.is_owned = false;
40731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40732         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
40733         int64_t ret_ref = 0;
40734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40737         ret_ref = (uintptr_t)ret_var.inner;
40738         if (ret_var.is_owned) {
40739                 ret_ref |= 1;
40740         }
40741         return ret_ref;
40742 }
40743
40744 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) {
40745         LDKNetworkGraph this_arg_conv;
40746         this_arg_conv.inner = (void*)(this_arg & (~1));
40747         this_arg_conv.is_owned = false;
40748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40749         LDKNodeAnnouncement msg_conv;
40750         msg_conv.inner = (void*)(msg & (~1));
40751         msg_conv.is_owned = false;
40752         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40753         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40754         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
40755         return (int64_t)ret_conv;
40756 }
40757
40758 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) {
40759         LDKNetworkGraph this_arg_conv;
40760         this_arg_conv.inner = (void*)(this_arg & (~1));
40761         this_arg_conv.is_owned = false;
40762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40763         LDKUnsignedNodeAnnouncement msg_conv;
40764         msg_conv.inner = (void*)(msg & (~1));
40765         msg_conv.is_owned = false;
40766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40767         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40768         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
40769         return (int64_t)ret_conv;
40770 }
40771
40772 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) {
40773         LDKNetworkGraph this_arg_conv;
40774         this_arg_conv.inner = (void*)(this_arg & (~1));
40775         this_arg_conv.is_owned = false;
40776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40777         LDKChannelAnnouncement msg_conv;
40778         msg_conv.inner = (void*)(msg & (~1));
40779         msg_conv.is_owned = false;
40780         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40781         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40782         CHECK_ACCESS(chain_access_ptr);
40783         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40784         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40785         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40786                 // Manually implement clone for Java trait instances
40787                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40788                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40789                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40790                 }
40791         }
40792         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40793         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40794         return (int64_t)ret_conv;
40795 }
40796
40797 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) {
40798         LDKNetworkGraph this_arg_conv;
40799         this_arg_conv.inner = (void*)(this_arg & (~1));
40800         this_arg_conv.is_owned = false;
40801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40802         LDKUnsignedChannelAnnouncement msg_conv;
40803         msg_conv.inner = (void*)(msg & (~1));
40804         msg_conv.is_owned = false;
40805         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40806         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40807         CHECK_ACCESS(chain_access_ptr);
40808         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40809         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40810         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40811                 // Manually implement clone for Java trait instances
40812                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40813                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40814                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40815                 }
40816         }
40817         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40818         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40819         return (int64_t)ret_conv;
40820 }
40821
40822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1from_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
40823         LDKNetworkGraph this_arg_conv;
40824         this_arg_conv.inner = (void*)(this_arg & (~1));
40825         this_arg_conv.is_owned = false;
40826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40827         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
40828 }
40829
40830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
40831         LDKNetworkGraph 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         LDKPublicKey _node_id_ref;
40836         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
40837         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
40838         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
40839 }
40840
40841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
40842         LDKNetworkGraph this_arg_conv;
40843         this_arg_conv.inner = (void*)(this_arg & (~1));
40844         this_arg_conv.is_owned = false;
40845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40846         NetworkGraph_remove_stale_channels(&this_arg_conv);
40847 }
40848
40849 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) {
40850         LDKNetworkGraph this_arg_conv;
40851         this_arg_conv.inner = (void*)(this_arg & (~1));
40852         this_arg_conv.is_owned = false;
40853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40854         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
40855 }
40856
40857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
40858         LDKNetworkGraph this_arg_conv;
40859         this_arg_conv.inner = (void*)(this_arg & (~1));
40860         this_arg_conv.is_owned = false;
40861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40862         LDKChannelUpdate msg_conv;
40863         msg_conv.inner = (void*)(msg & (~1));
40864         msg_conv.is_owned = false;
40865         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40866         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40867         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
40868         return (int64_t)ret_conv;
40869 }
40870
40871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
40872         LDKNetworkGraph this_arg_conv;
40873         this_arg_conv.inner = (void*)(this_arg & (~1));
40874         this_arg_conv.is_owned = false;
40875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40876         LDKUnsignedChannelUpdate msg_conv;
40877         msg_conv.inner = (void*)(msg & (~1));
40878         msg_conv.is_owned = false;
40879         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40880         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40881         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
40882         return (int64_t)ret_conv;
40883 }
40884
40885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
40886         LDKReadOnlyNetworkGraph this_arg_conv;
40887         this_arg_conv.inner = (void*)(this_arg & (~1));
40888         this_arg_conv.is_owned = false;
40889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40890         LDKPublicKey pubkey_ref;
40891         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
40892         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
40893         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
40894         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
40895         int64_t ret_ref = (uintptr_t)ret_copy;
40896         return ret_ref;
40897 }
40898
40899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40900         LDKRouteHop this_obj_conv;
40901         this_obj_conv.inner = (void*)(this_obj & (~1));
40902         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40904         RouteHop_free(this_obj_conv);
40905 }
40906
40907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
40908         LDKRouteHop this_ptr_conv;
40909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40910         this_ptr_conv.is_owned = false;
40911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40912         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40913         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
40914         return ret_arr;
40915 }
40916
40917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40918         LDKRouteHop this_ptr_conv;
40919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40920         this_ptr_conv.is_owned = false;
40921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40922         LDKPublicKey val_ref;
40923         CHECK((*env)->GetArrayLength(env, val) == 33);
40924         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40925         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
40926 }
40927
40928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40929         LDKRouteHop this_ptr_conv;
40930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40931         this_ptr_conv.is_owned = false;
40932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40933         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
40934         int64_t ret_ref = 0;
40935         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40936         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40938         ret_ref = (uintptr_t)ret_var.inner;
40939         if (ret_var.is_owned) {
40940                 ret_ref |= 1;
40941         }
40942         return ret_ref;
40943 }
40944
40945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40946         LDKRouteHop this_ptr_conv;
40947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40948         this_ptr_conv.is_owned = false;
40949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40950         LDKNodeFeatures val_conv;
40951         val_conv.inner = (void*)(val & (~1));
40952         val_conv.is_owned = (val & 1) || (val == 0);
40953         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40954         val_conv = NodeFeatures_clone(&val_conv);
40955         RouteHop_set_node_features(&this_ptr_conv, val_conv);
40956 }
40957
40958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
40959         LDKRouteHop this_ptr_conv;
40960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40961         this_ptr_conv.is_owned = false;
40962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40963         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
40964         return ret_val;
40965 }
40966
40967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40968         LDKRouteHop this_ptr_conv;
40969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40970         this_ptr_conv.is_owned = false;
40971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40972         RouteHop_set_short_channel_id(&this_ptr_conv, val);
40973 }
40974
40975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40976         LDKRouteHop this_ptr_conv;
40977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40978         this_ptr_conv.is_owned = false;
40979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40980         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
40981         int64_t ret_ref = 0;
40982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40985         ret_ref = (uintptr_t)ret_var.inner;
40986         if (ret_var.is_owned) {
40987                 ret_ref |= 1;
40988         }
40989         return ret_ref;
40990 }
40991
40992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40993         LDKRouteHop this_ptr_conv;
40994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40995         this_ptr_conv.is_owned = false;
40996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40997         LDKChannelFeatures val_conv;
40998         val_conv.inner = (void*)(val & (~1));
40999         val_conv.is_owned = (val & 1) || (val == 0);
41000         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41001         val_conv = ChannelFeatures_clone(&val_conv);
41002         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
41003 }
41004
41005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41006         LDKRouteHop this_ptr_conv;
41007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41008         this_ptr_conv.is_owned = false;
41009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41010         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
41011         return ret_val;
41012 }
41013
41014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41015         LDKRouteHop this_ptr_conv;
41016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41017         this_ptr_conv.is_owned = false;
41018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41019         RouteHop_set_fee_msat(&this_ptr_conv, val);
41020 }
41021
41022 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41023         LDKRouteHop this_ptr_conv;
41024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41025         this_ptr_conv.is_owned = false;
41026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41027         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
41028         return ret_val;
41029 }
41030
41031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
41032         LDKRouteHop this_ptr_conv;
41033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41034         this_ptr_conv.is_owned = false;
41035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41036         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41037 }
41038
41039 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) {
41040         LDKPublicKey pubkey_arg_ref;
41041         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
41042         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
41043         LDKNodeFeatures node_features_arg_conv;
41044         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
41045         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
41046         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
41047         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
41048         LDKChannelFeatures channel_features_arg_conv;
41049         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
41050         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
41051         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
41052         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
41053         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);
41054         int64_t ret_ref = 0;
41055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41058         ret_ref = (uintptr_t)ret_var.inner;
41059         if (ret_var.is_owned) {
41060                 ret_ref |= 1;
41061         }
41062         return ret_ref;
41063 }
41064
41065 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
41066         LDKRouteHop ret_var = RouteHop_clone(arg);
41067 int64_t ret_ref = 0;
41068 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41069 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41070 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41071 ret_ref = (uintptr_t)ret_var.inner;
41072 if (ret_var.is_owned) {
41073         ret_ref |= 1;
41074 }
41075         return ret_ref;
41076 }
41077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41078         LDKRouteHop arg_conv;
41079         arg_conv.inner = (void*)(arg & (~1));
41080         arg_conv.is_owned = false;
41081         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41082         int64_t ret_val = RouteHop_clone_ptr(&arg_conv);
41083         return ret_val;
41084 }
41085
41086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41087         LDKRouteHop orig_conv;
41088         orig_conv.inner = (void*)(orig & (~1));
41089         orig_conv.is_owned = false;
41090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41091         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
41092         int64_t ret_ref = 0;
41093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41096         ret_ref = (uintptr_t)ret_var.inner;
41097         if (ret_var.is_owned) {
41098                 ret_ref |= 1;
41099         }
41100         return ret_ref;
41101 }
41102
41103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
41104         LDKRouteHop o_conv;
41105         o_conv.inner = (void*)(o & (~1));
41106         o_conv.is_owned = false;
41107         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41108         int64_t ret_val = RouteHop_hash(&o_conv);
41109         return ret_val;
41110 }
41111
41112 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41113         LDKRouteHop a_conv;
41114         a_conv.inner = (void*)(a & (~1));
41115         a_conv.is_owned = false;
41116         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41117         LDKRouteHop b_conv;
41118         b_conv.inner = (void*)(b & (~1));
41119         b_conv.is_owned = false;
41120         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41121         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
41122         return ret_val;
41123 }
41124
41125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
41126         LDKRouteHop obj_conv;
41127         obj_conv.inner = (void*)(obj & (~1));
41128         obj_conv.is_owned = false;
41129         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41130         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
41131         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41132         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41133         CVec_u8Z_free(ret_var);
41134         return ret_arr;
41135 }
41136
41137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41138         LDKu8slice ser_ref;
41139         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41140         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41141         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
41142         *ret_conv = RouteHop_read(ser_ref);
41143         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41144         return (int64_t)ret_conv;
41145 }
41146
41147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41148         LDKRoute this_obj_conv;
41149         this_obj_conv.inner = (void*)(this_obj & (~1));
41150         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41152         Route_free(this_obj_conv);
41153 }
41154
41155 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
41156         LDKRoute this_ptr_conv;
41157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41158         this_ptr_conv.is_owned = false;
41159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41160         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
41161         jobjectArray ret_arr = NULL;
41162         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
41163         ;
41164         for (size_t m = 0; m < ret_var.datalen; m++) {
41165                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
41166                 int64_tArray ret_conv_12_arr = NULL;
41167                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
41168                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
41169                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
41170                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
41171                         int64_t ret_conv_12_conv_10_ref = 0;
41172                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41173                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41174                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
41175                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
41176                         if (ret_conv_12_conv_10_var.is_owned) {
41177                                 ret_conv_12_conv_10_ref |= 1;
41178                         }
41179                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
41180                 }
41181                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
41182                 FREE(ret_conv_12_var.data);
41183                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
41184         }
41185         
41186         FREE(ret_var.data);
41187         return ret_arr;
41188 }
41189
41190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
41191         LDKRoute this_ptr_conv;
41192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41193         this_ptr_conv.is_owned = false;
41194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41195         LDKCVec_CVec_RouteHopZZ val_constr;
41196         val_constr.datalen = (*env)->GetArrayLength(env, val);
41197         if (val_constr.datalen > 0)
41198                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41199         else
41200                 val_constr.data = NULL;
41201         for (size_t m = 0; m < val_constr.datalen; m++) {
41202                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
41203                 LDKCVec_RouteHopZ val_conv_12_constr;
41204                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
41205                 if (val_conv_12_constr.datalen > 0)
41206                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41207                 else
41208                         val_conv_12_constr.data = NULL;
41209                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
41210                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
41211                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
41212                         LDKRouteHop val_conv_12_conv_10_conv;
41213                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
41214                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
41215                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
41216                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
41217                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
41218                 }
41219                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
41220                 val_constr.data[m] = val_conv_12_constr;
41221         }
41222         Route_set_paths(&this_ptr_conv, val_constr);
41223 }
41224
41225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41226         LDKRoute this_ptr_conv;
41227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41228         this_ptr_conv.is_owned = false;
41229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41230         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
41231         int64_t ret_ref = 0;
41232         if ((uintptr_t)ret_var.inner > 4096) {
41233                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41234                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41236                 ret_ref = (uintptr_t)ret_var.inner;
41237                 if (ret_var.is_owned) {
41238                         ret_ref |= 1;
41239                 }
41240         }
41241         return ret_ref;
41242 }
41243
41244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41245         LDKRoute this_ptr_conv;
41246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41247         this_ptr_conv.is_owned = false;
41248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41249         LDKPaymentParameters val_conv;
41250         val_conv.inner = (void*)(val & (~1));
41251         val_conv.is_owned = (val & 1) || (val == 0);
41252         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41253         val_conv = PaymentParameters_clone(&val_conv);
41254         Route_set_payment_params(&this_ptr_conv, val_conv);
41255 }
41256
41257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
41258         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
41259         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
41260         if (paths_arg_constr.datalen > 0)
41261                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41262         else
41263                 paths_arg_constr.data = NULL;
41264         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
41265                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
41266                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
41267                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
41268                 if (paths_arg_conv_12_constr.datalen > 0)
41269                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41270                 else
41271                         paths_arg_conv_12_constr.data = NULL;
41272                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
41273                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
41274                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
41275                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
41276                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
41277                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
41278                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
41279                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
41280                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
41281                 }
41282                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
41283                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
41284         }
41285         LDKPaymentParameters payment_params_arg_conv;
41286         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41287         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41288         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41289         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41290         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
41291         int64_t ret_ref = 0;
41292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41295         ret_ref = (uintptr_t)ret_var.inner;
41296         if (ret_var.is_owned) {
41297                 ret_ref |= 1;
41298         }
41299         return ret_ref;
41300 }
41301
41302 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
41303         LDKRoute ret_var = Route_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41315         LDKRoute arg_conv;
41316         arg_conv.inner = (void*)(arg & (~1));
41317         arg_conv.is_owned = false;
41318         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41319         int64_t ret_val = Route_clone_ptr(&arg_conv);
41320         return ret_val;
41321 }
41322
41323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41324         LDKRoute orig_conv;
41325         orig_conv.inner = (void*)(orig & (~1));
41326         orig_conv.is_owned = false;
41327         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41328         LDKRoute ret_var = Route_clone(&orig_conv);
41329         int64_t ret_ref = 0;
41330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41333         ret_ref = (uintptr_t)ret_var.inner;
41334         if (ret_var.is_owned) {
41335                 ret_ref |= 1;
41336         }
41337         return ret_ref;
41338 }
41339
41340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
41341         LDKRoute o_conv;
41342         o_conv.inner = (void*)(o & (~1));
41343         o_conv.is_owned = false;
41344         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41345         int64_t ret_val = Route_hash(&o_conv);
41346         return ret_val;
41347 }
41348
41349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41350         LDKRoute a_conv;
41351         a_conv.inner = (void*)(a & (~1));
41352         a_conv.is_owned = false;
41353         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41354         LDKRoute b_conv;
41355         b_conv.inner = (void*)(b & (~1));
41356         b_conv.is_owned = false;
41357         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41358         jboolean ret_val = Route_eq(&a_conv, &b_conv);
41359         return ret_val;
41360 }
41361
41362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
41363         LDKRoute this_arg_conv;
41364         this_arg_conv.inner = (void*)(this_arg & (~1));
41365         this_arg_conv.is_owned = false;
41366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41367         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
41368         return ret_val;
41369 }
41370
41371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
41372         LDKRoute this_arg_conv;
41373         this_arg_conv.inner = (void*)(this_arg & (~1));
41374         this_arg_conv.is_owned = false;
41375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41376         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
41377         return ret_val;
41378 }
41379
41380 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
41381         LDKRoute obj_conv;
41382         obj_conv.inner = (void*)(obj & (~1));
41383         obj_conv.is_owned = false;
41384         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41385         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
41386         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41387         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41388         CVec_u8Z_free(ret_var);
41389         return ret_arr;
41390 }
41391
41392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41393         LDKu8slice ser_ref;
41394         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41395         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41396         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
41397         *ret_conv = Route_read(ser_ref);
41398         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41399         return (int64_t)ret_conv;
41400 }
41401
41402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41403         LDKRouteParameters this_obj_conv;
41404         this_obj_conv.inner = (void*)(this_obj & (~1));
41405         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41407         RouteParameters_free(this_obj_conv);
41408 }
41409
41410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41411         LDKRouteParameters this_ptr_conv;
41412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41413         this_ptr_conv.is_owned = false;
41414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41415         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
41416         int64_t ret_ref = 0;
41417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41420         ret_ref = (uintptr_t)ret_var.inner;
41421         if (ret_var.is_owned) {
41422                 ret_ref |= 1;
41423         }
41424         return ret_ref;
41425 }
41426
41427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41428         LDKRouteParameters this_ptr_conv;
41429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41430         this_ptr_conv.is_owned = false;
41431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41432         LDKPaymentParameters val_conv;
41433         val_conv.inner = (void*)(val & (~1));
41434         val_conv.is_owned = (val & 1) || (val == 0);
41435         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41436         val_conv = PaymentParameters_clone(&val_conv);
41437         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
41438 }
41439
41440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41441         LDKRouteParameters this_ptr_conv;
41442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41443         this_ptr_conv.is_owned = false;
41444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41445         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
41446         return ret_val;
41447 }
41448
41449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41450         LDKRouteParameters this_ptr_conv;
41451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41452         this_ptr_conv.is_owned = false;
41453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41454         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
41455 }
41456
41457 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41458         LDKRouteParameters this_ptr_conv;
41459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41460         this_ptr_conv.is_owned = false;
41461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41462         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
41463         return ret_val;
41464 }
41465
41466 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) {
41467         LDKRouteParameters this_ptr_conv;
41468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41469         this_ptr_conv.is_owned = false;
41470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41471         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
41472 }
41473
41474 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) {
41475         LDKPaymentParameters payment_params_arg_conv;
41476         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41477         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41478         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41479         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41480         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
41481         int64_t ret_ref = 0;
41482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41485         ret_ref = (uintptr_t)ret_var.inner;
41486         if (ret_var.is_owned) {
41487                 ret_ref |= 1;
41488         }
41489         return ret_ref;
41490 }
41491
41492 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
41493         LDKRouteParameters ret_var = RouteParameters_clone(arg);
41494 int64_t ret_ref = 0;
41495 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41496 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41497 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41498 ret_ref = (uintptr_t)ret_var.inner;
41499 if (ret_var.is_owned) {
41500         ret_ref |= 1;
41501 }
41502         return ret_ref;
41503 }
41504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41505         LDKRouteParameters arg_conv;
41506         arg_conv.inner = (void*)(arg & (~1));
41507         arg_conv.is_owned = false;
41508         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41509         int64_t ret_val = RouteParameters_clone_ptr(&arg_conv);
41510         return ret_val;
41511 }
41512
41513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41514         LDKRouteParameters orig_conv;
41515         orig_conv.inner = (void*)(orig & (~1));
41516         orig_conv.is_owned = false;
41517         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41518         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
41519         int64_t ret_ref = 0;
41520         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41521         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41523         ret_ref = (uintptr_t)ret_var.inner;
41524         if (ret_var.is_owned) {
41525                 ret_ref |= 1;
41526         }
41527         return ret_ref;
41528 }
41529
41530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
41531         LDKRouteParameters obj_conv;
41532         obj_conv.inner = (void*)(obj & (~1));
41533         obj_conv.is_owned = false;
41534         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41535         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
41536         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41537         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41538         CVec_u8Z_free(ret_var);
41539         return ret_arr;
41540 }
41541
41542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41543         LDKu8slice ser_ref;
41544         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41545         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41546         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
41547         *ret_conv = RouteParameters_read(ser_ref);
41548         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41549         return (int64_t)ret_conv;
41550 }
41551
41552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41553         LDKPaymentParameters this_obj_conv;
41554         this_obj_conv.inner = (void*)(this_obj & (~1));
41555         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41557         PaymentParameters_free(this_obj_conv);
41558 }
41559
41560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
41561         LDKPaymentParameters this_ptr_conv;
41562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41563         this_ptr_conv.is_owned = false;
41564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41565         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41566         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
41567         return ret_arr;
41568 }
41569
41570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41571         LDKPaymentParameters this_ptr_conv;
41572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41573         this_ptr_conv.is_owned = false;
41574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41575         LDKPublicKey val_ref;
41576         CHECK((*env)->GetArrayLength(env, val) == 33);
41577         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41578         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
41579 }
41580
41581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
41582         LDKPaymentParameters this_ptr_conv;
41583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41584         this_ptr_conv.is_owned = false;
41585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41586         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
41587         int64_t ret_ref = 0;
41588         if ((uintptr_t)ret_var.inner > 4096) {
41589                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41590                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41592                 ret_ref = (uintptr_t)ret_var.inner;
41593                 if (ret_var.is_owned) {
41594                         ret_ref |= 1;
41595                 }
41596         }
41597         return ret_ref;
41598 }
41599
41600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41601         LDKPaymentParameters this_ptr_conv;
41602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41603         this_ptr_conv.is_owned = false;
41604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41605         LDKInvoiceFeatures val_conv;
41606         val_conv.inner = (void*)(val & (~1));
41607         val_conv.is_owned = (val & 1) || (val == 0);
41608         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41609         val_conv = InvoiceFeatures_clone(&val_conv);
41610         PaymentParameters_set_features(&this_ptr_conv, val_conv);
41611 }
41612
41613 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
41614         LDKPaymentParameters this_ptr_conv;
41615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41616         this_ptr_conv.is_owned = false;
41617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41618         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
41619         int64_tArray ret_arr = NULL;
41620         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41621         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41622         for (size_t l = 0; l < ret_var.datalen; l++) {
41623                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41624                 int64_t ret_conv_11_ref = 0;
41625                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41626                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41627                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41628                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
41629                 if (ret_conv_11_var.is_owned) {
41630                         ret_conv_11_ref |= 1;
41631                 }
41632                 ret_arr_ptr[l] = ret_conv_11_ref;
41633         }
41634         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
41635         FREE(ret_var.data);
41636         return ret_arr;
41637 }
41638
41639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
41640         LDKPaymentParameters this_ptr_conv;
41641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41642         this_ptr_conv.is_owned = false;
41643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41644         LDKCVec_RouteHintZ val_constr;
41645         val_constr.datalen = (*env)->GetArrayLength(env, val);
41646         if (val_constr.datalen > 0)
41647                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41648         else
41649                 val_constr.data = NULL;
41650         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
41651         for (size_t l = 0; l < val_constr.datalen; l++) {
41652                 int64_t val_conv_11 = val_vals[l];
41653                 LDKRouteHint val_conv_11_conv;
41654                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
41655                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
41656                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
41657                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
41658                 val_constr.data[l] = val_conv_11_conv;
41659         }
41660         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
41661         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
41662 }
41663
41664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
41665         LDKPaymentParameters this_ptr_conv;
41666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41667         this_ptr_conv.is_owned = false;
41668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41669         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41670         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
41671         int64_t ret_ref = (uintptr_t)ret_copy;
41672         return ret_ref;
41673 }
41674
41675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41676         LDKPaymentParameters this_ptr_conv;
41677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41678         this_ptr_conv.is_owned = false;
41679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41680         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41681         CHECK_ACCESS(val_ptr);
41682         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41683         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41684         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
41685 }
41686
41687 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41688         LDKPaymentParameters this_ptr_conv;
41689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41690         this_ptr_conv.is_owned = false;
41691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41692         int32_t ret_val = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
41693         return ret_val;
41694 }
41695
41696 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) {
41697         LDKPaymentParameters this_ptr_conv;
41698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41699         this_ptr_conv.is_owned = false;
41700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41701         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
41702 }
41703
41704 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) {
41705         LDKPublicKey payee_pubkey_arg_ref;
41706         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
41707         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
41708         LDKInvoiceFeatures features_arg_conv;
41709         features_arg_conv.inner = (void*)(features_arg & (~1));
41710         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
41711         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
41712         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
41713         LDKCVec_RouteHintZ route_hints_arg_constr;
41714         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
41715         if (route_hints_arg_constr.datalen > 0)
41716                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41717         else
41718                 route_hints_arg_constr.data = NULL;
41719         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
41720         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
41721                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
41722                 LDKRouteHint route_hints_arg_conv_11_conv;
41723                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
41724                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
41725                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
41726                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
41727                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
41728         }
41729         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
41730         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
41731         CHECK_ACCESS(expiry_time_arg_ptr);
41732         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
41733         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
41734         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);
41735         int64_t ret_ref = 0;
41736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41739         ret_ref = (uintptr_t)ret_var.inner;
41740         if (ret_var.is_owned) {
41741                 ret_ref |= 1;
41742         }
41743         return ret_ref;
41744 }
41745
41746 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
41747         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
41748 int64_t ret_ref = 0;
41749 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41750 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41751 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41752 ret_ref = (uintptr_t)ret_var.inner;
41753 if (ret_var.is_owned) {
41754         ret_ref |= 1;
41755 }
41756         return ret_ref;
41757 }
41758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41759         LDKPaymentParameters arg_conv;
41760         arg_conv.inner = (void*)(arg & (~1));
41761         arg_conv.is_owned = false;
41762         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41763         int64_t ret_val = PaymentParameters_clone_ptr(&arg_conv);
41764         return ret_val;
41765 }
41766
41767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41768         LDKPaymentParameters orig_conv;
41769         orig_conv.inner = (void*)(orig & (~1));
41770         orig_conv.is_owned = false;
41771         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41772         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
41773         int64_t ret_ref = 0;
41774         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41775         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41777         ret_ref = (uintptr_t)ret_var.inner;
41778         if (ret_var.is_owned) {
41779                 ret_ref |= 1;
41780         }
41781         return ret_ref;
41782 }
41783
41784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
41785         LDKPaymentParameters o_conv;
41786         o_conv.inner = (void*)(o & (~1));
41787         o_conv.is_owned = false;
41788         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41789         int64_t ret_val = PaymentParameters_hash(&o_conv);
41790         return ret_val;
41791 }
41792
41793 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41794         LDKPaymentParameters a_conv;
41795         a_conv.inner = (void*)(a & (~1));
41796         a_conv.is_owned = false;
41797         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41798         LDKPaymentParameters b_conv;
41799         b_conv.inner = (void*)(b & (~1));
41800         b_conv.is_owned = false;
41801         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41802         jboolean ret_val = PaymentParameters_eq(&a_conv, &b_conv);
41803         return ret_val;
41804 }
41805
41806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
41807         LDKPaymentParameters obj_conv;
41808         obj_conv.inner = (void*)(obj & (~1));
41809         obj_conv.is_owned = false;
41810         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41811         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
41812         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41813         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41814         CVec_u8Z_free(ret_var);
41815         return ret_arr;
41816 }
41817
41818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41819         LDKu8slice ser_ref;
41820         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41821         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41822         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
41823         *ret_conv = PaymentParameters_read(ser_ref);
41824         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41825         return (int64_t)ret_conv;
41826 }
41827
41828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
41829         LDKPublicKey payee_pubkey_ref;
41830         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
41831         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
41832         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
41833         int64_t ret_ref = 0;
41834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41837         ret_ref = (uintptr_t)ret_var.inner;
41838         if (ret_var.is_owned) {
41839                 ret_ref |= 1;
41840         }
41841         return ret_ref;
41842 }
41843
41844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
41845         LDKPublicKey payee_pubkey_ref;
41846         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
41847         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
41848         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
41849         int64_t ret_ref = 0;
41850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41853         ret_ref = (uintptr_t)ret_var.inner;
41854         if (ret_var.is_owned) {
41855                 ret_ref |= 1;
41856         }
41857         return ret_ref;
41858 }
41859
41860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41861         LDKRouteHint this_obj_conv;
41862         this_obj_conv.inner = (void*)(this_obj & (~1));
41863         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41865         RouteHint_free(this_obj_conv);
41866 }
41867
41868 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
41869         LDKRouteHint this_ptr_conv;
41870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41871         this_ptr_conv.is_owned = false;
41872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41873         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
41874         int64_tArray ret_arr = NULL;
41875         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41876         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41877         for (size_t o = 0; o < ret_var.datalen; o++) {
41878                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
41879                 int64_t ret_conv_14_ref = 0;
41880                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41881                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41882                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41883                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41884                 if (ret_conv_14_var.is_owned) {
41885                         ret_conv_14_ref |= 1;
41886                 }
41887                 ret_arr_ptr[o] = ret_conv_14_ref;
41888         }
41889         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
41890         FREE(ret_var.data);
41891         return ret_arr;
41892 }
41893
41894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
41895         LDKRouteHint this_ptr_conv;
41896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41897         this_ptr_conv.is_owned = false;
41898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41899         LDKCVec_RouteHintHopZ val_constr;
41900         val_constr.datalen = (*env)->GetArrayLength(env, val);
41901         if (val_constr.datalen > 0)
41902                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
41903         else
41904                 val_constr.data = NULL;
41905         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
41906         for (size_t o = 0; o < val_constr.datalen; o++) {
41907                 int64_t val_conv_14 = val_vals[o];
41908                 LDKRouteHintHop val_conv_14_conv;
41909                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
41910                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
41911                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
41912                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
41913                 val_constr.data[o] = val_conv_14_conv;
41914         }
41915         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
41916         RouteHint_set_a(&this_ptr_conv, val_constr);
41917 }
41918
41919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
41920         LDKCVec_RouteHintHopZ a_arg_constr;
41921         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
41922         if (a_arg_constr.datalen > 0)
41923                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
41924         else
41925                 a_arg_constr.data = NULL;
41926         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
41927         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
41928                 int64_t a_arg_conv_14 = a_arg_vals[o];
41929                 LDKRouteHintHop a_arg_conv_14_conv;
41930                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
41931                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
41932                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
41933                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
41934                 a_arg_constr.data[o] = a_arg_conv_14_conv;
41935         }
41936         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
41937         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
41938         int64_t ret_ref = 0;
41939         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41940         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41942         ret_ref = (uintptr_t)ret_var.inner;
41943         if (ret_var.is_owned) {
41944                 ret_ref |= 1;
41945         }
41946         return ret_ref;
41947 }
41948
41949 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
41950         LDKRouteHint ret_var = RouteHint_clone(arg);
41951 int64_t ret_ref = 0;
41952 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41953 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41954 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41955 ret_ref = (uintptr_t)ret_var.inner;
41956 if (ret_var.is_owned) {
41957         ret_ref |= 1;
41958 }
41959         return ret_ref;
41960 }
41961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41962         LDKRouteHint arg_conv;
41963         arg_conv.inner = (void*)(arg & (~1));
41964         arg_conv.is_owned = false;
41965         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41966         int64_t ret_val = RouteHint_clone_ptr(&arg_conv);
41967         return ret_val;
41968 }
41969
41970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41971         LDKRouteHint orig_conv;
41972         orig_conv.inner = (void*)(orig & (~1));
41973         orig_conv.is_owned = false;
41974         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41975         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
41976         int64_t ret_ref = 0;
41977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41980         ret_ref = (uintptr_t)ret_var.inner;
41981         if (ret_var.is_owned) {
41982                 ret_ref |= 1;
41983         }
41984         return ret_ref;
41985 }
41986
41987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
41988         LDKRouteHint o_conv;
41989         o_conv.inner = (void*)(o & (~1));
41990         o_conv.is_owned = false;
41991         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41992         int64_t ret_val = RouteHint_hash(&o_conv);
41993         return ret_val;
41994 }
41995
41996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41997         LDKRouteHint a_conv;
41998         a_conv.inner = (void*)(a & (~1));
41999         a_conv.is_owned = false;
42000         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42001         LDKRouteHint b_conv;
42002         b_conv.inner = (void*)(b & (~1));
42003         b_conv.is_owned = false;
42004         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42005         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
42006         return ret_val;
42007 }
42008
42009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
42010         LDKRouteHint obj_conv;
42011         obj_conv.inner = (void*)(obj & (~1));
42012         obj_conv.is_owned = false;
42013         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42014         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
42015         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42016         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42017         CVec_u8Z_free(ret_var);
42018         return ret_arr;
42019 }
42020
42021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42022         LDKu8slice ser_ref;
42023         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42024         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42025         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
42026         *ret_conv = RouteHint_read(ser_ref);
42027         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42028         return (int64_t)ret_conv;
42029 }
42030
42031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42032         LDKRouteHintHop this_obj_conv;
42033         this_obj_conv.inner = (void*)(this_obj & (~1));
42034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42036         RouteHintHop_free(this_obj_conv);
42037 }
42038
42039 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
42040         LDKRouteHintHop this_ptr_conv;
42041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42042         this_ptr_conv.is_owned = false;
42043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42044         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42045         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
42046         return ret_arr;
42047 }
42048
42049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42050         LDKRouteHintHop this_ptr_conv;
42051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42052         this_ptr_conv.is_owned = false;
42053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42054         LDKPublicKey val_ref;
42055         CHECK((*env)->GetArrayLength(env, val) == 33);
42056         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42057         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
42058 }
42059
42060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
42061         LDKRouteHintHop this_ptr_conv;
42062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42063         this_ptr_conv.is_owned = false;
42064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42065         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
42066         return ret_val;
42067 }
42068
42069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42070         LDKRouteHintHop this_ptr_conv;
42071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42072         this_ptr_conv.is_owned = false;
42073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42074         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
42075 }
42076
42077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
42078         LDKRouteHintHop this_ptr_conv;
42079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42080         this_ptr_conv.is_owned = false;
42081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42082         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
42083         int64_t ret_ref = 0;
42084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42087         ret_ref = (uintptr_t)ret_var.inner;
42088         if (ret_var.is_owned) {
42089                 ret_ref |= 1;
42090         }
42091         return ret_ref;
42092 }
42093
42094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42095         LDKRouteHintHop this_ptr_conv;
42096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42097         this_ptr_conv.is_owned = false;
42098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42099         LDKRoutingFees val_conv;
42100         val_conv.inner = (void*)(val & (~1));
42101         val_conv.is_owned = (val & 1) || (val == 0);
42102         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42103         val_conv = RoutingFees_clone(&val_conv);
42104         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
42105 }
42106
42107 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42108         LDKRouteHintHop this_ptr_conv;
42109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42110         this_ptr_conv.is_owned = false;
42111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42112         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
42113         return ret_val;
42114 }
42115
42116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42117         LDKRouteHintHop this_ptr_conv;
42118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42119         this_ptr_conv.is_owned = false;
42120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42121         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
42122 }
42123
42124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42125         LDKRouteHintHop this_ptr_conv;
42126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42127         this_ptr_conv.is_owned = false;
42128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42129         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42130         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
42131         int64_t ret_ref = (uintptr_t)ret_copy;
42132         return ret_ref;
42133 }
42134
42135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42136         LDKRouteHintHop this_ptr_conv;
42137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42138         this_ptr_conv.is_owned = false;
42139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42140         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42141         CHECK_ACCESS(val_ptr);
42142         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42143         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42144         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
42145 }
42146
42147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42148         LDKRouteHintHop this_ptr_conv;
42149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42150         this_ptr_conv.is_owned = false;
42151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42152         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42153         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
42154         int64_t ret_ref = (uintptr_t)ret_copy;
42155         return ret_ref;
42156 }
42157
42158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42159         LDKRouteHintHop this_ptr_conv;
42160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42161         this_ptr_conv.is_owned = false;
42162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42163         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42164         CHECK_ACCESS(val_ptr);
42165         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42166         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42167         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42168 }
42169
42170 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) {
42171         LDKPublicKey src_node_id_arg_ref;
42172         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
42173         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
42174         LDKRoutingFees fees_arg_conv;
42175         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42176         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42177         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42178         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42179         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
42180         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
42181         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
42182         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
42183         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42184         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42185         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42186         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42187         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);
42188         int64_t ret_ref = 0;
42189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42192         ret_ref = (uintptr_t)ret_var.inner;
42193         if (ret_var.is_owned) {
42194                 ret_ref |= 1;
42195         }
42196         return ret_ref;
42197 }
42198
42199 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
42200         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
42201 int64_t ret_ref = 0;
42202 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42203 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42204 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42205 ret_ref = (uintptr_t)ret_var.inner;
42206 if (ret_var.is_owned) {
42207         ret_ref |= 1;
42208 }
42209         return ret_ref;
42210 }
42211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42212         LDKRouteHintHop arg_conv;
42213         arg_conv.inner = (void*)(arg & (~1));
42214         arg_conv.is_owned = false;
42215         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42216         int64_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
42217         return ret_val;
42218 }
42219
42220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42221         LDKRouteHintHop orig_conv;
42222         orig_conv.inner = (void*)(orig & (~1));
42223         orig_conv.is_owned = false;
42224         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42225         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
42226         int64_t ret_ref = 0;
42227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42230         ret_ref = (uintptr_t)ret_var.inner;
42231         if (ret_var.is_owned) {
42232                 ret_ref |= 1;
42233         }
42234         return ret_ref;
42235 }
42236
42237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
42238         LDKRouteHintHop o_conv;
42239         o_conv.inner = (void*)(o & (~1));
42240         o_conv.is_owned = false;
42241         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42242         int64_t ret_val = RouteHintHop_hash(&o_conv);
42243         return ret_val;
42244 }
42245
42246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42247         LDKRouteHintHop a_conv;
42248         a_conv.inner = (void*)(a & (~1));
42249         a_conv.is_owned = false;
42250         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42251         LDKRouteHintHop b_conv;
42252         b_conv.inner = (void*)(b & (~1));
42253         b_conv.is_owned = false;
42254         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42255         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
42256         return ret_val;
42257 }
42258
42259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
42260         LDKRouteHintHop obj_conv;
42261         obj_conv.inner = (void*)(obj & (~1));
42262         obj_conv.is_owned = false;
42263         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42264         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
42265         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42266         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42267         CVec_u8Z_free(ret_var);
42268         return ret_arr;
42269 }
42270
42271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42272         LDKu8slice ser_ref;
42273         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42274         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42275         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
42276         *ret_conv = RouteHintHop_read(ser_ref);
42277         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42278         return (int64_t)ret_conv;
42279 }
42280
42281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer) {
42282         LDKPublicKey our_node_pubkey_ref;
42283         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
42284         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
42285         LDKRouteParameters route_params_conv;
42286         route_params_conv.inner = (void*)(route_params & (~1));
42287         route_params_conv.is_owned = false;
42288         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42289         LDKNetworkGraph network_conv;
42290         network_conv.inner = (void*)(network & (~1));
42291         network_conv.is_owned = false;
42292         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
42293         LDKCVec_ChannelDetailsZ first_hops_constr;
42294         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
42295         if (first_hops != NULL) {
42296                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
42297                 if (first_hops_constr.datalen > 0)
42298                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
42299                 else
42300                         first_hops_constr.data = NULL;
42301                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
42302                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
42303                         int64_t first_hops_conv_16 = first_hops_vals[q];
42304                         LDKChannelDetails first_hops_conv_16_conv;
42305                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
42306                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
42307                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
42308                         first_hops_constr.data[q] = first_hops_conv_16_conv;
42309                 }
42310                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
42311                 first_hops_ptr = &first_hops_constr;
42312         }
42313         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42314         CHECK_ACCESS(logger_ptr);
42315         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42316         if (logger_conv.free == LDKLogger_JCalls_free) {
42317                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42318                 LDKLogger_JCalls_cloned(&logger_conv);
42319         }
42320         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
42321         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
42322         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
42323         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42324         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
42325         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
42326         return (int64_t)ret_conv;
42327 }
42328
42329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42330         if ((this_ptr & 1) != 0) return;
42331         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42332         CHECK_ACCESS(this_ptr_ptr);
42333         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
42334         FREE((void*)this_ptr);
42335         Score_free(this_ptr_conv);
42336 }
42337
42338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42339         if ((this_ptr & 1) != 0) return;
42340         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42341         CHECK_ACCESS(this_ptr_ptr);
42342         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
42343         FREE((void*)this_ptr);
42344         LockableScore_free(this_ptr_conv);
42345 }
42346
42347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42348         LDKMultiThreadedLockableScore this_obj_conv;
42349         this_obj_conv.inner = (void*)(this_obj & (~1));
42350         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42352         MultiThreadedLockableScore_free(this_obj_conv);
42353 }
42354
42355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
42356         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
42357         CHECK_ACCESS(score_ptr);
42358         LDKScore score_conv = *(LDKScore*)(score_ptr);
42359         if (score_conv.free == LDKScore_JCalls_free) {
42360                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42361                 LDKScore_JCalls_cloned(&score_conv);
42362         }
42363         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
42364         int64_t ret_ref = 0;
42365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42368         ret_ref = (uintptr_t)ret_var.inner;
42369         if (ret_var.is_owned) {
42370                 ret_ref |= 1;
42371         }
42372         return ret_ref;
42373 }
42374
42375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42376         LDKFixedPenaltyScorer this_obj_conv;
42377         this_obj_conv.inner = (void*)(this_obj & (~1));
42378         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42380         FixedPenaltyScorer_free(this_obj_conv);
42381 }
42382
42383 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
42384         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
42385 int64_t ret_ref = 0;
42386 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42387 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42388 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42389 ret_ref = (uintptr_t)ret_var.inner;
42390 if (ret_var.is_owned) {
42391         ret_ref |= 1;
42392 }
42393         return ret_ref;
42394 }
42395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42396         LDKFixedPenaltyScorer arg_conv;
42397         arg_conv.inner = (void*)(arg & (~1));
42398         arg_conv.is_owned = false;
42399         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42400         int64_t ret_val = FixedPenaltyScorer_clone_ptr(&arg_conv);
42401         return ret_val;
42402 }
42403
42404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42405         LDKFixedPenaltyScorer orig_conv;
42406         orig_conv.inner = (void*)(orig & (~1));
42407         orig_conv.is_owned = false;
42408         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42409         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
42410         int64_t ret_ref = 0;
42411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42414         ret_ref = (uintptr_t)ret_var.inner;
42415         if (ret_var.is_owned) {
42416                 ret_ref |= 1;
42417         }
42418         return ret_ref;
42419 }
42420
42421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
42422         LDKFixedPenaltyScorer obj_conv;
42423         obj_conv.inner = (void*)(obj & (~1));
42424         obj_conv.is_owned = false;
42425         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42426         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
42427         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42428         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42429         CVec_u8Z_free(ret_var);
42430         return ret_arr;
42431 }
42432
42433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42434         LDKu8slice ser_ref;
42435         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42436         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42437         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
42438         *ret_conv = FixedPenaltyScorer_read(ser_ref);
42439         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42440         return (int64_t)ret_conv;
42441 }
42442
42443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
42444         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
42445         int64_t ret_ref = 0;
42446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42449         ret_ref = (uintptr_t)ret_var.inner;
42450         if (ret_var.is_owned) {
42451                 ret_ref |= 1;
42452         }
42453         return ret_ref;
42454 }
42455
42456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
42457         LDKFixedPenaltyScorer this_arg_conv;
42458         this_arg_conv.inner = (void*)(this_arg & (~1));
42459         this_arg_conv.is_owned = false;
42460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42461         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42462         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
42463         return (int64_t)ret_ret;
42464 }
42465
42466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42467         LDKScorer this_obj_conv;
42468         this_obj_conv.inner = (void*)(this_obj & (~1));
42469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42471         Scorer_free(this_obj_conv);
42472 }
42473
42474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42475         LDKScoringParameters this_obj_conv;
42476         this_obj_conv.inner = (void*)(this_obj & (~1));
42477         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42479         ScoringParameters_free(this_obj_conv);
42480 }
42481
42482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42483         LDKScoringParameters this_ptr_conv;
42484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42485         this_ptr_conv.is_owned = false;
42486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42487         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
42488         return ret_val;
42489 }
42490
42491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42492         LDKScoringParameters this_ptr_conv;
42493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42494         this_ptr_conv.is_owned = false;
42495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42496         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
42497 }
42498
42499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42500         LDKScoringParameters this_ptr_conv;
42501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42502         this_ptr_conv.is_owned = false;
42503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42504         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
42505         return ret_val;
42506 }
42507
42508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42509         LDKScoringParameters this_ptr_conv;
42510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42511         this_ptr_conv.is_owned = false;
42512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42513         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
42514 }
42515
42516 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
42517         LDKScoringParameters this_ptr_conv;
42518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42519         this_ptr_conv.is_owned = false;
42520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42521         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
42522         return ret_val;
42523 }
42524
42525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42526         LDKScoringParameters this_ptr_conv;
42527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42528         this_ptr_conv.is_owned = false;
42529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42530         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
42531 }
42532
42533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
42534         LDKScoringParameters this_ptr_conv;
42535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42536         this_ptr_conv.is_owned = false;
42537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42538         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
42539         return ret_val;
42540 }
42541
42542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42543         LDKScoringParameters this_ptr_conv;
42544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42545         this_ptr_conv.is_owned = false;
42546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42547         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
42548 }
42549
42550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
42551         LDKScoringParameters this_ptr_conv;
42552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42553         this_ptr_conv.is_owned = false;
42554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42555         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
42556         return ret_val;
42557 }
42558
42559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42560         LDKScoringParameters this_ptr_conv;
42561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42562         this_ptr_conv.is_owned = false;
42563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42564         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
42565 }
42566
42567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int16_t overuse_penalty_start_1024th_arg, int64_t overuse_penalty_msat_per_1024th_arg, int64_t failure_penalty_half_life_arg) {
42568         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, overuse_penalty_start_1024th_arg, overuse_penalty_msat_per_1024th_arg, failure_penalty_half_life_arg);
42569         int64_t ret_ref = 0;
42570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42573         ret_ref = (uintptr_t)ret_var.inner;
42574         if (ret_var.is_owned) {
42575                 ret_ref |= 1;
42576         }
42577         return ret_ref;
42578 }
42579
42580 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
42581         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
42582 int64_t ret_ref = 0;
42583 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42584 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42585 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42586 ret_ref = (uintptr_t)ret_var.inner;
42587 if (ret_var.is_owned) {
42588         ret_ref |= 1;
42589 }
42590         return ret_ref;
42591 }
42592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42593         LDKScoringParameters arg_conv;
42594         arg_conv.inner = (void*)(arg & (~1));
42595         arg_conv.is_owned = false;
42596         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42597         int64_t ret_val = ScoringParameters_clone_ptr(&arg_conv);
42598         return ret_val;
42599 }
42600
42601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42602         LDKScoringParameters orig_conv;
42603         orig_conv.inner = (void*)(orig & (~1));
42604         orig_conv.is_owned = false;
42605         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42606         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
42607         int64_t ret_ref = 0;
42608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42611         ret_ref = (uintptr_t)ret_var.inner;
42612         if (ret_var.is_owned) {
42613                 ret_ref |= 1;
42614         }
42615         return ret_ref;
42616 }
42617
42618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42619         LDKScoringParameters obj_conv;
42620         obj_conv.inner = (void*)(obj & (~1));
42621         obj_conv.is_owned = false;
42622         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42623         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
42624         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42625         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42626         CVec_u8Z_free(ret_var);
42627         return ret_arr;
42628 }
42629
42630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42631         LDKu8slice ser_ref;
42632         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42633         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42634         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
42635         *ret_conv = ScoringParameters_read(ser_ref);
42636         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42637         return (int64_t)ret_conv;
42638 }
42639
42640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
42641         LDKScoringParameters params_conv;
42642         params_conv.inner = (void*)(params & (~1));
42643         params_conv.is_owned = (params & 1) || (params == 0);
42644         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
42645         params_conv = ScoringParameters_clone(&params_conv);
42646         LDKScorer ret_var = Scorer_new(params_conv);
42647         int64_t ret_ref = 0;
42648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42651         ret_ref = (uintptr_t)ret_var.inner;
42652         if (ret_var.is_owned) {
42653                 ret_ref |= 1;
42654         }
42655         return ret_ref;
42656 }
42657
42658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
42659         LDKScorer ret_var = Scorer_default();
42660         int64_t ret_ref = 0;
42661         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42662         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42664         ret_ref = (uintptr_t)ret_var.inner;
42665         if (ret_var.is_owned) {
42666                 ret_ref |= 1;
42667         }
42668         return ret_ref;
42669 }
42670
42671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
42672         LDKScoringParameters ret_var = ScoringParameters_default();
42673         int64_t ret_ref = 0;
42674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42677         ret_ref = (uintptr_t)ret_var.inner;
42678         if (ret_var.is_owned) {
42679                 ret_ref |= 1;
42680         }
42681         return ret_ref;
42682 }
42683
42684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
42685         LDKScorer this_arg_conv;
42686         this_arg_conv.inner = (void*)(this_arg & (~1));
42687         this_arg_conv.is_owned = false;
42688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42689         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42690         *ret_ret = Scorer_as_Score(&this_arg_conv);
42691         return (int64_t)ret_ret;
42692 }
42693
42694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
42695         LDKScorer obj_conv;
42696         obj_conv.inner = (void*)(obj & (~1));
42697         obj_conv.is_owned = false;
42698         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42699         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
42700         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42701         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42702         CVec_u8Z_free(ret_var);
42703         return ret_arr;
42704 }
42705
42706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42707         LDKu8slice ser_ref;
42708         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42709         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42710         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
42711         *ret_conv = Scorer_read(ser_ref);
42712         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42713         return (int64_t)ret_conv;
42714 }
42715
42716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42717         LDKProbabilisticScorer this_obj_conv;
42718         this_obj_conv.inner = (void*)(this_obj & (~1));
42719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42721         ProbabilisticScorer_free(this_obj_conv);
42722 }
42723
42724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42725         LDKProbabilisticScoringParameters this_obj_conv;
42726         this_obj_conv.inner = (void*)(this_obj & (~1));
42727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42729         ProbabilisticScoringParameters_free(this_obj_conv);
42730 }
42731
42732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42733         LDKProbabilisticScoringParameters this_ptr_conv;
42734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42735         this_ptr_conv.is_owned = false;
42736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42737         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
42738         return ret_val;
42739 }
42740
42741 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) {
42742         LDKProbabilisticScoringParameters this_ptr_conv;
42743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42744         this_ptr_conv.is_owned = false;
42745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42746         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
42747 }
42748
42749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
42750         LDKProbabilisticScoringParameters this_ptr_conv;
42751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42752         this_ptr_conv.is_owned = false;
42753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42754         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
42755         return ret_val;
42756 }
42757
42758 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) {
42759         LDKProbabilisticScoringParameters this_ptr_conv;
42760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42761         this_ptr_conv.is_owned = false;
42762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42763         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
42764 }
42765
42766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1new(JNIEnv *env, jclass clz, int64_t liquidity_penalty_multiplier_msat_arg, int64_t liquidity_offset_half_life_arg) {
42767         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg);
42768         int64_t ret_ref = 0;
42769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42772         ret_ref = (uintptr_t)ret_var.inner;
42773         if (ret_var.is_owned) {
42774                 ret_ref |= 1;
42775         }
42776         return ret_ref;
42777 }
42778
42779 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
42780         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
42781 int64_t ret_ref = 0;
42782 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42783 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42784 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42785 ret_ref = (uintptr_t)ret_var.inner;
42786 if (ret_var.is_owned) {
42787         ret_ref |= 1;
42788 }
42789         return ret_ref;
42790 }
42791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42792         LDKProbabilisticScoringParameters arg_conv;
42793         arg_conv.inner = (void*)(arg & (~1));
42794         arg_conv.is_owned = false;
42795         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42796         int64_t ret_val = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
42797         return ret_val;
42798 }
42799
42800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42801         LDKProbabilisticScoringParameters orig_conv;
42802         orig_conv.inner = (void*)(orig & (~1));
42803         orig_conv.is_owned = false;
42804         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42805         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
42806         int64_t ret_ref = 0;
42807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42810         ret_ref = (uintptr_t)ret_var.inner;
42811         if (ret_var.is_owned) {
42812                 ret_ref |= 1;
42813         }
42814         return ret_ref;
42815 }
42816
42817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42818         LDKProbabilisticScoringParameters obj_conv;
42819         obj_conv.inner = (void*)(obj & (~1));
42820         obj_conv.is_owned = false;
42821         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42822         LDKCVec_u8Z ret_var = ProbabilisticScoringParameters_write(&obj_conv);
42823         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42824         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42825         CVec_u8Z_free(ret_var);
42826         return ret_arr;
42827 }
42828
42829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42830         LDKu8slice ser_ref;
42831         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42832         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42833         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
42834         *ret_conv = ProbabilisticScoringParameters_read(ser_ref);
42835         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42836         return (int64_t)ret_conv;
42837 }
42838
42839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph) {
42840         LDKProbabilisticScoringParameters params_conv;
42841         params_conv.inner = (void*)(params & (~1));
42842         params_conv.is_owned = (params & 1) || (params == 0);
42843         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
42844         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
42845         LDKNetworkGraph network_graph_conv;
42846         network_graph_conv.inner = (void*)(network_graph & (~1));
42847         network_graph_conv.is_owned = false;
42848         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42849         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv);
42850         int64_t ret_ref = 0;
42851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42854         ret_ref = (uintptr_t)ret_var.inner;
42855         if (ret_var.is_owned) {
42856                 ret_ref |= 1;
42857         }
42858         return ret_ref;
42859 }
42860
42861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
42862         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
42863         int64_t ret_ref = 0;
42864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42867         ret_ref = (uintptr_t)ret_var.inner;
42868         if (ret_var.is_owned) {
42869                 ret_ref |= 1;
42870         }
42871         return ret_ref;
42872 }
42873
42874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
42875         LDKProbabilisticScorer this_arg_conv;
42876         this_arg_conv.inner = (void*)(this_arg & (~1));
42877         this_arg_conv.is_owned = false;
42878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42879         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42880         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
42881         return (int64_t)ret_ret;
42882 }
42883
42884 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
42885         LDKProbabilisticScorer obj_conv;
42886         obj_conv.inner = (void*)(obj & (~1));
42887         obj_conv.is_owned = false;
42888         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42889         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
42890         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42891         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42892         CVec_u8Z_free(ret_var);
42893         return ret_arr;
42894 }
42895
42896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
42897         LDKu8slice ser_ref;
42898         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42899         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42900         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
42901         CHECK_ACCESS(arg_ptr);
42902         LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ arg_conv = *(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(arg_ptr);
42903         arg_conv = C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone((LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ*)(((uintptr_t)arg) & ~1));
42904         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
42905         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_conv);
42906         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42907         return (int64_t)ret_conv;
42908 }
42909
42910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42911         LDKFilesystemPersister this_obj_conv;
42912         this_obj_conv.inner = (void*)(this_obj & (~1));
42913         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42915         FilesystemPersister_free(this_obj_conv);
42916 }
42917
42918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
42919         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
42920         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
42921         int64_t ret_ref = 0;
42922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42925         ret_ref = (uintptr_t)ret_var.inner;
42926         if (ret_var.is_owned) {
42927                 ret_ref |= 1;
42928         }
42929         return ret_ref;
42930 }
42931
42932 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
42933         LDKFilesystemPersister this_arg_conv;
42934         this_arg_conv.inner = (void*)(this_arg & (~1));
42935         this_arg_conv.is_owned = false;
42936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42937         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
42938         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42939         Str_free(ret_str);
42940         return ret_conv;
42941 }
42942
42943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
42944         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
42945         LDKChannelManager manager_conv;
42946         manager_conv.inner = (void*)(manager & (~1));
42947         manager_conv.is_owned = false;
42948         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
42949         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
42950         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
42951         return (int64_t)ret_conv;
42952 }
42953
42954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
42955         LDKFilesystemPersister this_arg_conv;
42956         this_arg_conv.inner = (void*)(this_arg & (~1));
42957         this_arg_conv.is_owned = false;
42958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42959         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
42960         CHECK_ACCESS(keys_manager_ptr);
42961         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
42962         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
42963                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42964                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
42965         }
42966         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
42967         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
42968         return (int64_t)ret_conv;
42969 }
42970
42971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
42972         LDKFilesystemPersister this_arg_conv;
42973         this_arg_conv.inner = (void*)(this_arg & (~1));
42974         this_arg_conv.is_owned = false;
42975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42976         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
42977         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
42978         return (int64_t)ret_ret;
42979 }
42980
42981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42982         LDKBackgroundProcessor this_obj_conv;
42983         this_obj_conv.inner = (void*)(this_obj & (~1));
42984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42986         BackgroundProcessor_free(this_obj_conv);
42987 }
42988
42989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42990         if ((this_ptr & 1) != 0) return;
42991         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42992         CHECK_ACCESS(this_ptr_ptr);
42993         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
42994         FREE((void*)this_ptr);
42995         ChannelManagerPersister_free(this_ptr_conv);
42996 }
42997
42998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
42999         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
43000         CHECK_ACCESS(persister_ptr);
43001         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
43002         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
43003                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43004                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
43005         }
43006         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
43007         CHECK_ACCESS(event_handler_ptr);
43008         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
43009         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
43010                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43011                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
43012         }
43013         LDKChainMonitor chain_monitor_conv;
43014         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
43015         chain_monitor_conv.is_owned = false;
43016         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
43017         LDKChannelManager channel_manager_conv;
43018         channel_manager_conv.inner = (void*)(channel_manager & (~1));
43019         channel_manager_conv.is_owned = false;
43020         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
43021         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
43022         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
43023         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
43024         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
43025         LDKPeerManager peer_manager_conv;
43026         peer_manager_conv.inner = (void*)(peer_manager & (~1));
43027         peer_manager_conv.is_owned = false;
43028         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
43029         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43030         CHECK_ACCESS(logger_ptr);
43031         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43032         if (logger_conv.free == LDKLogger_JCalls_free) {
43033                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43034                 LDKLogger_JCalls_cloned(&logger_conv);
43035         }
43036         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
43037         int64_t ret_ref = 0;
43038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43041         ret_ref = (uintptr_t)ret_var.inner;
43042         if (ret_var.is_owned) {
43043                 ret_ref |= 1;
43044         }
43045         return ret_ref;
43046 }
43047
43048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
43049         LDKBackgroundProcessor this_arg_conv;
43050         this_arg_conv.inner = (void*)(this_arg & (~1));
43051         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43053         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
43054         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43055         *ret_conv = BackgroundProcessor_join(this_arg_conv);
43056         return (int64_t)ret_conv;
43057 }
43058
43059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
43060         LDKBackgroundProcessor this_arg_conv;
43061         this_arg_conv.inner = (void*)(this_arg & (~1));
43062         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43064         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
43065         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43066         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
43067         return (int64_t)ret_conv;
43068 }
43069
43070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43071         LDKInvoice this_obj_conv;
43072         this_obj_conv.inner = (void*)(this_obj & (~1));
43073         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43075         Invoice_free(this_obj_conv);
43076 }
43077
43078 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43079         LDKInvoice a_conv;
43080         a_conv.inner = (void*)(a & (~1));
43081         a_conv.is_owned = false;
43082         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43083         LDKInvoice b_conv;
43084         b_conv.inner = (void*)(b & (~1));
43085         b_conv.is_owned = false;
43086         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43087         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
43088         return ret_val;
43089 }
43090
43091 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
43092         LDKInvoice ret_var = Invoice_clone(arg);
43093 int64_t ret_ref = 0;
43094 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43095 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43096 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43097 ret_ref = (uintptr_t)ret_var.inner;
43098 if (ret_var.is_owned) {
43099         ret_ref |= 1;
43100 }
43101         return ret_ref;
43102 }
43103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43104         LDKInvoice arg_conv;
43105         arg_conv.inner = (void*)(arg & (~1));
43106         arg_conv.is_owned = false;
43107         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43108         int64_t ret_val = Invoice_clone_ptr(&arg_conv);
43109         return ret_val;
43110 }
43111
43112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43113         LDKInvoice orig_conv;
43114         orig_conv.inner = (void*)(orig & (~1));
43115         orig_conv.is_owned = false;
43116         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43117         LDKInvoice ret_var = Invoice_clone(&orig_conv);
43118         int64_t ret_ref = 0;
43119         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43120         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43122         ret_ref = (uintptr_t)ret_var.inner;
43123         if (ret_var.is_owned) {
43124                 ret_ref |= 1;
43125         }
43126         return ret_ref;
43127 }
43128
43129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43130         LDKSignedRawInvoice this_obj_conv;
43131         this_obj_conv.inner = (void*)(this_obj & (~1));
43132         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43134         SignedRawInvoice_free(this_obj_conv);
43135 }
43136
43137 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43138         LDKSignedRawInvoice a_conv;
43139         a_conv.inner = (void*)(a & (~1));
43140         a_conv.is_owned = false;
43141         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43142         LDKSignedRawInvoice b_conv;
43143         b_conv.inner = (void*)(b & (~1));
43144         b_conv.is_owned = false;
43145         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43146         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
43147         return ret_val;
43148 }
43149
43150 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
43151         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
43152 int64_t ret_ref = 0;
43153 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43154 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43155 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43156 ret_ref = (uintptr_t)ret_var.inner;
43157 if (ret_var.is_owned) {
43158         ret_ref |= 1;
43159 }
43160         return ret_ref;
43161 }
43162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43163         LDKSignedRawInvoice arg_conv;
43164         arg_conv.inner = (void*)(arg & (~1));
43165         arg_conv.is_owned = false;
43166         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43167         int64_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
43168         return ret_val;
43169 }
43170
43171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43172         LDKSignedRawInvoice orig_conv;
43173         orig_conv.inner = (void*)(orig & (~1));
43174         orig_conv.is_owned = false;
43175         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43176         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
43177         int64_t ret_ref = 0;
43178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43181         ret_ref = (uintptr_t)ret_var.inner;
43182         if (ret_var.is_owned) {
43183                 ret_ref |= 1;
43184         }
43185         return ret_ref;
43186 }
43187
43188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43189         LDKRawInvoice this_obj_conv;
43190         this_obj_conv.inner = (void*)(this_obj & (~1));
43191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43193         RawInvoice_free(this_obj_conv);
43194 }
43195
43196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
43197         LDKRawInvoice this_ptr_conv;
43198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43199         this_ptr_conv.is_owned = false;
43200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43201         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
43202         int64_t ret_ref = 0;
43203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43206         ret_ref = (uintptr_t)ret_var.inner;
43207         if (ret_var.is_owned) {
43208                 ret_ref |= 1;
43209         }
43210         return ret_ref;
43211 }
43212
43213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43214         LDKRawInvoice this_ptr_conv;
43215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43216         this_ptr_conv.is_owned = false;
43217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43218         LDKRawDataPart val_conv;
43219         val_conv.inner = (void*)(val & (~1));
43220         val_conv.is_owned = (val & 1) || (val == 0);
43221         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43222         val_conv = RawDataPart_clone(&val_conv);
43223         RawInvoice_set_data(&this_ptr_conv, val_conv);
43224 }
43225
43226 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43227         LDKRawInvoice a_conv;
43228         a_conv.inner = (void*)(a & (~1));
43229         a_conv.is_owned = false;
43230         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43231         LDKRawInvoice b_conv;
43232         b_conv.inner = (void*)(b & (~1));
43233         b_conv.is_owned = false;
43234         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43235         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
43236         return ret_val;
43237 }
43238
43239 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
43240         LDKRawInvoice ret_var = RawInvoice_clone(arg);
43241 int64_t ret_ref = 0;
43242 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43243 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43244 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43245 ret_ref = (uintptr_t)ret_var.inner;
43246 if (ret_var.is_owned) {
43247         ret_ref |= 1;
43248 }
43249         return ret_ref;
43250 }
43251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43252         LDKRawInvoice arg_conv;
43253         arg_conv.inner = (void*)(arg & (~1));
43254         arg_conv.is_owned = false;
43255         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43256         int64_t ret_val = RawInvoice_clone_ptr(&arg_conv);
43257         return ret_val;
43258 }
43259
43260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43261         LDKRawInvoice orig_conv;
43262         orig_conv.inner = (void*)(orig & (~1));
43263         orig_conv.is_owned = false;
43264         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43265         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
43266         int64_t ret_ref = 0;
43267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43270         ret_ref = (uintptr_t)ret_var.inner;
43271         if (ret_var.is_owned) {
43272                 ret_ref |= 1;
43273         }
43274         return ret_ref;
43275 }
43276
43277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43278         LDKRawDataPart this_obj_conv;
43279         this_obj_conv.inner = (void*)(this_obj & (~1));
43280         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43282         RawDataPart_free(this_obj_conv);
43283 }
43284
43285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
43286         LDKRawDataPart this_ptr_conv;
43287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43288         this_ptr_conv.is_owned = false;
43289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43290         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
43291         int64_t ret_ref = 0;
43292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43295         ret_ref = (uintptr_t)ret_var.inner;
43296         if (ret_var.is_owned) {
43297                 ret_ref |= 1;
43298         }
43299         return ret_ref;
43300 }
43301
43302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43303         LDKRawDataPart this_ptr_conv;
43304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43305         this_ptr_conv.is_owned = false;
43306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43307         LDKPositiveTimestamp val_conv;
43308         val_conv.inner = (void*)(val & (~1));
43309         val_conv.is_owned = (val & 1) || (val == 0);
43310         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43311         val_conv = PositiveTimestamp_clone(&val_conv);
43312         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
43313 }
43314
43315 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43316         LDKRawDataPart a_conv;
43317         a_conv.inner = (void*)(a & (~1));
43318         a_conv.is_owned = false;
43319         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43320         LDKRawDataPart b_conv;
43321         b_conv.inner = (void*)(b & (~1));
43322         b_conv.is_owned = false;
43323         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43324         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
43325         return ret_val;
43326 }
43327
43328 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
43329         LDKRawDataPart ret_var = RawDataPart_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43341         LDKRawDataPart arg_conv;
43342         arg_conv.inner = (void*)(arg & (~1));
43343         arg_conv.is_owned = false;
43344         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43345         int64_t ret_val = RawDataPart_clone_ptr(&arg_conv);
43346         return ret_val;
43347 }
43348
43349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43350         LDKRawDataPart orig_conv;
43351         orig_conv.inner = (void*)(orig & (~1));
43352         orig_conv.is_owned = false;
43353         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43354         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
43355         int64_t ret_ref = 0;
43356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43359         ret_ref = (uintptr_t)ret_var.inner;
43360         if (ret_var.is_owned) {
43361                 ret_ref |= 1;
43362         }
43363         return ret_ref;
43364 }
43365
43366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43367         LDKPositiveTimestamp this_obj_conv;
43368         this_obj_conv.inner = (void*)(this_obj & (~1));
43369         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43371         PositiveTimestamp_free(this_obj_conv);
43372 }
43373
43374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43375         LDKPositiveTimestamp a_conv;
43376         a_conv.inner = (void*)(a & (~1));
43377         a_conv.is_owned = false;
43378         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43379         LDKPositiveTimestamp b_conv;
43380         b_conv.inner = (void*)(b & (~1));
43381         b_conv.is_owned = false;
43382         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43383         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
43384         return ret_val;
43385 }
43386
43387 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
43388         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
43389 int64_t ret_ref = 0;
43390 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43391 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43392 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43393 ret_ref = (uintptr_t)ret_var.inner;
43394 if (ret_var.is_owned) {
43395         ret_ref |= 1;
43396 }
43397         return ret_ref;
43398 }
43399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43400         LDKPositiveTimestamp arg_conv;
43401         arg_conv.inner = (void*)(arg & (~1));
43402         arg_conv.is_owned = false;
43403         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43404         int64_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
43405         return ret_val;
43406 }
43407
43408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43409         LDKPositiveTimestamp orig_conv;
43410         orig_conv.inner = (void*)(orig & (~1));
43411         orig_conv.is_owned = false;
43412         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43413         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
43414         int64_t ret_ref = 0;
43415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43418         ret_ref = (uintptr_t)ret_var.inner;
43419         if (ret_var.is_owned) {
43420                 ret_ref |= 1;
43421         }
43422         return ret_ref;
43423 }
43424
43425 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43426         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
43427         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
43428         return ret_conv;
43429 }
43430
43431 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
43432         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
43433         return ret_conv;
43434 }
43435
43436 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
43437         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
43438         return ret_conv;
43439 }
43440
43441 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
43442         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
43443         return ret_conv;
43444 }
43445
43446 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
43447         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
43448         return ret_conv;
43449 }
43450
43451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43452         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
43453         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
43454         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
43455         return ret_val;
43456 }
43457
43458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
43459         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
43460         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
43461         return ret_val;
43462 }
43463
43464 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43465         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
43466         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
43467         return ret_conv;
43468 }
43469
43470 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
43471         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
43472         return ret_conv;
43473 }
43474
43475 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
43476         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
43477         return ret_conv;
43478 }
43479
43480 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
43481         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
43482         return ret_conv;
43483 }
43484
43485 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
43486         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
43487         return ret_conv;
43488 }
43489
43490 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
43491         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
43492         return ret_conv;
43493 }
43494
43495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
43496         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
43497         int64_t ret_val = Currency_hash(o_conv);
43498         return ret_val;
43499 }
43500
43501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43502         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
43503         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
43504         jboolean ret_val = Currency_eq(a_conv, b_conv);
43505         return ret_val;
43506 }
43507
43508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43509         LDKSha256 this_obj_conv;
43510         this_obj_conv.inner = (void*)(this_obj & (~1));
43511         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43513         Sha256_free(this_obj_conv);
43514 }
43515
43516 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
43517         LDKSha256 ret_var = Sha256_clone(arg);
43518 int64_t ret_ref = 0;
43519 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43520 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43521 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43522 ret_ref = (uintptr_t)ret_var.inner;
43523 if (ret_var.is_owned) {
43524         ret_ref |= 1;
43525 }
43526         return ret_ref;
43527 }
43528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43529         LDKSha256 arg_conv;
43530         arg_conv.inner = (void*)(arg & (~1));
43531         arg_conv.is_owned = false;
43532         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43533         int64_t ret_val = Sha256_clone_ptr(&arg_conv);
43534         return ret_val;
43535 }
43536
43537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43538         LDKSha256 orig_conv;
43539         orig_conv.inner = (void*)(orig & (~1));
43540         orig_conv.is_owned = false;
43541         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43542         LDKSha256 ret_var = Sha256_clone(&orig_conv);
43543         int64_t ret_ref = 0;
43544         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43545         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43547         ret_ref = (uintptr_t)ret_var.inner;
43548         if (ret_var.is_owned) {
43549                 ret_ref |= 1;
43550         }
43551         return ret_ref;
43552 }
43553
43554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
43555         LDKSha256 o_conv;
43556         o_conv.inner = (void*)(o & (~1));
43557         o_conv.is_owned = false;
43558         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43559         int64_t ret_val = Sha256_hash(&o_conv);
43560         return ret_val;
43561 }
43562
43563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43564         LDKSha256 a_conv;
43565         a_conv.inner = (void*)(a & (~1));
43566         a_conv.is_owned = false;
43567         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43568         LDKSha256 b_conv;
43569         b_conv.inner = (void*)(b & (~1));
43570         b_conv.is_owned = false;
43571         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43572         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
43573         return ret_val;
43574 }
43575
43576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43577         LDKDescription this_obj_conv;
43578         this_obj_conv.inner = (void*)(this_obj & (~1));
43579         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43581         Description_free(this_obj_conv);
43582 }
43583
43584 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
43585         LDKDescription ret_var = Description_clone(arg);
43586 int64_t ret_ref = 0;
43587 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43588 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43589 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43590 ret_ref = (uintptr_t)ret_var.inner;
43591 if (ret_var.is_owned) {
43592         ret_ref |= 1;
43593 }
43594         return ret_ref;
43595 }
43596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43597         LDKDescription arg_conv;
43598         arg_conv.inner = (void*)(arg & (~1));
43599         arg_conv.is_owned = false;
43600         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43601         int64_t ret_val = Description_clone_ptr(&arg_conv);
43602         return ret_val;
43603 }
43604
43605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43606         LDKDescription orig_conv;
43607         orig_conv.inner = (void*)(orig & (~1));
43608         orig_conv.is_owned = false;
43609         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43610         LDKDescription ret_var = Description_clone(&orig_conv);
43611         int64_t ret_ref = 0;
43612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43613         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43615         ret_ref = (uintptr_t)ret_var.inner;
43616         if (ret_var.is_owned) {
43617                 ret_ref |= 1;
43618         }
43619         return ret_ref;
43620 }
43621
43622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
43623         LDKDescription o_conv;
43624         o_conv.inner = (void*)(o & (~1));
43625         o_conv.is_owned = false;
43626         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43627         int64_t ret_val = Description_hash(&o_conv);
43628         return ret_val;
43629 }
43630
43631 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43632         LDKDescription a_conv;
43633         a_conv.inner = (void*)(a & (~1));
43634         a_conv.is_owned = false;
43635         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43636         LDKDescription b_conv;
43637         b_conv.inner = (void*)(b & (~1));
43638         b_conv.is_owned = false;
43639         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43640         jboolean ret_val = Description_eq(&a_conv, &b_conv);
43641         return ret_val;
43642 }
43643
43644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43645         LDKPayeePubKey this_obj_conv;
43646         this_obj_conv.inner = (void*)(this_obj & (~1));
43647         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43649         PayeePubKey_free(this_obj_conv);
43650 }
43651
43652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
43653         LDKPayeePubKey this_ptr_conv;
43654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43655         this_ptr_conv.is_owned = false;
43656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43657         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
43658         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
43659         return ret_arr;
43660 }
43661
43662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43663         LDKPayeePubKey this_ptr_conv;
43664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43665         this_ptr_conv.is_owned = false;
43666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43667         LDKPublicKey val_ref;
43668         CHECK((*env)->GetArrayLength(env, val) == 33);
43669         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
43670         PayeePubKey_set_a(&this_ptr_conv, val_ref);
43671 }
43672
43673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
43674         LDKPublicKey a_arg_ref;
43675         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
43676         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
43677         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
43678         int64_t ret_ref = 0;
43679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43682         ret_ref = (uintptr_t)ret_var.inner;
43683         if (ret_var.is_owned) {
43684                 ret_ref |= 1;
43685         }
43686         return ret_ref;
43687 }
43688
43689 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
43690         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
43691 int64_t ret_ref = 0;
43692 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43693 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43694 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43695 ret_ref = (uintptr_t)ret_var.inner;
43696 if (ret_var.is_owned) {
43697         ret_ref |= 1;
43698 }
43699         return ret_ref;
43700 }
43701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43702         LDKPayeePubKey arg_conv;
43703         arg_conv.inner = (void*)(arg & (~1));
43704         arg_conv.is_owned = false;
43705         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43706         int64_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
43707         return ret_val;
43708 }
43709
43710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43711         LDKPayeePubKey orig_conv;
43712         orig_conv.inner = (void*)(orig & (~1));
43713         orig_conv.is_owned = false;
43714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43715         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
43716         int64_t ret_ref = 0;
43717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43720         ret_ref = (uintptr_t)ret_var.inner;
43721         if (ret_var.is_owned) {
43722                 ret_ref |= 1;
43723         }
43724         return ret_ref;
43725 }
43726
43727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
43728         LDKPayeePubKey o_conv;
43729         o_conv.inner = (void*)(o & (~1));
43730         o_conv.is_owned = false;
43731         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43732         int64_t ret_val = PayeePubKey_hash(&o_conv);
43733         return ret_val;
43734 }
43735
43736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43737         LDKPayeePubKey a_conv;
43738         a_conv.inner = (void*)(a & (~1));
43739         a_conv.is_owned = false;
43740         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43741         LDKPayeePubKey b_conv;
43742         b_conv.inner = (void*)(b & (~1));
43743         b_conv.is_owned = false;
43744         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43745         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
43746         return ret_val;
43747 }
43748
43749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43750         LDKExpiryTime this_obj_conv;
43751         this_obj_conv.inner = (void*)(this_obj & (~1));
43752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43754         ExpiryTime_free(this_obj_conv);
43755 }
43756
43757 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
43758         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
43759 int64_t ret_ref = 0;
43760 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43761 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43762 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43763 ret_ref = (uintptr_t)ret_var.inner;
43764 if (ret_var.is_owned) {
43765         ret_ref |= 1;
43766 }
43767         return ret_ref;
43768 }
43769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43770         LDKExpiryTime arg_conv;
43771         arg_conv.inner = (void*)(arg & (~1));
43772         arg_conv.is_owned = false;
43773         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43774         int64_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
43775         return ret_val;
43776 }
43777
43778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43779         LDKExpiryTime orig_conv;
43780         orig_conv.inner = (void*)(orig & (~1));
43781         orig_conv.is_owned = false;
43782         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43783         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
43784         int64_t ret_ref = 0;
43785         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43786         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43788         ret_ref = (uintptr_t)ret_var.inner;
43789         if (ret_var.is_owned) {
43790                 ret_ref |= 1;
43791         }
43792         return ret_ref;
43793 }
43794
43795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
43796         LDKExpiryTime o_conv;
43797         o_conv.inner = (void*)(o & (~1));
43798         o_conv.is_owned = false;
43799         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43800         int64_t ret_val = ExpiryTime_hash(&o_conv);
43801         return ret_val;
43802 }
43803
43804 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43805         LDKExpiryTime a_conv;
43806         a_conv.inner = (void*)(a & (~1));
43807         a_conv.is_owned = false;
43808         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43809         LDKExpiryTime b_conv;
43810         b_conv.inner = (void*)(b & (~1));
43811         b_conv.is_owned = false;
43812         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43813         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
43814         return ret_val;
43815 }
43816
43817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43818         LDKMinFinalCltvExpiry this_obj_conv;
43819         this_obj_conv.inner = (void*)(this_obj & (~1));
43820         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43822         MinFinalCltvExpiry_free(this_obj_conv);
43823 }
43824
43825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
43826         LDKMinFinalCltvExpiry this_ptr_conv;
43827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43828         this_ptr_conv.is_owned = false;
43829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43830         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
43831         return ret_val;
43832 }
43833
43834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43835         LDKMinFinalCltvExpiry this_ptr_conv;
43836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43837         this_ptr_conv.is_owned = false;
43838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43839         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
43840 }
43841
43842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
43843         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
43844         int64_t ret_ref = 0;
43845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43848         ret_ref = (uintptr_t)ret_var.inner;
43849         if (ret_var.is_owned) {
43850                 ret_ref |= 1;
43851         }
43852         return ret_ref;
43853 }
43854
43855 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
43856         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
43857 int64_t ret_ref = 0;
43858 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43859 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43860 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43861 ret_ref = (uintptr_t)ret_var.inner;
43862 if (ret_var.is_owned) {
43863         ret_ref |= 1;
43864 }
43865         return ret_ref;
43866 }
43867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43868         LDKMinFinalCltvExpiry arg_conv;
43869         arg_conv.inner = (void*)(arg & (~1));
43870         arg_conv.is_owned = false;
43871         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43872         int64_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
43873         return ret_val;
43874 }
43875
43876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43877         LDKMinFinalCltvExpiry orig_conv;
43878         orig_conv.inner = (void*)(orig & (~1));
43879         orig_conv.is_owned = false;
43880         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43881         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
43882         int64_t ret_ref = 0;
43883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43886         ret_ref = (uintptr_t)ret_var.inner;
43887         if (ret_var.is_owned) {
43888                 ret_ref |= 1;
43889         }
43890         return ret_ref;
43891 }
43892
43893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
43894         LDKMinFinalCltvExpiry o_conv;
43895         o_conv.inner = (void*)(o & (~1));
43896         o_conv.is_owned = false;
43897         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43898         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
43899         return ret_val;
43900 }
43901
43902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43903         LDKMinFinalCltvExpiry a_conv;
43904         a_conv.inner = (void*)(a & (~1));
43905         a_conv.is_owned = false;
43906         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43907         LDKMinFinalCltvExpiry b_conv;
43908         b_conv.inner = (void*)(b & (~1));
43909         b_conv.is_owned = false;
43910         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43911         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
43912         return ret_val;
43913 }
43914
43915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43916         if ((this_ptr & 1) != 0) return;
43917         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43918         CHECK_ACCESS(this_ptr_ptr);
43919         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
43920         FREE((void*)this_ptr);
43921         Fallback_free(this_ptr_conv);
43922 }
43923
43924 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
43925         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43926         *ret_copy = Fallback_clone(arg);
43927 int64_t ret_ref = (uintptr_t)ret_copy;
43928         return ret_ref;
43929 }
43930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43931         LDKFallback* arg_conv = (LDKFallback*)arg;
43932         int64_t ret_val = Fallback_clone_ptr(arg_conv);
43933         return ret_val;
43934 }
43935
43936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43937         LDKFallback* orig_conv = (LDKFallback*)orig;
43938         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43939         *ret_copy = Fallback_clone(orig_conv);
43940         int64_t ret_ref = (uintptr_t)ret_copy;
43941         return ret_ref;
43942 }
43943
43944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
43945         
43946         LDKCVec_u8Z program_ref;
43947         program_ref.datalen = (*env)->GetArrayLength(env, program);
43948         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
43949         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
43950         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43951         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
43952         int64_t ret_ref = (uintptr_t)ret_copy;
43953         return ret_ref;
43954 }
43955
43956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
43957         LDKTwentyBytes a_ref;
43958         CHECK((*env)->GetArrayLength(env, a) == 20);
43959         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
43960         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43961         *ret_copy = Fallback_pub_key_hash(a_ref);
43962         int64_t ret_ref = (uintptr_t)ret_copy;
43963         return ret_ref;
43964 }
43965
43966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
43967         LDKTwentyBytes a_ref;
43968         CHECK((*env)->GetArrayLength(env, a) == 20);
43969         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
43970         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43971         *ret_copy = Fallback_script_hash(a_ref);
43972         int64_t ret_ref = (uintptr_t)ret_copy;
43973         return ret_ref;
43974 }
43975
43976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
43977         LDKFallback* o_conv = (LDKFallback*)o;
43978         int64_t ret_val = Fallback_hash(o_conv);
43979         return ret_val;
43980 }
43981
43982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43983         LDKFallback* a_conv = (LDKFallback*)a;
43984         LDKFallback* b_conv = (LDKFallback*)b;
43985         jboolean ret_val = Fallback_eq(a_conv, b_conv);
43986         return ret_val;
43987 }
43988
43989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43990         LDKInvoiceSignature this_obj_conv;
43991         this_obj_conv.inner = (void*)(this_obj & (~1));
43992         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43994         InvoiceSignature_free(this_obj_conv);
43995 }
43996
43997 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
43998         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
43999 int64_t ret_ref = 0;
44000 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44001 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44002 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44003 ret_ref = (uintptr_t)ret_var.inner;
44004 if (ret_var.is_owned) {
44005         ret_ref |= 1;
44006 }
44007         return ret_ref;
44008 }
44009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44010         LDKInvoiceSignature arg_conv;
44011         arg_conv.inner = (void*)(arg & (~1));
44012         arg_conv.is_owned = false;
44013         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44014         int64_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
44015         return ret_val;
44016 }
44017
44018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44019         LDKInvoiceSignature orig_conv;
44020         orig_conv.inner = (void*)(orig & (~1));
44021         orig_conv.is_owned = false;
44022         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44023         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
44024         int64_t ret_ref = 0;
44025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44028         ret_ref = (uintptr_t)ret_var.inner;
44029         if (ret_var.is_owned) {
44030                 ret_ref |= 1;
44031         }
44032         return ret_ref;
44033 }
44034
44035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44036         LDKInvoiceSignature a_conv;
44037         a_conv.inner = (void*)(a & (~1));
44038         a_conv.is_owned = false;
44039         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44040         LDKInvoiceSignature b_conv;
44041         b_conv.inner = (void*)(b & (~1));
44042         b_conv.is_owned = false;
44043         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44044         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
44045         return ret_val;
44046 }
44047
44048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44049         LDKPrivateRoute this_obj_conv;
44050         this_obj_conv.inner = (void*)(this_obj & (~1));
44051         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44053         PrivateRoute_free(this_obj_conv);
44054 }
44055
44056 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
44057         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
44058 int64_t ret_ref = 0;
44059 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44060 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44061 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44062 ret_ref = (uintptr_t)ret_var.inner;
44063 if (ret_var.is_owned) {
44064         ret_ref |= 1;
44065 }
44066         return ret_ref;
44067 }
44068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44069         LDKPrivateRoute arg_conv;
44070         arg_conv.inner = (void*)(arg & (~1));
44071         arg_conv.is_owned = false;
44072         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44073         int64_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
44074         return ret_val;
44075 }
44076
44077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44078         LDKPrivateRoute orig_conv;
44079         orig_conv.inner = (void*)(orig & (~1));
44080         orig_conv.is_owned = false;
44081         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44082         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
44083         int64_t ret_ref = 0;
44084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44087         ret_ref = (uintptr_t)ret_var.inner;
44088         if (ret_var.is_owned) {
44089                 ret_ref |= 1;
44090         }
44091         return ret_ref;
44092 }
44093
44094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
44095         LDKPrivateRoute o_conv;
44096         o_conv.inner = (void*)(o & (~1));
44097         o_conv.is_owned = false;
44098         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44099         int64_t ret_val = PrivateRoute_hash(&o_conv);
44100         return ret_val;
44101 }
44102
44103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44104         LDKPrivateRoute a_conv;
44105         a_conv.inner = (void*)(a & (~1));
44106         a_conv.is_owned = false;
44107         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44108         LDKPrivateRoute b_conv;
44109         b_conv.inner = (void*)(b & (~1));
44110         b_conv.is_owned = false;
44111         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44112         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
44113         return ret_val;
44114 }
44115
44116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
44117         LDKSignedRawInvoice this_arg_conv;
44118         this_arg_conv.inner = (void*)(this_arg & (~1));
44119         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44121         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
44122         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
44123         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
44124         return ((int64_t)ret_conv);
44125 }
44126
44127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
44128         LDKSignedRawInvoice this_arg_conv;
44129         this_arg_conv.inner = (void*)(this_arg & (~1));
44130         this_arg_conv.is_owned = false;
44131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44132         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
44133         int64_t ret_ref = 0;
44134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44135         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44137         ret_ref = (uintptr_t)ret_var.inner;
44138         if (ret_var.is_owned) {
44139                 ret_ref |= 1;
44140         }
44141         return ret_ref;
44142 }
44143
44144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44145         LDKSignedRawInvoice this_arg_conv;
44146         this_arg_conv.inner = (void*)(this_arg & (~1));
44147         this_arg_conv.is_owned = false;
44148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44149         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
44151         return ret_arr;
44152 }
44153
44154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44155         LDKSignedRawInvoice this_arg_conv;
44156         this_arg_conv.inner = (void*)(this_arg & (~1));
44157         this_arg_conv.is_owned = false;
44158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44159         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
44160         int64_t ret_ref = 0;
44161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44164         ret_ref = (uintptr_t)ret_var.inner;
44165         if (ret_var.is_owned) {
44166                 ret_ref |= 1;
44167         }
44168         return ret_ref;
44169 }
44170
44171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44172         LDKSignedRawInvoice this_arg_conv;
44173         this_arg_conv.inner = (void*)(this_arg & (~1));
44174         this_arg_conv.is_owned = false;
44175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44176         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
44177         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
44178         return (int64_t)ret_conv;
44179 }
44180
44181 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44182         LDKSignedRawInvoice this_arg_conv;
44183         this_arg_conv.inner = (void*)(this_arg & (~1));
44184         this_arg_conv.is_owned = false;
44185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44186         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
44187         return ret_val;
44188 }
44189
44190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44191         LDKRawInvoice this_arg_conv;
44192         this_arg_conv.inner = (void*)(this_arg & (~1));
44193         this_arg_conv.is_owned = false;
44194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44195         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44196         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
44197         return ret_arr;
44198 }
44199
44200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44201         LDKRawInvoice this_arg_conv;
44202         this_arg_conv.inner = (void*)(this_arg & (~1));
44203         this_arg_conv.is_owned = false;
44204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44205         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
44206         int64_t ret_ref = 0;
44207         if ((uintptr_t)ret_var.inner > 4096) {
44208                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44209                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44211                 ret_ref = (uintptr_t)ret_var.inner;
44212                 if (ret_var.is_owned) {
44213                         ret_ref |= 1;
44214                 }
44215         }
44216         return ret_ref;
44217 }
44218
44219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
44220         LDKRawInvoice this_arg_conv;
44221         this_arg_conv.inner = (void*)(this_arg & (~1));
44222         this_arg_conv.is_owned = false;
44223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44224         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
44225         int64_t ret_ref = 0;
44226         if ((uintptr_t)ret_var.inner > 4096) {
44227                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44228                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44230                 ret_ref = (uintptr_t)ret_var.inner;
44231                 if (ret_var.is_owned) {
44232                         ret_ref |= 1;
44233                 }
44234         }
44235         return ret_ref;
44236 }
44237
44238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44239         LDKRawInvoice this_arg_conv;
44240         this_arg_conv.inner = (void*)(this_arg & (~1));
44241         this_arg_conv.is_owned = false;
44242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44243         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
44244         int64_t ret_ref = 0;
44245         if ((uintptr_t)ret_var.inner > 4096) {
44246                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44247                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44249                 ret_ref = (uintptr_t)ret_var.inner;
44250                 if (ret_var.is_owned) {
44251                         ret_ref |= 1;
44252                 }
44253         }
44254         return ret_ref;
44255 }
44256
44257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44258         LDKRawInvoice this_arg_conv;
44259         this_arg_conv.inner = (void*)(this_arg & (~1));
44260         this_arg_conv.is_owned = false;
44261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44262         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
44263         int64_t ret_ref = 0;
44264         if ((uintptr_t)ret_var.inner > 4096) {
44265                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44266                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44268                 ret_ref = (uintptr_t)ret_var.inner;
44269                 if (ret_var.is_owned) {
44270                         ret_ref |= 1;
44271                 }
44272         }
44273         return ret_ref;
44274 }
44275
44276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
44277         LDKRawInvoice this_arg_conv;
44278         this_arg_conv.inner = (void*)(this_arg & (~1));
44279         this_arg_conv.is_owned = false;
44280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44281         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
44282         int64_t ret_ref = 0;
44283         if ((uintptr_t)ret_var.inner > 4096) {
44284                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44285                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44287                 ret_ref = (uintptr_t)ret_var.inner;
44288                 if (ret_var.is_owned) {
44289                         ret_ref |= 1;
44290                 }
44291         }
44292         return ret_ref;
44293 }
44294
44295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
44296         LDKRawInvoice this_arg_conv;
44297         this_arg_conv.inner = (void*)(this_arg & (~1));
44298         this_arg_conv.is_owned = false;
44299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44300         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
44301         int64_t ret_ref = 0;
44302         if ((uintptr_t)ret_var.inner > 4096) {
44303                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44304                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44306                 ret_ref = (uintptr_t)ret_var.inner;
44307                 if (ret_var.is_owned) {
44308                         ret_ref |= 1;
44309                 }
44310         }
44311         return ret_ref;
44312 }
44313
44314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44315         LDKRawInvoice this_arg_conv;
44316         this_arg_conv.inner = (void*)(this_arg & (~1));
44317         this_arg_conv.is_owned = false;
44318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44319         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44320         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
44321         return ret_arr;
44322 }
44323
44324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
44325         LDKRawInvoice this_arg_conv;
44326         this_arg_conv.inner = (void*)(this_arg & (~1));
44327         this_arg_conv.is_owned = false;
44328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44329         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
44330         int64_t ret_ref = 0;
44331         if ((uintptr_t)ret_var.inner > 4096) {
44332                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44333                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44335                 ret_ref = (uintptr_t)ret_var.inner;
44336                 if (ret_var.is_owned) {
44337                         ret_ref |= 1;
44338                 }
44339         }
44340         return ret_ref;
44341 }
44342
44343 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
44344         LDKRawInvoice this_arg_conv;
44345         this_arg_conv.inner = (void*)(this_arg & (~1));
44346         this_arg_conv.is_owned = false;
44347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44348         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
44349         int64_tArray ret_arr = NULL;
44350         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44351         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44352         for (size_t o = 0; o < ret_var.datalen; o++) {
44353                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44354                 int64_t ret_conv_14_ref = 0;
44355                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44356                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44357                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44358                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44359                 if (ret_conv_14_var.is_owned) {
44360                         ret_conv_14_ref |= 1;
44361                 }
44362                 ret_arr_ptr[o] = ret_conv_14_ref;
44363         }
44364         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44365         FREE(ret_var.data);
44366         return ret_arr;
44367 }
44368
44369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
44370         LDKRawInvoice this_arg_conv;
44371         this_arg_conv.inner = (void*)(this_arg & (~1));
44372         this_arg_conv.is_owned = false;
44373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44374         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44375         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
44376         int64_t ret_ref = (uintptr_t)ret_copy;
44377         return ret_ref;
44378 }
44379
44380 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
44381         LDKRawInvoice this_arg_conv;
44382         this_arg_conv.inner = (void*)(this_arg & (~1));
44383         this_arg_conv.is_owned = false;
44384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44385         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
44386         return ret_conv;
44387 }
44388
44389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
44390         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
44391         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
44392         return (int64_t)ret_conv;
44393 }
44394
44395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
44396         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
44397         *ret_conv = PositiveTimestamp_from_system_time(time);
44398         return (int64_t)ret_conv;
44399 }
44400
44401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
44402         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
44403         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
44404         return (int64_t)ret_conv;
44405 }
44406
44407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
44408         LDKPositiveTimestamp this_arg_conv;
44409         this_arg_conv.inner = (void*)(this_arg & (~1));
44410         this_arg_conv.is_owned = false;
44411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44412         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
44413         return ret_val;
44414 }
44415
44416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
44417         LDKPositiveTimestamp this_arg_conv;
44418         this_arg_conv.inner = (void*)(this_arg & (~1));
44419         this_arg_conv.is_owned = false;
44420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44421         int64_t ret_val = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
44422         return ret_val;
44423 }
44424
44425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
44426         LDKPositiveTimestamp this_arg_conv;
44427         this_arg_conv.inner = (void*)(this_arg & (~1));
44428         this_arg_conv.is_owned = false;
44429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44430         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
44431         return ret_val;
44432 }
44433
44434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
44435         LDKInvoice this_arg_conv;
44436         this_arg_conv.inner = (void*)(this_arg & (~1));
44437         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44439         this_arg_conv = Invoice_clone(&this_arg_conv);
44440         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
44441         int64_t ret_ref = 0;
44442         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44443         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44445         ret_ref = (uintptr_t)ret_var.inner;
44446         if (ret_var.is_owned) {
44447                 ret_ref |= 1;
44448         }
44449         return ret_ref;
44450 }
44451
44452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44453         LDKInvoice this_arg_conv;
44454         this_arg_conv.inner = (void*)(this_arg & (~1));
44455         this_arg_conv.is_owned = false;
44456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44457         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
44458         *ret_conv = Invoice_check_signature(&this_arg_conv);
44459         return (int64_t)ret_conv;
44460 }
44461
44462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
44463         LDKSignedRawInvoice signed_invoice_conv;
44464         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
44465         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
44466         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
44467         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
44468         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
44469         *ret_conv = Invoice_from_signed(signed_invoice_conv);
44470         return (int64_t)ret_conv;
44471 }
44472
44473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
44474         LDKInvoice this_arg_conv;
44475         this_arg_conv.inner = (void*)(this_arg & (~1));
44476         this_arg_conv.is_owned = false;
44477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44478         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
44479         return ret_val;
44480 }
44481
44482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
44483         LDKInvoice this_arg_conv;
44484         this_arg_conv.inner = (void*)(this_arg & (~1));
44485         this_arg_conv.is_owned = false;
44486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44487         int64_t ret_val = Invoice_duration_since_epoch(&this_arg_conv);
44488         return ret_val;
44489 }
44490
44491 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44492         LDKInvoice this_arg_conv;
44493         this_arg_conv.inner = (void*)(this_arg & (~1));
44494         this_arg_conv.is_owned = false;
44495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44496         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44497         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
44498         return ret_arr;
44499 }
44500
44501 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44502         LDKInvoice this_arg_conv;
44503         this_arg_conv.inner = (void*)(this_arg & (~1));
44504         this_arg_conv.is_owned = false;
44505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44506         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44507         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
44508         return ret_arr;
44509 }
44510
44511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44512         LDKInvoice this_arg_conv;
44513         this_arg_conv.inner = (void*)(this_arg & (~1));
44514         this_arg_conv.is_owned = false;
44515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44516         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
44518         return ret_arr;
44519 }
44520
44521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
44522         LDKInvoice this_arg_conv;
44523         this_arg_conv.inner = (void*)(this_arg & (~1));
44524         this_arg_conv.is_owned = false;
44525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44526         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
44527         int64_t ret_ref = 0;
44528         if ((uintptr_t)ret_var.inner > 4096) {
44529                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44530                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44532                 ret_ref = (uintptr_t)ret_var.inner;
44533                 if (ret_var.is_owned) {
44534                         ret_ref |= 1;
44535                 }
44536         }
44537         return ret_ref;
44538 }
44539
44540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44541         LDKInvoice this_arg_conv;
44542         this_arg_conv.inner = (void*)(this_arg & (~1));
44543         this_arg_conv.is_owned = false;
44544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44545         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
44547         return ret_arr;
44548 }
44549
44550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
44551         LDKInvoice this_arg_conv;
44552         this_arg_conv.inner = (void*)(this_arg & (~1));
44553         this_arg_conv.is_owned = false;
44554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44555         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
44556         return ret_val;
44557 }
44558
44559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
44560         LDKInvoice this_arg_conv;
44561         this_arg_conv.inner = (void*)(this_arg & (~1));
44562         this_arg_conv.is_owned = false;
44563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44564         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
44565         return ret_val;
44566 }
44567
44568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
44569         LDKInvoice this_arg_conv;
44570         this_arg_conv.inner = (void*)(this_arg & (~1));
44571         this_arg_conv.is_owned = false;
44572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44573         jboolean ret_val = Invoice_would_expire(&this_arg_conv, at_time);
44574         return ret_val;
44575 }
44576
44577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
44578         LDKInvoice this_arg_conv;
44579         this_arg_conv.inner = (void*)(this_arg & (~1));
44580         this_arg_conv.is_owned = false;
44581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44582         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
44583         return ret_val;
44584 }
44585
44586 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
44587         LDKInvoice this_arg_conv;
44588         this_arg_conv.inner = (void*)(this_arg & (~1));
44589         this_arg_conv.is_owned = false;
44590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44591         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
44592         int64_tArray ret_arr = NULL;
44593         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44594         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44595         for (size_t o = 0; o < ret_var.datalen; o++) {
44596                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44597                 int64_t ret_conv_14_ref = 0;
44598                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44599                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44600                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44601                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44602                 if (ret_conv_14_var.is_owned) {
44603                         ret_conv_14_ref |= 1;
44604                 }
44605                 ret_arr_ptr[o] = ret_conv_14_ref;
44606         }
44607         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44608         FREE(ret_var.data);
44609         return ret_arr;
44610 }
44611
44612 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
44613         LDKInvoice this_arg_conv;
44614         this_arg_conv.inner = (void*)(this_arg & (~1));
44615         this_arg_conv.is_owned = false;
44616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44617         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
44618         int64_tArray ret_arr = NULL;
44619         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44620         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44621         for (size_t l = 0; l < ret_var.datalen; l++) {
44622                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
44623                 int64_t ret_conv_11_ref = 0;
44624                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44625                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44626                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
44627                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
44628                 if (ret_conv_11_var.is_owned) {
44629                         ret_conv_11_ref |= 1;
44630                 }
44631                 ret_arr_ptr[l] = ret_conv_11_ref;
44632         }
44633         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44634         FREE(ret_var.data);
44635         return ret_arr;
44636 }
44637
44638 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
44639         LDKInvoice this_arg_conv;
44640         this_arg_conv.inner = (void*)(this_arg & (~1));
44641         this_arg_conv.is_owned = false;
44642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44643         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
44644         return ret_conv;
44645 }
44646
44647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
44648         LDKInvoice this_arg_conv;
44649         this_arg_conv.inner = (void*)(this_arg & (~1));
44650         this_arg_conv.is_owned = false;
44651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44652         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44653         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
44654         int64_t ret_ref = (uintptr_t)ret_copy;
44655         return ret_ref;
44656 }
44657
44658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
44659         LDKStr description_conv = java_to_owned_str(env, description);
44660         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
44661         *ret_conv = Description_new(description_conv);
44662         return (int64_t)ret_conv;
44663 }
44664
44665 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
44666         LDKDescription this_arg_conv;
44667         this_arg_conv.inner = (void*)(this_arg & (~1));
44668         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44670         this_arg_conv = Description_clone(&this_arg_conv);
44671         LDKStr ret_str = Description_into_inner(this_arg_conv);
44672         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
44673         Str_free(ret_str);
44674         return ret_conv;
44675 }
44676
44677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
44678         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
44679         int64_t ret_ref = 0;
44680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44683         ret_ref = (uintptr_t)ret_var.inner;
44684         if (ret_var.is_owned) {
44685                 ret_ref |= 1;
44686         }
44687         return ret_ref;
44688 }
44689
44690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
44691         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
44692         int64_t ret_ref = 0;
44693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44696         ret_ref = (uintptr_t)ret_var.inner;
44697         if (ret_var.is_owned) {
44698                 ret_ref |= 1;
44699         }
44700         return ret_ref;
44701 }
44702
44703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
44704         LDKExpiryTime this_arg_conv;
44705         this_arg_conv.inner = (void*)(this_arg & (~1));
44706         this_arg_conv.is_owned = false;
44707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44708         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
44709         return ret_val;
44710 }
44711
44712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
44713         LDKExpiryTime this_arg_conv;
44714         this_arg_conv.inner = (void*)(this_arg & (~1));
44715         this_arg_conv.is_owned = false;
44716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44717         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
44718         return ret_val;
44719 }
44720
44721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
44722         LDKRouteHint hops_conv;
44723         hops_conv.inner = (void*)(hops & (~1));
44724         hops_conv.is_owned = (hops & 1) || (hops == 0);
44725         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
44726         hops_conv = RouteHint_clone(&hops_conv);
44727         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
44728         *ret_conv = PrivateRoute_new(hops_conv);
44729         return (int64_t)ret_conv;
44730 }
44731
44732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
44733         LDKPrivateRoute this_arg_conv;
44734         this_arg_conv.inner = (void*)(this_arg & (~1));
44735         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44737         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
44738         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
44739         int64_t ret_ref = 0;
44740         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44741         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44743         ret_ref = (uintptr_t)ret_var.inner;
44744         if (ret_var.is_owned) {
44745                 ret_ref |= 1;
44746         }
44747         return ret_ref;
44748 }
44749
44750 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44751         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
44752         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
44753         return ret_conv;
44754 }
44755
44756 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
44757         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
44758         return ret_conv;
44759 }
44760
44761 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
44762         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
44763         return ret_conv;
44764 }
44765
44766 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
44767         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
44768         return ret_conv;
44769 }
44770
44771 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
44772         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
44773         return ret_conv;
44774 }
44775
44776 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
44777         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
44778         return ret_conv;
44779 }
44780
44781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44782         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
44783         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
44784         jboolean ret_val = CreationError_eq(a_conv, b_conv);
44785         return ret_val;
44786 }
44787
44788 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
44789         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
44790         LDKStr ret_str = CreationError_to_str(o_conv);
44791         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
44792         Str_free(ret_str);
44793         return ret_conv;
44794 }
44795
44796 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44797         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
44798         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
44799         return ret_conv;
44800 }
44801
44802 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
44803         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
44804         return ret_conv;
44805 }
44806
44807 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
44808         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
44809         return ret_conv;
44810 }
44811
44812 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
44813         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
44814         return ret_conv;
44815 }
44816
44817 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
44818         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
44819         return ret_conv;
44820 }
44821
44822 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
44823         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
44824         return ret_conv;
44825 }
44826
44827 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
44828         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
44829         return ret_conv;
44830 }
44831
44832 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
44833         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
44834         return ret_conv;
44835 }
44836
44837 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
44838         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
44839         return ret_conv;
44840 }
44841
44842 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
44843         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
44844         return ret_conv;
44845 }
44846
44847 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
44848         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
44849         return ret_conv;
44850 }
44851
44852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44853         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
44854         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
44855         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
44856         return ret_val;
44857 }
44858
44859 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
44860         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
44861         LDKStr ret_str = SemanticError_to_str(o_conv);
44862         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
44863         Str_free(ret_str);
44864         return ret_conv;
44865 }
44866
44867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44868         if ((this_ptr & 1) != 0) return;
44869         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44870         CHECK_ACCESS(this_ptr_ptr);
44871         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
44872         FREE((void*)this_ptr);
44873         SignOrCreationError_free(this_ptr_conv);
44874 }
44875
44876 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
44877         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44878         *ret_copy = SignOrCreationError_clone(arg);
44879 int64_t ret_ref = (uintptr_t)ret_copy;
44880         return ret_ref;
44881 }
44882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44883         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
44884         int64_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
44885         return ret_val;
44886 }
44887
44888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44889         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
44890         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44891         *ret_copy = SignOrCreationError_clone(orig_conv);
44892         int64_t ret_ref = (uintptr_t)ret_copy;
44893         return ret_ref;
44894 }
44895
44896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
44897         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44898         *ret_copy = SignOrCreationError_sign_error();
44899         int64_t ret_ref = (uintptr_t)ret_copy;
44900         return ret_ref;
44901 }
44902
44903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
44904         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
44905         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44906         *ret_copy = SignOrCreationError_creation_error(a_conv);
44907         int64_t ret_ref = (uintptr_t)ret_copy;
44908         return ret_ref;
44909 }
44910
44911 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44912         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
44913         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
44914         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
44915         return ret_val;
44916 }
44917
44918 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
44919         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
44920         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
44921         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
44922         Str_free(ret_str);
44923         return ret_conv;
44924 }
44925
44926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44927         LDKInvoicePayer this_obj_conv;
44928         this_obj_conv.inner = (void*)(this_obj & (~1));
44929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44931         InvoicePayer_free(this_obj_conv);
44932 }
44933
44934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44935         if ((this_ptr & 1) != 0) return;
44936         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44937         CHECK_ACCESS(this_ptr_ptr);
44938         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
44939         FREE((void*)this_ptr);
44940         Payer_free(this_ptr_conv);
44941 }
44942
44943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44944         if ((this_ptr & 1) != 0) return;
44945         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44946         CHECK_ACCESS(this_ptr_ptr);
44947         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
44948         FREE((void*)this_ptr);
44949         Router_free(this_ptr_conv);
44950 }
44951
44952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44953         LDKRetryAttempts this_obj_conv;
44954         this_obj_conv.inner = (void*)(this_obj & (~1));
44955         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44957         RetryAttempts_free(this_obj_conv);
44958 }
44959
44960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44961         LDKRetryAttempts this_ptr_conv;
44962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44963         this_ptr_conv.is_owned = false;
44964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44965         int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
44966         return ret_val;
44967 }
44968
44969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44970         LDKRetryAttempts this_ptr_conv;
44971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44972         this_ptr_conv.is_owned = false;
44973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44974         RetryAttempts_set_a(&this_ptr_conv, val);
44975 }
44976
44977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
44978         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
44979         int64_t ret_ref = 0;
44980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44983         ret_ref = (uintptr_t)ret_var.inner;
44984         if (ret_var.is_owned) {
44985                 ret_ref |= 1;
44986         }
44987         return ret_ref;
44988 }
44989
44990 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
44991         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
44992 int64_t ret_ref = 0;
44993 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44994 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44995 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44996 ret_ref = (uintptr_t)ret_var.inner;
44997 if (ret_var.is_owned) {
44998         ret_ref |= 1;
44999 }
45000         return ret_ref;
45001 }
45002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45003         LDKRetryAttempts arg_conv;
45004         arg_conv.inner = (void*)(arg & (~1));
45005         arg_conv.is_owned = false;
45006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45007         int64_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
45008         return ret_val;
45009 }
45010
45011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45012         LDKRetryAttempts orig_conv;
45013         orig_conv.inner = (void*)(orig & (~1));
45014         orig_conv.is_owned = false;
45015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45016         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
45017         int64_t ret_ref = 0;
45018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45021         ret_ref = (uintptr_t)ret_var.inner;
45022         if (ret_var.is_owned) {
45023                 ret_ref |= 1;
45024         }
45025         return ret_ref;
45026 }
45027
45028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45029         LDKRetryAttempts a_conv;
45030         a_conv.inner = (void*)(a & (~1));
45031         a_conv.is_owned = false;
45032         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45033         LDKRetryAttempts b_conv;
45034         b_conv.inner = (void*)(b & (~1));
45035         b_conv.is_owned = false;
45036         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45037         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
45038         return ret_val;
45039 }
45040
45041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
45042         LDKRetryAttempts o_conv;
45043         o_conv.inner = (void*)(o & (~1));
45044         o_conv.is_owned = false;
45045         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45046         int64_t ret_val = RetryAttempts_hash(&o_conv);
45047         return ret_val;
45048 }
45049
45050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45051         if ((this_ptr & 1) != 0) return;
45052         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45053         CHECK_ACCESS(this_ptr_ptr);
45054         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
45055         FREE((void*)this_ptr);
45056         PaymentError_free(this_ptr_conv);
45057 }
45058
45059 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
45060         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45061         *ret_copy = PaymentError_clone(arg);
45062 int64_t ret_ref = (uintptr_t)ret_copy;
45063         return ret_ref;
45064 }
45065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45066         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
45067         int64_t ret_val = PaymentError_clone_ptr(arg_conv);
45068         return ret_val;
45069 }
45070
45071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45072         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
45073         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45074         *ret_copy = PaymentError_clone(orig_conv);
45075         int64_t ret_ref = (uintptr_t)ret_copy;
45076         return ret_ref;
45077 }
45078
45079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
45080         LDKStr a_conv = java_to_owned_str(env, a);
45081         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45082         *ret_copy = PaymentError_invoice(a_conv);
45083         int64_t ret_ref = (uintptr_t)ret_copy;
45084         return ret_ref;
45085 }
45086
45087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
45088         LDKLightningError a_conv;
45089         a_conv.inner = (void*)(a & (~1));
45090         a_conv.is_owned = (a & 1) || (a == 0);
45091         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45092         a_conv = LightningError_clone(&a_conv);
45093         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45094         *ret_copy = PaymentError_routing(a_conv);
45095         int64_t ret_ref = (uintptr_t)ret_copy;
45096         return ret_ref;
45097 }
45098
45099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
45100         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
45101         CHECK_ACCESS(a_ptr);
45102         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
45103         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
45104         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45105         *ret_copy = PaymentError_sending(a_conv);
45106         int64_t ret_ref = (uintptr_t)ret_copy;
45107         return ret_ref;
45108 }
45109
45110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry_attempts) {
45111         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
45112         CHECK_ACCESS(payer_ptr);
45113         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
45114         if (payer_conv.free == LDKPayer_JCalls_free) {
45115                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45116                 LDKPayer_JCalls_cloned(&payer_conv);
45117         }
45118         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
45119         CHECK_ACCESS(router_ptr);
45120         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
45121         if (router_conv.free == LDKRouter_JCalls_free) {
45122                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45123                 LDKRouter_JCalls_cloned(&router_conv);
45124         }
45125         LDKMultiThreadedLockableScore scorer_conv;
45126         scorer_conv.inner = (void*)(scorer & (~1));
45127         scorer_conv.is_owned = false;
45128         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
45129         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45130         CHECK_ACCESS(logger_ptr);
45131         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45132         if (logger_conv.free == LDKLogger_JCalls_free) {
45133                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45134                 LDKLogger_JCalls_cloned(&logger_conv);
45135         }
45136         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
45137         CHECK_ACCESS(event_handler_ptr);
45138         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45139         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45140                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45141                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45142         }
45143         LDKRetryAttempts retry_attempts_conv;
45144         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
45145         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
45146         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
45147         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
45148         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
45149         int64_t ret_ref = 0;
45150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45153         ret_ref = (uintptr_t)ret_var.inner;
45154         if (ret_var.is_owned) {
45155                 ret_ref |= 1;
45156         }
45157         return ret_ref;
45158 }
45159
45160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
45161         LDKInvoicePayer this_arg_conv;
45162         this_arg_conv.inner = (void*)(this_arg & (~1));
45163         this_arg_conv.is_owned = false;
45164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45165         LDKInvoice invoice_conv;
45166         invoice_conv.inner = (void*)(invoice & (~1));
45167         invoice_conv.is_owned = false;
45168         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45169         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45170         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
45171         return (int64_t)ret_conv;
45172 }
45173
45174 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) {
45175         LDKInvoicePayer this_arg_conv;
45176         this_arg_conv.inner = (void*)(this_arg & (~1));
45177         this_arg_conv.is_owned = false;
45178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45179         LDKInvoice invoice_conv;
45180         invoice_conv.inner = (void*)(invoice & (~1));
45181         invoice_conv.is_owned = false;
45182         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45183         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45184         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
45185         return (int64_t)ret_conv;
45186 }
45187
45188 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) {
45189         LDKInvoicePayer this_arg_conv;
45190         this_arg_conv.inner = (void*)(this_arg & (~1));
45191         this_arg_conv.is_owned = false;
45192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45193         LDKPublicKey pubkey_ref;
45194         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
45195         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
45196         LDKThirtyTwoBytes payment_preimage_ref;
45197         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
45198         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
45199         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45200         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
45201         return (int64_t)ret_conv;
45202 }
45203
45204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
45205         LDKInvoicePayer this_arg_conv;
45206         this_arg_conv.inner = (void*)(this_arg & (~1));
45207         this_arg_conv.is_owned = false;
45208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45209         unsigned char payment_hash_arr[32];
45210         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
45211         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
45212         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
45213         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
45214 }
45215
45216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
45217         LDKInvoicePayer this_arg_conv;
45218         this_arg_conv.inner = (void*)(this_arg & (~1));
45219         this_arg_conv.is_owned = false;
45220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45221         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
45222         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
45223         return (int64_t)ret_ret;
45224 }
45225
45226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, jstring description, int8_tArray payment_hash, int8_tArray payment_secret, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
45227         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45228         CHECK_ACCESS(amt_msat_ptr);
45229         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45230         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45231         LDKStr description_conv = java_to_owned_str(env, description);
45232         LDKThirtyTwoBytes payment_hash_ref;
45233         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
45234         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
45235         LDKThirtyTwoBytes payment_secret_ref;
45236         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
45237         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
45238         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
45239         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
45240         if (phantom_route_hints_constr.datalen > 0)
45241                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
45242         else
45243                 phantom_route_hints_constr.data = NULL;
45244         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
45245         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
45246                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
45247                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
45248                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
45249                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
45250                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
45251                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
45252                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
45253         }
45254         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
45255         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45256         CHECK_ACCESS(keys_manager_ptr);
45257         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45258         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45259                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45260                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45261         }
45262         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
45263         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45264         *ret_conv = create_phantom_invoice(amt_msat_conv, description_conv, payment_hash_ref, payment_secret_ref, phantom_route_hints_constr, keys_manager_conv, network_conv);
45265         return (int64_t)ret_conv;
45266 }
45267
45268 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) {
45269         LDKChannelManager channelmanager_conv;
45270         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45271         channelmanager_conv.is_owned = false;
45272         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45273         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45274         CHECK_ACCESS(keys_manager_ptr);
45275         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45276         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45277                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45278                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45279         }
45280         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
45281         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45282         CHECK_ACCESS(amt_msat_ptr);
45283         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45284         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45285         LDKStr description_conv = java_to_owned_str(env, description);
45286         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45287         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
45288         return (int64_t)ret_conv;
45289 }
45290
45291 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) {
45292         LDKChannelManager channelmanager_conv;
45293         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45294         channelmanager_conv.is_owned = false;
45295         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45296         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45297         CHECK_ACCESS(keys_manager_ptr);
45298         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45299         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45300                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45301                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45302         }
45303         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
45304         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45305         CHECK_ACCESS(amt_msat_ptr);
45306         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45307         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45308         LDKStr description_conv = java_to_owned_str(env, description);
45309         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45310         *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);
45311         return (int64_t)ret_conv;
45312 }
45313
45314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45315         LDKDefaultRouter this_obj_conv;
45316         this_obj_conv.inner = (void*)(this_obj & (~1));
45317         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45319         DefaultRouter_free(this_obj_conv);
45320 }
45321
45322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
45323         LDKNetworkGraph network_graph_conv;
45324         network_graph_conv.inner = (void*)(network_graph & (~1));
45325         network_graph_conv.is_owned = false;
45326         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45327         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45328         CHECK_ACCESS(logger_ptr);
45329         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45330         if (logger_conv.free == LDKLogger_JCalls_free) {
45331                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45332                 LDKLogger_JCalls_cloned(&logger_conv);
45333         }
45334         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
45335         int64_t ret_ref = 0;
45336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45339         ret_ref = (uintptr_t)ret_var.inner;
45340         if (ret_var.is_owned) {
45341                 ret_ref |= 1;
45342         }
45343         return ret_ref;
45344 }
45345
45346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
45347         LDKDefaultRouter this_arg_conv;
45348         this_arg_conv.inner = (void*)(this_arg & (~1));
45349         this_arg_conv.is_owned = false;
45350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45351         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
45352         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
45353         return (int64_t)ret_ret;
45354 }
45355
45356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
45357         LDKChannelManager this_arg_conv;
45358         this_arg_conv.inner = (void*)(this_arg & (~1));
45359         this_arg_conv.is_owned = false;
45360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45361         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
45362         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
45363         return (int64_t)ret_ret;
45364 }
45365
45366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
45367         LDKStr s_conv = java_to_owned_str(env, s);
45368         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
45369         *ret_conv = SiPrefix_from_str(s_conv);
45370         return (int64_t)ret_conv;
45371 }
45372
45373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
45374         LDKStr s_conv = java_to_owned_str(env, s);
45375         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
45376         *ret_conv = Invoice_from_str(s_conv);
45377         return (int64_t)ret_conv;
45378 }
45379
45380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
45381         LDKStr s_conv = java_to_owned_str(env, s);
45382         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
45383         *ret_conv = SignedRawInvoice_from_str(s_conv);
45384         return (int64_t)ret_conv;
45385 }
45386
45387 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45388         LDKInvoice o_conv;
45389         o_conv.inner = (void*)(o & (~1));
45390         o_conv.is_owned = false;
45391         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45392         LDKStr ret_str = Invoice_to_str(&o_conv);
45393         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45394         Str_free(ret_str);
45395         return ret_conv;
45396 }
45397
45398 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45399         LDKSignedRawInvoice o_conv;
45400         o_conv.inner = (void*)(o & (~1));
45401         o_conv.is_owned = false;
45402         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45403         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
45404         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45405         Str_free(ret_str);
45406         return ret_conv;
45407 }
45408
45409 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45410         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
45411         LDKStr ret_str = Currency_to_str(o_conv);
45412         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45413         Str_free(ret_str);
45414         return ret_conv;
45415 }
45416
45417 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45418         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
45419         LDKStr ret_str = SiPrefix_to_str(o_conv);
45420         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45421         Str_free(ret_str);
45422         return ret_conv;
45423 }
45424