Update auto-updated Java files
[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_ExpiryTimeOutOfBounds;
311                 case 4: return LDKCreationError_InvalidAmount;
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_ExpiryTimeOutOfBounds = NULL;
321 static jfieldID CreationError_LDKCreationError_InvalidAmount = 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_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
333         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
334         CHECK(CreationError_LDKCreationError_InvalidAmount != 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_ExpiryTimeOutOfBounds:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
346                 case LDKCreationError_InvalidAmount:
347                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
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 LDKSecp256k1Error LDKSecp256k1Error_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 Secp256k1Error.ordinal() from rust threw an exception.");
643         }
644         switch (ord) {
645                 case 0: return LDKSecp256k1Error_IncorrectSignature;
646                 case 1: return LDKSecp256k1Error_InvalidMessage;
647                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
648                 case 3: return LDKSecp256k1Error_InvalidSignature;
649                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
650                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
651                 case 6: return LDKSecp256k1Error_InvalidTweak;
652                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
653                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
654         }
655         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
656         abort(); // Unreachable, but will let the compiler know we don't return here
657 }
658 static jclass Secp256k1Error_class = NULL;
659 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
660 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
661 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
662 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
663 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
664 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
665 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
666 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
667 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
668 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
669         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
670         CHECK(Secp256k1Error_class != NULL);
671         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
672         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
673         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
674         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
675         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
676         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
677         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
678         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
679         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
680         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
681         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
682         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
683         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
684         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
685         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
686         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
687         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
688         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
689 }
690 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
691         switch (val) {
692                 case LDKSecp256k1Error_IncorrectSignature:
693                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
694                 case LDKSecp256k1Error_InvalidMessage:
695                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
696                 case LDKSecp256k1Error_InvalidPublicKey:
697                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
698                 case LDKSecp256k1Error_InvalidSignature:
699                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
700                 case LDKSecp256k1Error_InvalidSecretKey:
701                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
702                 case LDKSecp256k1Error_InvalidRecoveryId:
703                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
704                 case LDKSecp256k1Error_InvalidTweak:
705                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
706                 case LDKSecp256k1Error_TweakCheckFailed:
707                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
708                 case LDKSecp256k1Error_NotEnoughMemory:
709                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
710                 default: abort();
711         }
712 }
713
714 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
715         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
716         if (UNLIKELY((*env)->ExceptionCheck(env))) {
717                 (*env)->ExceptionDescribe(env);
718                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
719         }
720         switch (ord) {
721                 case 0: return LDKSemanticError_NoPaymentHash;
722                 case 1: return LDKSemanticError_MultiplePaymentHashes;
723                 case 2: return LDKSemanticError_NoDescription;
724                 case 3: return LDKSemanticError_MultipleDescriptions;
725                 case 4: return LDKSemanticError_NoPaymentSecret;
726                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
727                 case 6: return LDKSemanticError_InvalidFeatures;
728                 case 7: return LDKSemanticError_InvalidRecoveryId;
729                 case 8: return LDKSemanticError_InvalidSignature;
730                 case 9: return LDKSemanticError_ImpreciseAmount;
731         }
732         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
733         abort(); // Unreachable, but will let the compiler know we don't return here
734 }
735 static jclass SemanticError_class = NULL;
736 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
737 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
738 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
739 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
740 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
741 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
742 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
743 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
744 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
745 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
746 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
747         SemanticError_class = (*env)->NewGlobalRef(env, clz);
748         CHECK(SemanticError_class != NULL);
749         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
750         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
751         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
752         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
753         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
754         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
755         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
756         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
757         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
758         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
759         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
760         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
761         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
762         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
763         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
764         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
765         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
766         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
767         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
768         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
769 }
770 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
771         switch (val) {
772                 case LDKSemanticError_NoPaymentHash:
773                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
774                 case LDKSemanticError_MultiplePaymentHashes:
775                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
776                 case LDKSemanticError_NoDescription:
777                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
778                 case LDKSemanticError_MultipleDescriptions:
779                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
780                 case LDKSemanticError_NoPaymentSecret:
781                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
782                 case LDKSemanticError_MultiplePaymentSecrets:
783                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
784                 case LDKSemanticError_InvalidFeatures:
785                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
786                 case LDKSemanticError_InvalidRecoveryId:
787                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
788                 case LDKSemanticError_InvalidSignature:
789                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
790                 case LDKSemanticError_ImpreciseAmount:
791                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
792                 default: abort();
793         }
794 }
795
796 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
797         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
798         if (UNLIKELY((*env)->ExceptionCheck(env))) {
799                 (*env)->ExceptionDescribe(env);
800                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
801         }
802         switch (ord) {
803                 case 0: return LDKSiPrefix_Milli;
804                 case 1: return LDKSiPrefix_Micro;
805                 case 2: return LDKSiPrefix_Nano;
806                 case 3: return LDKSiPrefix_Pico;
807         }
808         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
809         abort(); // Unreachable, but will let the compiler know we don't return here
810 }
811 static jclass SiPrefix_class = NULL;
812 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
813 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
814 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
815 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
816 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
817         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
818         CHECK(SiPrefix_class != NULL);
819         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
820         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
821         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
822         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
823         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
824         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
825         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
826         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
827 }
828 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
829         switch (val) {
830                 case LDKSiPrefix_Milli:
831                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
832                 case LDKSiPrefix_Micro:
833                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
834                 case LDKSiPrefix_Nano:
835                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
836                 case LDKSiPrefix_Pico:
837                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
838                 default: abort();
839         }
840 }
841
842 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
843         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
844         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
845         return ret;
846 }
847 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) {
848         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
849         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
850         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
851         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
852         CVec_u8Z_free(ret_var);
853         return ret_arr;
854 }
855
856 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) {
857         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
858         int64_t ret_val = TxOut_get_value(thing_conv);
859         return ret_val;
860 }
861
862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
863         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
864         CHECK(val->result_ok);
865         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
866         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
867         return res_arr;
868 }
869 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
870         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
871         CHECK(!val->result_ok);
872         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
873         return err_conv;
874 }
875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
876         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
877         CHECK(val->result_ok);
878         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
879         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
880         return res_arr;
881 }
882 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
883         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
884         CHECK(!val->result_ok);
885         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
886         return err_conv;
887 }
888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
889         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
890         CHECK(val->result_ok);
891         LDKTxCreationKeys res_var = (*val->contents.result);
892         uint64_t res_ref = 0;
893         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
894         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
895         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
896         res_ref = (uint64_t)res_var.inner & ~1;
897         return res_ref;
898 }
899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
900         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
901         CHECK(!val->result_ok);
902         LDKDecodeError err_var = (*val->contents.err);
903         uint64_t err_ref = 0;
904         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
905         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
906         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
907         err_ref = (uint64_t)err_var.inner & ~1;
908         return err_ref;
909 }
910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
911         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
912         CHECK(val->result_ok);
913         LDKChannelPublicKeys res_var = (*val->contents.result);
914         uint64_t res_ref = 0;
915         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
916         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
917         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
918         res_ref = (uint64_t)res_var.inner & ~1;
919         return res_ref;
920 }
921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
922         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
923         CHECK(!val->result_ok);
924         LDKDecodeError err_var = (*val->contents.err);
925         uint64_t err_ref = 0;
926         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
927         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
928         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
929         err_ref = (uint64_t)err_var.inner & ~1;
930         return err_ref;
931 }
932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
933         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
934         CHECK(val->result_ok);
935         LDKTxCreationKeys res_var = (*val->contents.result);
936         uint64_t res_ref = 0;
937         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
938         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
939         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
940         res_ref = (uint64_t)res_var.inner & ~1;
941         return res_ref;
942 }
943 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
944         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
945         CHECK(!val->result_ok);
946         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
947         return err_conv;
948 }
949 static jclass LDKCOption_u32Z_Some_class = NULL;
950 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
951 static jclass LDKCOption_u32Z_None_class = NULL;
952 static jmethodID LDKCOption_u32Z_None_meth = NULL;
953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
954         LDKCOption_u32Z_Some_class =
955                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
956         CHECK(LDKCOption_u32Z_Some_class != NULL);
957         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
958         CHECK(LDKCOption_u32Z_Some_meth != NULL);
959         LDKCOption_u32Z_None_class =
960                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
961         CHECK(LDKCOption_u32Z_None_class != NULL);
962         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
963         CHECK(LDKCOption_u32Z_None_meth != NULL);
964 }
965 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
966         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
967         switch(obj->tag) {
968                 case LDKCOption_u32Z_Some: {
969                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
970                 }
971                 case LDKCOption_u32Z_None: {
972                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
973                 }
974                 default: abort();
975         }
976 }
977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
978         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
979         CHECK(val->result_ok);
980         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
981         uint64_t res_ref = 0;
982         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
983         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
984         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
985         res_ref = (uint64_t)res_var.inner & ~1;
986         return res_ref;
987 }
988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
989         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
990         CHECK(!val->result_ok);
991         LDKDecodeError err_var = (*val->contents.err);
992         uint64_t err_ref = 0;
993         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
994         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
995         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
996         err_ref = (uint64_t)err_var.inner & ~1;
997         return err_ref;
998 }
999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1000         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1001         CHECK(val->result_ok);
1002         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
1003         uint64_t res_ref = 0;
1004         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1005         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1006         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1007         res_ref = (uint64_t)res_var.inner & ~1;
1008         return res_ref;
1009 }
1010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1011         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1012         CHECK(!val->result_ok);
1013         LDKDecodeError err_var = (*val->contents.err);
1014         uint64_t err_ref = 0;
1015         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1016         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1017         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1018         err_ref = (uint64_t)err_var.inner & ~1;
1019         return err_ref;
1020 }
1021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1022         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1023         CHECK(val->result_ok);
1024         LDKChannelTransactionParameters res_var = (*val->contents.result);
1025         uint64_t res_ref = 0;
1026         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1027         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1028         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1029         res_ref = (uint64_t)res_var.inner & ~1;
1030         return res_ref;
1031 }
1032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1033         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
1034         CHECK(!val->result_ok);
1035         LDKDecodeError err_var = (*val->contents.err);
1036         uint64_t err_ref = 0;
1037         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1038         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1039         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1040         err_ref = (uint64_t)err_var.inner & ~1;
1041         return err_ref;
1042 }
1043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1044         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1045         CHECK(val->result_ok);
1046         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
1047         uint64_t res_ref = 0;
1048         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1049         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1050         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1051         res_ref = (uint64_t)res_var.inner & ~1;
1052         return res_ref;
1053 }
1054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1055         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1056         CHECK(!val->result_ok);
1057         LDKDecodeError err_var = (*val->contents.err);
1058         uint64_t err_ref = 0;
1059         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1060         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1061         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1062         err_ref = (uint64_t)err_var.inner & ~1;
1063         return err_ref;
1064 }
1065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1066         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1067         CHECK(val->result_ok);
1068         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
1069         uint64_t res_ref = 0;
1070         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1071         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1072         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1073         res_ref = (uint64_t)res_var.inner & ~1;
1074         return res_ref;
1075 }
1076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1077         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
1078         CHECK(!val->result_ok);
1079         LDKDecodeError err_var = (*val->contents.err);
1080         uint64_t err_ref = 0;
1081         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1082         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1083         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1084         err_ref = (uint64_t)err_var.inner & ~1;
1085         return err_ref;
1086 }
1087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1088         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
1089         CHECK(val->result_ok);
1090         LDKTrustedClosingTransaction res_var = (*val->contents.result);
1091         uint64_t res_ref = 0;
1092         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1093         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1094         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1095         res_ref = (uint64_t)res_var.inner & ~1;
1096         return res_ref;
1097 }
1098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1099         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
1100         CHECK(!val->result_ok);
1101         return *val->contents.err;
1102 }
1103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1104         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1105         CHECK(val->result_ok);
1106         LDKCommitmentTransaction res_var = (*val->contents.result);
1107         uint64_t res_ref = 0;
1108         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1109         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1110         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1111         res_ref = (uint64_t)res_var.inner & ~1;
1112         return res_ref;
1113 }
1114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1115         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1116         CHECK(!val->result_ok);
1117         LDKDecodeError err_var = (*val->contents.err);
1118         uint64_t err_ref = 0;
1119         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1120         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1121         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1122         err_ref = (uint64_t)err_var.inner & ~1;
1123         return err_ref;
1124 }
1125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1126         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1127         CHECK(val->result_ok);
1128         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1129         uint64_t res_ref = 0;
1130         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1131         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1132         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1133         res_ref = (uint64_t)res_var.inner & ~1;
1134         return res_ref;
1135 }
1136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1137         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1138         CHECK(!val->result_ok);
1139         return *val->contents.err;
1140 }
1141 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1142         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1143         CHECK(val->result_ok);
1144         LDKCVec_SignatureZ res_var = (*val->contents.result);
1145         jobjectArray res_arr = NULL;
1146         res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1147         ;
1148         for (size_t i = 0; i < res_var.datalen; i++) {
1149                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1150                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1151                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1152         }
1153         
1154         return res_arr;
1155 }
1156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1157         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1158         CHECK(!val->result_ok);
1159         return *val->contents.err;
1160 }
1161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1162         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1163         CHECK(val->result_ok);
1164         LDKShutdownScript res_var = (*val->contents.result);
1165         uint64_t res_ref = 0;
1166         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1167         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1168         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1169         res_ref = (uint64_t)res_var.inner & ~1;
1170         return res_ref;
1171 }
1172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1173         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1174         CHECK(!val->result_ok);
1175         LDKDecodeError err_var = (*val->contents.err);
1176         uint64_t err_ref = 0;
1177         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1178         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1179         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1180         err_ref = (uint64_t)err_var.inner & ~1;
1181         return err_ref;
1182 }
1183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1184         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1185         CHECK(val->result_ok);
1186         LDKShutdownScript res_var = (*val->contents.result);
1187         uint64_t res_ref = 0;
1188         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1189         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1190         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1191         res_ref = (uint64_t)res_var.inner & ~1;
1192         return res_ref;
1193 }
1194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1195         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1196         CHECK(!val->result_ok);
1197         LDKInvalidShutdownScript err_var = (*val->contents.err);
1198         uint64_t err_ref = 0;
1199         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1200         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1201         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1202         err_ref = (uint64_t)err_var.inner & ~1;
1203         return err_ref;
1204 }
1205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1206         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1207         CHECK(val->result_ok);
1208         return *val->contents.result;
1209 }
1210 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1211         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1212         CHECK(!val->result_ok);
1213         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1214         return err_conv;
1215 }
1216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1217         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1218         CHECK(val->result_ok);
1219         LDKRouteHop res_var = (*val->contents.result);
1220         uint64_t res_ref = 0;
1221         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1222         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1223         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1224         res_ref = (uint64_t)res_var.inner & ~1;
1225         return res_ref;
1226 }
1227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1228         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1229         CHECK(!val->result_ok);
1230         LDKDecodeError err_var = (*val->contents.err);
1231         uint64_t err_ref = 0;
1232         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1233         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1234         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1235         err_ref = (uint64_t)err_var.inner & ~1;
1236         return err_ref;
1237 }
1238 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1239         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1240         for (size_t i = 0; i < ret.datalen; i++) {
1241                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1242         }
1243         return ret;
1244 }
1245 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1246         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1247         for (size_t i = 0; i < ret.datalen; i++) {
1248                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1249         }
1250         return ret;
1251 }
1252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1253         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1254         CHECK(val->result_ok);
1255         LDKRoute res_var = (*val->contents.result);
1256         uint64_t res_ref = 0;
1257         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1258         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1259         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1260         res_ref = (uint64_t)res_var.inner & ~1;
1261         return res_ref;
1262 }
1263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1264         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1265         CHECK(!val->result_ok);
1266         LDKDecodeError err_var = (*val->contents.err);
1267         uint64_t err_ref = 0;
1268         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1269         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1270         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1271         err_ref = (uint64_t)err_var.inner & ~1;
1272         return err_ref;
1273 }
1274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1275         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
1276         CHECK(val->result_ok);
1277         LDKRouteParameters res_var = (*val->contents.result);
1278         uint64_t res_ref = 0;
1279         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1280         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1281         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1282         res_ref = (uint64_t)res_var.inner & ~1;
1283         return res_ref;
1284 }
1285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1286         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
1287         CHECK(!val->result_ok);
1288         LDKDecodeError err_var = (*val->contents.err);
1289         uint64_t err_ref = 0;
1290         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1291         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1292         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1293         err_ref = (uint64_t)err_var.inner & ~1;
1294         return err_ref;
1295 }
1296 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1297         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1298         for (size_t i = 0; i < ret.datalen; i++) {
1299                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1300         }
1301         return ret;
1302 }
1303 static jclass LDKCOption_u64Z_Some_class = NULL;
1304 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1305 static jclass LDKCOption_u64Z_None_class = NULL;
1306 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1308         LDKCOption_u64Z_Some_class =
1309                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1310         CHECK(LDKCOption_u64Z_Some_class != NULL);
1311         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1312         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1313         LDKCOption_u64Z_None_class =
1314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1315         CHECK(LDKCOption_u64Z_None_class != NULL);
1316         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1317         CHECK(LDKCOption_u64Z_None_meth != NULL);
1318 }
1319 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1320         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1321         switch(obj->tag) {
1322                 case LDKCOption_u64Z_Some: {
1323                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1324                 }
1325                 case LDKCOption_u64Z_None: {
1326                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1327                 }
1328                 default: abort();
1329         }
1330 }
1331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1332         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
1333         CHECK(val->result_ok);
1334         LDKPayee res_var = (*val->contents.result);
1335         uint64_t res_ref = 0;
1336         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1337         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1338         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1339         res_ref = (uint64_t)res_var.inner & ~1;
1340         return res_ref;
1341 }
1342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1343         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
1344         CHECK(!val->result_ok);
1345         LDKDecodeError err_var = (*val->contents.err);
1346         uint64_t err_ref = 0;
1347         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1348         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1349         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1350         err_ref = (uint64_t)err_var.inner & ~1;
1351         return err_ref;
1352 }
1353 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1354         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1355         for (size_t i = 0; i < ret.datalen; i++) {
1356                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1357         }
1358         return ret;
1359 }
1360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1361         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
1362         CHECK(val->result_ok);
1363         LDKRouteHint res_var = (*val->contents.result);
1364         uint64_t res_ref = 0;
1365         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1366         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1367         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1368         res_ref = (uint64_t)res_var.inner & ~1;
1369         return res_ref;
1370 }
1371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1372         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
1373         CHECK(!val->result_ok);
1374         LDKDecodeError err_var = (*val->contents.err);
1375         uint64_t err_ref = 0;
1376         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1377         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1378         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1379         err_ref = (uint64_t)err_var.inner & ~1;
1380         return err_ref;
1381 }
1382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1383         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
1384         CHECK(val->result_ok);
1385         LDKRouteHintHop res_var = (*val->contents.result);
1386         uint64_t res_ref = 0;
1387         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1388         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1389         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1390         res_ref = (uint64_t)res_var.inner & ~1;
1391         return res_ref;
1392 }
1393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1394         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
1395         CHECK(!val->result_ok);
1396         LDKDecodeError err_var = (*val->contents.err);
1397         uint64_t err_ref = 0;
1398         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1399         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1400         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1401         err_ref = (uint64_t)err_var.inner & ~1;
1402         return err_ref;
1403 }
1404 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1405         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1406         for (size_t i = 0; i < ret.datalen; i++) {
1407                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1408         }
1409         return ret;
1410 }
1411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1412         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1413         CHECK(val->result_ok);
1414         LDKRoute res_var = (*val->contents.result);
1415         uint64_t res_ref = 0;
1416         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1417         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1418         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1419         res_ref = (uint64_t)res_var.inner & ~1;
1420         return res_ref;
1421 }
1422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1423         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1424         CHECK(!val->result_ok);
1425         LDKLightningError err_var = (*val->contents.err);
1426         uint64_t err_ref = 0;
1427         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1428         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1429         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1430         err_ref = (uint64_t)err_var.inner & ~1;
1431         return err_ref;
1432 }
1433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1434         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1435         CHECK(val->result_ok);
1436         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1437         return (uint64_t)res_ref;
1438 }
1439 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1440         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1441         CHECK(!val->result_ok);
1442         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1443         return err_conv;
1444 }
1445 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1446         return tuple->a;
1447 }
1448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
1449         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1450         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
1451         return ret_val;
1452 }
1453
1454 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1455         return tuple->b;
1456 }
1457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
1458         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1459         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
1460         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1461         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1462         Transaction_free(ret_var);
1463         return ret_arr;
1464 }
1465
1466 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1467         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1468         for (size_t i = 0; i < ret.datalen; i++) {
1469                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1470         }
1471         return ret;
1472 }
1473 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1474         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1475         for (size_t i = 0; i < ret.datalen; i++) {
1476                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1477         }
1478         return ret;
1479 }
1480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1481         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1482         CHECK(val->result_ok);
1483         return *val->contents.result;
1484 }
1485 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1486         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1487         CHECK(!val->result_ok);
1488         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1489         return err_conv;
1490 }
1491 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1492 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1493 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1494 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1495 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1496 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1497 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1498 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1500         LDKMonitorEvent_HTLCEvent_class =
1501                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
1502         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1503         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1504         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1505         LDKMonitorEvent_CommitmentTxConfirmed_class =
1506                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
1507         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1508         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1509         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1510         LDKMonitorEvent_UpdateCompleted_class =
1511                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
1512         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1513         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1514         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1515         LDKMonitorEvent_UpdateFailed_class =
1516                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
1517         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
1518         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
1519         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
1520 }
1521 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1522         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1523         switch(obj->tag) {
1524                 case LDKMonitorEvent_HTLCEvent: {
1525                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1526                         uint64_t htlc_event_ref = 0;
1527                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1528                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1529                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1530                         htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1531                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1532                 }
1533                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1534                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1535                         uint64_t commitment_tx_confirmed_ref = 0;
1536                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1537                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1538                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1539                         commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
1540                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
1541                 }
1542                 case LDKMonitorEvent_UpdateCompleted: {
1543                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1544                         uint64_t funding_txo_ref = 0;
1545                         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1546                         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1547                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1548                         funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
1549                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
1550                 }
1551                 case LDKMonitorEvent_UpdateFailed: {
1552                         LDKOutPoint update_failed_var = obj->update_failed;
1553                         uint64_t update_failed_ref = 0;
1554                         CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1555                         CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1556                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1557                         update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
1558                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
1559                 }
1560                 default: abort();
1561         }
1562 }
1563 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1564         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1565         for (size_t i = 0; i < ret.datalen; i++) {
1566                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1567         }
1568         return ret;
1569 }
1570 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1571 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1572 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1573 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1575         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1576                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
1577         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1578         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1579         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1580         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1581                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
1582         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1583         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1584         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1585 }
1586 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1587         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1588         switch(obj->tag) {
1589                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1590                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1591                         *some_conv = obj->some;
1592                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1593                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((uint64_t)some_conv));
1594                 }
1595                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1596                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1597                 }
1598                 default: abort();
1599         }
1600 }
1601 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1602 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1603 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1604 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1605 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1606 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1607 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1608 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1609 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
1610 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
1611 static jclass LDKClosureReason_ProcessingError_class = NULL;
1612 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1613 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1614 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1615 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1616 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1618         LDKClosureReason_CounterpartyForceClosed_class =
1619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
1620         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
1621         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
1622         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
1623         LDKClosureReason_HolderForceClosed_class =
1624                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
1625         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
1626         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
1627         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
1628         LDKClosureReason_CooperativeClosure_class =
1629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
1630         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
1631         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
1632         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
1633         LDKClosureReason_CommitmentTxConfirmed_class =
1634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
1635         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
1636         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
1637         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
1638         LDKClosureReason_FundingTimedOut_class =
1639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
1640         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
1641         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
1642         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
1643         LDKClosureReason_ProcessingError_class =
1644                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
1645         CHECK(LDKClosureReason_ProcessingError_class != NULL);
1646         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
1647         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
1648         LDKClosureReason_DisconnectedPeer_class =
1649                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
1650         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
1651         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
1652         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
1653         LDKClosureReason_OutdatedChannelManager_class =
1654                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
1655         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
1656         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
1657         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
1658 }
1659 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1660         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1661         switch(obj->tag) {
1662                 case LDKClosureReason_CounterpartyForceClosed: {
1663                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1664                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
1665                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
1666                 }
1667                 case LDKClosureReason_HolderForceClosed: {
1668                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
1669                 }
1670                 case LDKClosureReason_CooperativeClosure: {
1671                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
1672                 }
1673                 case LDKClosureReason_CommitmentTxConfirmed: {
1674                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
1675                 }
1676                 case LDKClosureReason_FundingTimedOut: {
1677                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
1678                 }
1679                 case LDKClosureReason_ProcessingError: {
1680                         LDKStr err_str = obj->processing_error.err;
1681                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1682                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
1683                 }
1684                 case LDKClosureReason_DisconnectedPeer: {
1685                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
1686                 }
1687                 case LDKClosureReason_OutdatedChannelManager: {
1688                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
1689                 }
1690                 default: abort();
1691         }
1692 }
1693 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
1694 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
1695 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
1696 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
1697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
1698         LDKCOption_ClosureReasonZ_Some_class =
1699                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
1700         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
1701         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
1702         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
1703         LDKCOption_ClosureReasonZ_None_class =
1704                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
1705         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
1706         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
1707         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
1708 }
1709 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1710         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1711         switch(obj->tag) {
1712                 case LDKCOption_ClosureReasonZ_Some: {
1713                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1714                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
1715                 }
1716                 case LDKCOption_ClosureReasonZ_None: {
1717                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
1718                 }
1719                 default: abort();
1720         }
1721 }
1722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1723         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1724         CHECK(val->result_ok);
1725         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1726         return res_ref;
1727 }
1728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1729         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1730         CHECK(!val->result_ok);
1731         LDKDecodeError err_var = (*val->contents.err);
1732         uint64_t err_ref = 0;
1733         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1734         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1735         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1736         err_ref = (uint64_t)err_var.inner & ~1;
1737         return err_ref;
1738 }
1739 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
1740 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
1741 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
1742 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
1743 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
1744 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
1745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
1746         LDKNetworkUpdate_ChannelUpdateMessage_class =
1747                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
1748         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
1749         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1750         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
1751         LDKNetworkUpdate_ChannelClosed_class =
1752                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed"));
1753         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
1754         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1755         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
1756         LDKNetworkUpdate_NodeFailure_class =
1757                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
1758         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
1759         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
1760         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
1761 }
1762 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1763         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1764         switch(obj->tag) {
1765                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1766                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1767                         uint64_t msg_ref = 0;
1768                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1769                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1770                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1771                         msg_ref = (uint64_t)msg_var.inner & ~1;
1772                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
1773                 }
1774                 case LDKNetworkUpdate_ChannelClosed: {
1775                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1776                 }
1777                 case LDKNetworkUpdate_NodeFailure: {
1778                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1779                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1780                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1781                 }
1782                 default: abort();
1783         }
1784 }
1785 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
1786 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
1787 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
1788 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
1789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
1790         LDKCOption_NetworkUpdateZ_Some_class =
1791                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
1792         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
1793         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
1794         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
1795         LDKCOption_NetworkUpdateZ_None_class =
1796                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
1797         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
1798         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
1799         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
1800 }
1801 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1802         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1803         switch(obj->tag) {
1804                 case LDKCOption_NetworkUpdateZ_Some: {
1805                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1806                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
1807                 }
1808                 case LDKCOption_NetworkUpdateZ_None: {
1809                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
1810                 }
1811                 default: abort();
1812         }
1813 }
1814 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1815 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1816 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1817 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1818 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1819 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1821         LDKSpendableOutputDescriptor_StaticOutput_class =
1822                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
1823         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1824         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1825         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1826         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
1828         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1829         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1830         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1831         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1832                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
1833         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1834         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1835         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1836 }
1837 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1838         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1839         switch(obj->tag) {
1840                 case LDKSpendableOutputDescriptor_StaticOutput: {
1841                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1842                         uint64_t outpoint_ref = 0;
1843                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1844                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1845                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1846                         outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1847                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1848                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1849                 }
1850                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1851                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1852                         uint64_t delayed_payment_output_ref = 0;
1853                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1854                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1855                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1856                         delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1857                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1858                 }
1859                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1860                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1861                         uint64_t static_payment_output_ref = 0;
1862                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1863                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1864                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1865                         static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1866                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1867                 }
1868                 default: abort();
1869         }
1870 }
1871 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1872         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1873         for (size_t i = 0; i < ret.datalen; i++) {
1874                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1875         }
1876         return ret;
1877 }
1878 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1879 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1880 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1881 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1883         LDKPaymentPurpose_InvoicePayment_class =
1884                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
1885         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1886         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
1887         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1888         LDKPaymentPurpose_SpontaneousPayment_class =
1889                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
1890         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1891         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1892         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1893 }
1894 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1895         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1896         switch(obj->tag) {
1897                 case LDKPaymentPurpose_InvoicePayment: {
1898                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1899                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1900                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1901                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1902                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
1903                 }
1904                 case LDKPaymentPurpose_SpontaneousPayment: {
1905                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1906                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1907                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1908                 }
1909                 default: abort();
1910         }
1911 }
1912 static jclass LDKEvent_FundingGenerationReady_class = NULL;
1913 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
1914 static jclass LDKEvent_PaymentReceived_class = NULL;
1915 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
1916 static jclass LDKEvent_PaymentSent_class = NULL;
1917 static jmethodID LDKEvent_PaymentSent_meth = NULL;
1918 static jclass LDKEvent_PaymentPathFailed_class = NULL;
1919 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
1920 static jclass LDKEvent_PaymentFailed_class = NULL;
1921 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
1922 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
1923 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
1924 static jclass LDKEvent_SpendableOutputs_class = NULL;
1925 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
1926 static jclass LDKEvent_PaymentForwarded_class = NULL;
1927 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
1928 static jclass LDKEvent_ChannelClosed_class = NULL;
1929 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
1930 static jclass LDKEvent_DiscardFunding_class = NULL;
1931 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
1932 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
1933 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
1934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
1935         LDKEvent_FundingGenerationReady_class =
1936                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
1937         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
1938         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
1939         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
1940         LDKEvent_PaymentReceived_class =
1941                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
1942         CHECK(LDKEvent_PaymentReceived_class != NULL);
1943         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
1944         CHECK(LDKEvent_PaymentReceived_meth != NULL);
1945         LDKEvent_PaymentSent_class =
1946                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
1947         CHECK(LDKEvent_PaymentSent_class != NULL);
1948         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
1949         CHECK(LDKEvent_PaymentSent_meth != NULL);
1950         LDKEvent_PaymentPathFailed_class =
1951                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
1952         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
1953         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
1954         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
1955         LDKEvent_PaymentFailed_class =
1956                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
1957         CHECK(LDKEvent_PaymentFailed_class != NULL);
1958         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
1959         CHECK(LDKEvent_PaymentFailed_meth != NULL);
1960         LDKEvent_PendingHTLCsForwardable_class =
1961                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
1962         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
1963         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
1964         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
1965         LDKEvent_SpendableOutputs_class =
1966                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
1967         CHECK(LDKEvent_SpendableOutputs_class != NULL);
1968         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
1969         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
1970         LDKEvent_PaymentForwarded_class =
1971                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
1972         CHECK(LDKEvent_PaymentForwarded_class != NULL);
1973         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
1974         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
1975         LDKEvent_ChannelClosed_class =
1976                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
1977         CHECK(LDKEvent_ChannelClosed_class != NULL);
1978         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
1979         CHECK(LDKEvent_ChannelClosed_meth != NULL);
1980         LDKEvent_DiscardFunding_class =
1981                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
1982         CHECK(LDKEvent_DiscardFunding_class != NULL);
1983         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
1984         CHECK(LDKEvent_DiscardFunding_meth != NULL);
1985         LDKEvent_PaymentPathSuccessful_class =
1986                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
1987         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
1988         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
1989         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
1990 }
1991 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1992         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1993         switch(obj->tag) {
1994                 case LDKEvent_FundingGenerationReady: {
1995                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
1996                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
1997                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1998                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
1999                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2000                         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);
2001                 }
2002                 case LDKEvent_PaymentReceived: {
2003                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2004                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2005                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
2006                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
2007                 }
2008                 case LDKEvent_PaymentSent: {
2009                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2010                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2011                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2012                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2013                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2014                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2015                         uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
2016                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2017                 }
2018                 case LDKEvent_PaymentPathFailed: {
2019                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2020                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2021                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2022                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2023                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
2024                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2025                         int64_tArray path_arr = NULL;
2026                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2027                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2028                         for (size_t k = 0; k < path_var.datalen; k++) {
2029                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2030                                 uint64_t path_conv_10_ref = 0;
2031                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2032                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2033                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2034                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
2035                                 path_arr_ptr[k] = path_conv_10_ref;
2036                         }
2037                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2038                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
2039                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2040                         uint64_t retry_ref = 0;
2041                         if ((uint64_t)retry_var.inner > 4096) {
2042                                 CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2043                                 CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2044                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2045                                 retry_ref = (uint64_t)retry_var.inner & ~1;
2046                         }
2047                         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);
2048                 }
2049                 case LDKEvent_PaymentFailed: {
2050                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2051                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2052                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2053                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2054                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2055                 }
2056                 case LDKEvent_PendingHTLCsForwardable: {
2057                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
2058                 }
2059                 case LDKEvent_SpendableOutputs: {
2060                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2061                         int64_tArray outputs_arr = NULL;
2062                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2063                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2064                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2065                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
2066                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2067                         }
2068                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2069                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2070                 }
2071                 case LDKEvent_PaymentForwarded: {
2072                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2073                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
2074                 }
2075                 case LDKEvent_ChannelClosed: {
2076                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2077                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2078                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
2079                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
2080                 }
2081                 case LDKEvent_DiscardFunding: {
2082                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2083                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2084                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2085                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2086                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2087                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2088                 }
2089                 case LDKEvent_PaymentPathSuccessful: {
2090                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2091                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2092                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2093                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2094                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2095                         int64_tArray path_arr = NULL;
2096                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2097                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2098                         for (size_t k = 0; k < path_var.datalen; k++) {
2099                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2100                                 uint64_t path_conv_10_ref = 0;
2101                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2102                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2103                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2104                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
2105                                 path_arr_ptr[k] = path_conv_10_ref;
2106                         }
2107                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2108                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2109                 }
2110                 default: abort();
2111         }
2112 }
2113 static jclass LDKCOption_EventZ_Some_class = NULL;
2114 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2115 static jclass LDKCOption_EventZ_None_class = NULL;
2116 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2118         LDKCOption_EventZ_Some_class =
2119                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2120         CHECK(LDKCOption_EventZ_Some_class != NULL);
2121         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2122         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2123         LDKCOption_EventZ_None_class =
2124                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2125         CHECK(LDKCOption_EventZ_None_class != NULL);
2126         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2127         CHECK(LDKCOption_EventZ_None_meth != NULL);
2128 }
2129 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2130         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2131         switch(obj->tag) {
2132                 case LDKCOption_EventZ_Some: {
2133                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
2134                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2135                 }
2136                 case LDKCOption_EventZ_None: {
2137                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2138                 }
2139                 default: abort();
2140         }
2141 }
2142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2143         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
2144         CHECK(val->result_ok);
2145         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2146         return res_ref;
2147 }
2148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2149         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
2150         CHECK(!val->result_ok);
2151         LDKDecodeError err_var = (*val->contents.err);
2152         uint64_t err_ref = 0;
2153         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2154         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2155         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2156         err_ref = (uint64_t)err_var.inner & ~1;
2157         return err_ref;
2158 }
2159 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2160 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2161 static jclass LDKErrorAction_IgnoreError_class = NULL;
2162 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2163 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2164 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2165 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2166 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2167 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2168 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2170         LDKErrorAction_DisconnectPeer_class =
2171                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2172         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2173         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2174         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2175         LDKErrorAction_IgnoreError_class =
2176                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2177         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2178         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2179         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2180         LDKErrorAction_IgnoreAndLog_class =
2181                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2182         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2183         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2184         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2185         LDKErrorAction_IgnoreDuplicateGossip_class =
2186                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2187         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2188         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2189         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2190         LDKErrorAction_SendErrorMessage_class =
2191                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2192         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2193         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2194         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2195 }
2196 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2197         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2198         switch(obj->tag) {
2199                 case LDKErrorAction_DisconnectPeer: {
2200                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2201                         uint64_t msg_ref = 0;
2202                         if ((uint64_t)msg_var.inner > 4096) {
2203                                 CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2204                                 CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2205                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2206                                 msg_ref = (uint64_t)msg_var.inner & ~1;
2207                         }
2208                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2209                 }
2210                 case LDKErrorAction_IgnoreError: {
2211                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2212                 }
2213                 case LDKErrorAction_IgnoreAndLog: {
2214                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2215                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2216                 }
2217                 case LDKErrorAction_IgnoreDuplicateGossip: {
2218                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2219                 }
2220                 case LDKErrorAction_SendErrorMessage: {
2221                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2222                         uint64_t msg_ref = 0;
2223                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2224                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2225                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2226                         msg_ref = (uint64_t)msg_var.inner & ~1;
2227                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2228                 }
2229                 default: abort();
2230         }
2231 }
2232 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2233 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2234 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2235 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2236 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2237 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2238 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2239 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2240 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2241 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2242 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2243 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2244 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2245 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2246 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2247 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2248 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2249 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2250 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2251 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2252 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2253 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2254 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2255 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2256 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2257 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2258 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2259 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2260 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2261 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2262 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2263 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2264 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2265 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2266 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2267 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2268 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2269 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2271         LDKMessageSendEvent_SendAcceptChannel_class =
2272                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2273         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2274         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2275         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2276         LDKMessageSendEvent_SendOpenChannel_class =
2277                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2278         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2279         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2280         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2281         LDKMessageSendEvent_SendFundingCreated_class =
2282                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2283         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2284         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2285         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2286         LDKMessageSendEvent_SendFundingSigned_class =
2287                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2288         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2289         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2290         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2291         LDKMessageSendEvent_SendFundingLocked_class =
2292                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked"));
2293         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2294         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2295         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2296         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2297                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2298         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2299         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2300         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2301         LDKMessageSendEvent_UpdateHTLCs_class =
2302                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2303         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2304         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2305         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2306         LDKMessageSendEvent_SendRevokeAndACK_class =
2307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2308         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2309         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2310         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2311         LDKMessageSendEvent_SendClosingSigned_class =
2312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2313         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2314         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2315         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2316         LDKMessageSendEvent_SendShutdown_class =
2317                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2318         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2319         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2320         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2321         LDKMessageSendEvent_SendChannelReestablish_class =
2322                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2323         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2324         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2325         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2326         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2327                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2328         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2329         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2330         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2331         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2333         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2334         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2335         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2336         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2337                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2338         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2339         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2340         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2341         LDKMessageSendEvent_SendChannelUpdate_class =
2342                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2343         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2344         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2345         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2346         LDKMessageSendEvent_HandleError_class =
2347                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2348         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2349         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2350         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2351         LDKMessageSendEvent_SendChannelRangeQuery_class =
2352                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2353         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2354         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2355         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2356         LDKMessageSendEvent_SendShortIdsQuery_class =
2357                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2358         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2359         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2360         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2361         LDKMessageSendEvent_SendReplyChannelRange_class =
2362                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2363         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2364         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2365         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2366 }
2367 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2368         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2369         switch(obj->tag) {
2370                 case LDKMessageSendEvent_SendAcceptChannel: {
2371                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2372                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2373                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2374                         uint64_t msg_ref = 0;
2375                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2376                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2377                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2378                         msg_ref = (uint64_t)msg_var.inner & ~1;
2379                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2380                 }
2381                 case LDKMessageSendEvent_SendOpenChannel: {
2382                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2383                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2384                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2385                         uint64_t msg_ref = 0;
2386                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2387                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2388                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2389                         msg_ref = (uint64_t)msg_var.inner & ~1;
2390                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2391                 }
2392                 case LDKMessageSendEvent_SendFundingCreated: {
2393                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2394                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2395                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2396                         uint64_t msg_ref = 0;
2397                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2398                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2399                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2400                         msg_ref = (uint64_t)msg_var.inner & ~1;
2401                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2402                 }
2403                 case LDKMessageSendEvent_SendFundingSigned: {
2404                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2405                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2406                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2407                         uint64_t msg_ref = 0;
2408                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2409                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2410                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2411                         msg_ref = (uint64_t)msg_var.inner & ~1;
2412                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2413                 }
2414                 case LDKMessageSendEvent_SendFundingLocked: {
2415                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2416                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2417                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2418                         uint64_t msg_ref = 0;
2419                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2420                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2421                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2422                         msg_ref = (uint64_t)msg_var.inner & ~1;
2423                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2424                 }
2425                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2426                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2427                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2428                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2429                         uint64_t msg_ref = 0;
2430                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2431                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2432                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2433                         msg_ref = (uint64_t)msg_var.inner & ~1;
2434                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2435                 }
2436                 case LDKMessageSendEvent_UpdateHTLCs: {
2437                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2438                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2439                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2440                         uint64_t updates_ref = 0;
2441                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2442                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2443                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2444                         updates_ref = (uint64_t)updates_var.inner & ~1;
2445                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2446                 }
2447                 case LDKMessageSendEvent_SendRevokeAndACK: {
2448                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2449                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2450                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2451                         uint64_t msg_ref = 0;
2452                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2453                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2454                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2455                         msg_ref = (uint64_t)msg_var.inner & ~1;
2456                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2457                 }
2458                 case LDKMessageSendEvent_SendClosingSigned: {
2459                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2460                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2461                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2462                         uint64_t msg_ref = 0;
2463                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2464                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2465                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2466                         msg_ref = (uint64_t)msg_var.inner & ~1;
2467                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2468                 }
2469                 case LDKMessageSendEvent_SendShutdown: {
2470                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2471                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2472                         LDKShutdown msg_var = obj->send_shutdown.msg;
2473                         uint64_t msg_ref = 0;
2474                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2475                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2476                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2477                         msg_ref = (uint64_t)msg_var.inner & ~1;
2478                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2479                 }
2480                 case LDKMessageSendEvent_SendChannelReestablish: {
2481                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2482                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2483                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2484                         uint64_t msg_ref = 0;
2485                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2486                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2487                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2488                         msg_ref = (uint64_t)msg_var.inner & ~1;
2489                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2490                 }
2491                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2492                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2493                         uint64_t msg_ref = 0;
2494                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2495                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2496                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2497                         msg_ref = (uint64_t)msg_var.inner & ~1;
2498                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2499                         uint64_t update_msg_ref = 0;
2500                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2501                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2502                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2503                         update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
2504                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2505                 }
2506                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2507                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2508                         uint64_t msg_ref = 0;
2509                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2510                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2511                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2512                         msg_ref = (uint64_t)msg_var.inner & ~1;
2513                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2514                 }
2515                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2516                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2517                         uint64_t msg_ref = 0;
2518                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2519                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2520                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2521                         msg_ref = (uint64_t)msg_var.inner & ~1;
2522                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2523                 }
2524                 case LDKMessageSendEvent_SendChannelUpdate: {
2525                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2526                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2527                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2528                         uint64_t msg_ref = 0;
2529                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2530                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2531                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2532                         msg_ref = (uint64_t)msg_var.inner & ~1;
2533                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2534                 }
2535                 case LDKMessageSendEvent_HandleError: {
2536                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2537                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2538                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
2539                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2540                 }
2541                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2542                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2543                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2544                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2545                         uint64_t msg_ref = 0;
2546                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2547                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2548                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2549                         msg_ref = (uint64_t)msg_var.inner & ~1;
2550                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2551                 }
2552                 case LDKMessageSendEvent_SendShortIdsQuery: {
2553                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2554                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2555                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2556                         uint64_t msg_ref = 0;
2557                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2558                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2559                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2560                         msg_ref = (uint64_t)msg_var.inner & ~1;
2561                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
2562                 }
2563                 case LDKMessageSendEvent_SendReplyChannelRange: {
2564                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2565                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
2566                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2567                         uint64_t msg_ref = 0;
2568                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2569                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2570                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2571                         msg_ref = (uint64_t)msg_var.inner & ~1;
2572                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2573                 }
2574                 default: abort();
2575         }
2576 }
2577 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2578         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2579         for (size_t i = 0; i < ret.datalen; i++) {
2580                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2581         }
2582         return ret;
2583 }
2584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2585         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
2586         CHECK(val->result_ok);
2587         LDKScoringParameters res_var = (*val->contents.result);
2588         uint64_t res_ref = 0;
2589         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2590         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2591         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2592         res_ref = (uint64_t)res_var.inner & ~1;
2593         return res_ref;
2594 }
2595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2596         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
2597         CHECK(!val->result_ok);
2598         LDKDecodeError err_var = (*val->contents.err);
2599         uint64_t err_ref = 0;
2600         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2601         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2602         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2603         err_ref = (uint64_t)err_var.inner & ~1;
2604         return err_ref;
2605 }
2606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2607         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
2608         CHECK(val->result_ok);
2609         LDKScorer res_var = (*val->contents.result);
2610         uint64_t res_ref = 0;
2611         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2612         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2613         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2614         res_ref = (uint64_t)res_var.inner & ~1;
2615         return res_ref;
2616 }
2617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2618         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
2619         CHECK(!val->result_ok);
2620         LDKDecodeError err_var = (*val->contents.err);
2621         uint64_t err_ref = 0;
2622         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2623         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2624         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2625         err_ref = (uint64_t)err_var.inner & ~1;
2626         return err_ref;
2627 }
2628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2629         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2630         CHECK(val->result_ok);
2631         LDKInitFeatures res_var = (*val->contents.result);
2632         uint64_t res_ref = 0;
2633         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2634         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2635         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2636         res_ref = (uint64_t)res_var.inner & ~1;
2637         return res_ref;
2638 }
2639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2640         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2641         CHECK(!val->result_ok);
2642         LDKDecodeError err_var = (*val->contents.err);
2643         uint64_t err_ref = 0;
2644         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2645         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2646         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2647         err_ref = (uint64_t)err_var.inner & ~1;
2648         return err_ref;
2649 }
2650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2651         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2652         CHECK(val->result_ok);
2653         LDKChannelFeatures res_var = (*val->contents.result);
2654         uint64_t res_ref = 0;
2655         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2656         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2657         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2658         res_ref = (uint64_t)res_var.inner & ~1;
2659         return res_ref;
2660 }
2661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2662         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2663         CHECK(!val->result_ok);
2664         LDKDecodeError err_var = (*val->contents.err);
2665         uint64_t err_ref = 0;
2666         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2667         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2668         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2669         err_ref = (uint64_t)err_var.inner & ~1;
2670         return err_ref;
2671 }
2672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2673         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2674         CHECK(val->result_ok);
2675         LDKNodeFeatures res_var = (*val->contents.result);
2676         uint64_t res_ref = 0;
2677         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2678         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2679         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2680         res_ref = (uint64_t)res_var.inner & ~1;
2681         return res_ref;
2682 }
2683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2684         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2685         CHECK(!val->result_ok);
2686         LDKDecodeError err_var = (*val->contents.err);
2687         uint64_t err_ref = 0;
2688         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2689         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2690         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2691         err_ref = (uint64_t)err_var.inner & ~1;
2692         return err_ref;
2693 }
2694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2695         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2696         CHECK(val->result_ok);
2697         LDKInvoiceFeatures res_var = (*val->contents.result);
2698         uint64_t res_ref = 0;
2699         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2700         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2701         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2702         res_ref = (uint64_t)res_var.inner & ~1;
2703         return res_ref;
2704 }
2705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2706         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2707         CHECK(!val->result_ok);
2708         LDKDecodeError err_var = (*val->contents.err);
2709         uint64_t err_ref = 0;
2710         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2711         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2712         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2713         err_ref = (uint64_t)err_var.inner & ~1;
2714         return err_ref;
2715 }
2716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2717         LDKCResult_ChannelTypeFeaturesDecodeErrorZ *val = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
2718         CHECK(val->result_ok);
2719         LDKChannelTypeFeatures res_var = (*val->contents.result);
2720         uint64_t res_ref = 0;
2721         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2722         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2723         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2724         res_ref = (uint64_t)res_var.inner & ~1;
2725         return res_ref;
2726 }
2727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2728         LDKCResult_ChannelTypeFeaturesDecodeErrorZ *val = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
2729         CHECK(!val->result_ok);
2730         LDKDecodeError err_var = (*val->contents.err);
2731         uint64_t err_ref = 0;
2732         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2733         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2734         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2735         err_ref = (uint64_t)err_var.inner & ~1;
2736         return err_ref;
2737 }
2738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2739         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2740         CHECK(val->result_ok);
2741         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2742         uint64_t res_ref = 0;
2743         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2744         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2745         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2746         res_ref = (uint64_t)res_var.inner & ~1;
2747         return res_ref;
2748 }
2749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2750         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2751         CHECK(!val->result_ok);
2752         LDKDecodeError err_var = (*val->contents.err);
2753         uint64_t err_ref = 0;
2754         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2755         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2756         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2757         err_ref = (uint64_t)err_var.inner & ~1;
2758         return err_ref;
2759 }
2760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2761         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2762         CHECK(val->result_ok);
2763         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2764         uint64_t res_ref = 0;
2765         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2766         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2767         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2768         res_ref = (uint64_t)res_var.inner & ~1;
2769         return res_ref;
2770 }
2771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2772         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2773         CHECK(!val->result_ok);
2774         LDKDecodeError err_var = (*val->contents.err);
2775         uint64_t err_ref = 0;
2776         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2777         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2778         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2779         err_ref = (uint64_t)err_var.inner & ~1;
2780         return err_ref;
2781 }
2782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2783         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2784         CHECK(val->result_ok);
2785         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2786         return res_ref;
2787 }
2788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2789         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2790         CHECK(!val->result_ok);
2791         LDKDecodeError err_var = (*val->contents.err);
2792         uint64_t err_ref = 0;
2793         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2794         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2795         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2796         err_ref = (uint64_t)err_var.inner & ~1;
2797         return err_ref;
2798 }
2799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2800         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2801         CHECK(val->result_ok);
2802         return *val->contents.result;
2803 }
2804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2805         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2806         CHECK(!val->result_ok);
2807         return *val->contents.err;
2808 }
2809 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2810         return tuple->a;
2811 }
2812 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
2813         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2814         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
2815         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form);
2816         return ret_arr;
2817 }
2818
2819 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2820         return tuple->b;
2821 }
2822 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
2823         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2824         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
2825         jobjectArray ret_arr = NULL;
2826         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
2827         ;
2828         for (size_t i = 0; i < ret_var.datalen; i++) {
2829                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
2830                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
2831                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
2832         }
2833         
2834         FREE(ret_var.data);
2835         return ret_arr;
2836 }
2837
2838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2839         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2840         CHECK(val->result_ok);
2841         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2842         *res_conv = (*val->contents.result);
2843         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
2844         return ((uint64_t)res_conv);
2845 }
2846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2847         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2848         CHECK(!val->result_ok);
2849         return *val->contents.err;
2850 }
2851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2852         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2853         CHECK(val->result_ok);
2854         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2855         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2856         return res_arr;
2857 }
2858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2859         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2860         CHECK(!val->result_ok);
2861         return *val->contents.err;
2862 }
2863 typedef struct LDKBaseSign_JCalls {
2864         atomic_size_t refcnt;
2865         JavaVM *vm;
2866         jweak o;
2867         jmethodID get_per_commitment_point_meth;
2868         jmethodID release_commitment_secret_meth;
2869         jmethodID validate_holder_commitment_meth;
2870         jmethodID channel_keys_id_meth;
2871         jmethodID sign_counterparty_commitment_meth;
2872         jmethodID validate_counterparty_revocation_meth;
2873         jmethodID sign_holder_commitment_and_htlcs_meth;
2874         jmethodID sign_justice_revoked_output_meth;
2875         jmethodID sign_justice_revoked_htlc_meth;
2876         jmethodID sign_counterparty_htlc_transaction_meth;
2877         jmethodID sign_closing_transaction_meth;
2878         jmethodID sign_channel_announcement_meth;
2879         jmethodID ready_channel_meth;
2880 } LDKBaseSign_JCalls;
2881 static void LDKBaseSign_JCalls_free(void* this_arg) {
2882         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2883         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2884                 JNIEnv *env;
2885                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2886                 if (get_jenv_res == JNI_EDETACHED) {
2887                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2888                 } else {
2889                         DO_ASSERT(get_jenv_res == JNI_OK);
2890                 }
2891                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2892                 if (get_jenv_res == JNI_EDETACHED) {
2893                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2894                 }
2895                 FREE(j_calls);
2896         }
2897 }
2898 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2899         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2900         JNIEnv *env;
2901         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2902         if (get_jenv_res == JNI_EDETACHED) {
2903                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2904         } else {
2905                 DO_ASSERT(get_jenv_res == JNI_OK);
2906         }
2907         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2908         CHECK(obj != NULL);
2909         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2910         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2911                 (*env)->ExceptionDescribe(env);
2912                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2913         }
2914         LDKPublicKey ret_ref;
2915         CHECK((*env)->GetArrayLength(env, ret) == 33);
2916         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2917         if (get_jenv_res == JNI_EDETACHED) {
2918                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2919         }
2920         return ret_ref;
2921 }
2922 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2923         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2924         JNIEnv *env;
2925         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2926         if (get_jenv_res == JNI_EDETACHED) {
2927                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2928         } else {
2929                 DO_ASSERT(get_jenv_res == JNI_OK);
2930         }
2931         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2932         CHECK(obj != NULL);
2933         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2934         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2935                 (*env)->ExceptionDescribe(env);
2936                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2937         }
2938         LDKThirtyTwoBytes ret_ref;
2939         CHECK((*env)->GetArrayLength(env, ret) == 32);
2940         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2941         if (get_jenv_res == JNI_EDETACHED) {
2942                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2943         }
2944         return ret_ref;
2945 }
2946 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
2947         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2948         JNIEnv *env;
2949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2950         if (get_jenv_res == JNI_EDETACHED) {
2951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2952         } else {
2953                 DO_ASSERT(get_jenv_res == JNI_OK);
2954         }
2955         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2956         uint64_t holder_tx_ref = 0;
2957         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
2958         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2959         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2960         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
2961         holder_tx_ref = (uint64_t)holder_tx_var.inner;
2962         if (holder_tx_var.is_owned) {
2963                 holder_tx_ref |= 1;
2964         }
2965         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2966         CHECK(obj != NULL);
2967         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref);
2968         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2969                 (*env)->ExceptionDescribe(env);
2970                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
2971         }
2972         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2973         CHECK_ACCESS(ret_ptr);
2974         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2975         FREE((void*)ret);
2976         if (get_jenv_res == JNI_EDETACHED) {
2977                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2978         }
2979         return ret_conv;
2980 }
2981 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2982         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2983         JNIEnv *env;
2984         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2985         if (get_jenv_res == JNI_EDETACHED) {
2986                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2987         } else {
2988                 DO_ASSERT(get_jenv_res == JNI_OK);
2989         }
2990         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2991         CHECK(obj != NULL);
2992         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2993         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2994                 (*env)->ExceptionDescribe(env);
2995                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2996         }
2997         LDKThirtyTwoBytes ret_ref;
2998         CHECK((*env)->GetArrayLength(env, ret) == 32);
2999         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3000         if (get_jenv_res == JNI_EDETACHED) {
3001                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3002         }
3003         return ret_ref;
3004 }
3005 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
3006         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3007         JNIEnv *env;
3008         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3009         if (get_jenv_res == JNI_EDETACHED) {
3010                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3011         } else {
3012                 DO_ASSERT(get_jenv_res == JNI_OK);
3013         }
3014         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3015         uint64_t commitment_tx_ref = 0;
3016         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
3017         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3018         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3019         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3020         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
3021         if (commitment_tx_var.is_owned) {
3022                 commitment_tx_ref |= 1;
3023         }
3024         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3025         CHECK(obj != NULL);
3026         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
3027         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3028                 (*env)->ExceptionDescribe(env);
3029                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
3030         }
3031         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3032         CHECK_ACCESS(ret_ptr);
3033         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3034         FREE((void*)ret);
3035         if (get_jenv_res == JNI_EDETACHED) {
3036                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3037         }
3038         return ret_conv;
3039 }
3040 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3041         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3042         JNIEnv *env;
3043         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3044         if (get_jenv_res == JNI_EDETACHED) {
3045                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3046         } else {
3047                 DO_ASSERT(get_jenv_res == JNI_OK);
3048         }
3049         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
3050         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
3051         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3052         CHECK(obj != NULL);
3053         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
3054         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3055                 (*env)->ExceptionDescribe(env);
3056                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
3057         }
3058         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3059         CHECK_ACCESS(ret_ptr);
3060         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3061         FREE((void*)ret);
3062         if (get_jenv_res == JNI_EDETACHED) {
3063                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3064         }
3065         return ret_conv;
3066 }
3067 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3068         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3069         JNIEnv *env;
3070         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3071         if (get_jenv_res == JNI_EDETACHED) {
3072                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3073         } else {
3074                 DO_ASSERT(get_jenv_res == JNI_OK);
3075         }
3076         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3077         uint64_t commitment_tx_ref = 0;
3078         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
3079         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3080         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3081         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3082         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
3083         if (commitment_tx_var.is_owned) {
3084                 commitment_tx_ref |= 1;
3085         }
3086         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3087         CHECK(obj != NULL);
3088         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
3089         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3090                 (*env)->ExceptionDescribe(env);
3091                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
3092         }
3093         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3094         CHECK_ACCESS(ret_ptr);
3095         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3096         FREE((void*)ret);
3097         if (get_jenv_res == JNI_EDETACHED) {
3098                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3099         }
3100         return ret_conv;
3101 }
3102 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]) {
3103         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3104         JNIEnv *env;
3105         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3106         if (get_jenv_res == JNI_EDETACHED) {
3107                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3108         } else {
3109                 DO_ASSERT(get_jenv_res == JNI_OK);
3110         }
3111         LDKTransaction justice_tx_var = justice_tx;
3112         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3113         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3114         Transaction_free(justice_tx_var);
3115         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3116         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3117         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3118         CHECK(obj != NULL);
3119         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
3120         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3121                 (*env)->ExceptionDescribe(env);
3122                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
3123         }
3124         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3125         CHECK_ACCESS(ret_ptr);
3126         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3127         FREE((void*)ret);
3128         if (get_jenv_res == JNI_EDETACHED) {
3129                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3130         }
3131         return ret_conv;
3132 }
3133 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) {
3134         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3135         JNIEnv *env;
3136         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3137         if (get_jenv_res == JNI_EDETACHED) {
3138                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3139         } else {
3140                 DO_ASSERT(get_jenv_res == JNI_OK);
3141         }
3142         LDKTransaction justice_tx_var = justice_tx;
3143         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3144         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3145         Transaction_free(justice_tx_var);
3146         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3147         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3148         LDKHTLCOutputInCommitment htlc_var = *htlc;
3149         uint64_t htlc_ref = 0;
3150         htlc_var = HTLCOutputInCommitment_clone(htlc);
3151         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3152         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3153         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3154         htlc_ref = (uint64_t)htlc_var.inner;
3155         if (htlc_var.is_owned) {
3156                 htlc_ref |= 1;
3157         }
3158         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3159         CHECK(obj != NULL);
3160         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);
3161         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3162                 (*env)->ExceptionDescribe(env);
3163                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
3164         }
3165         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3166         CHECK_ACCESS(ret_ptr);
3167         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3168         FREE((void*)ret);
3169         if (get_jenv_res == JNI_EDETACHED) {
3170                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3171         }
3172         return ret_conv;
3173 }
3174 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) {
3175         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3176         JNIEnv *env;
3177         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3178         if (get_jenv_res == JNI_EDETACHED) {
3179                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3180         } else {
3181                 DO_ASSERT(get_jenv_res == JNI_OK);
3182         }
3183         LDKTransaction htlc_tx_var = htlc_tx;
3184         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
3185         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
3186         Transaction_free(htlc_tx_var);
3187         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
3188         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
3189         LDKHTLCOutputInCommitment htlc_var = *htlc;
3190         uint64_t htlc_ref = 0;
3191         htlc_var = HTLCOutputInCommitment_clone(htlc);
3192         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3193         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3194         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3195         htlc_ref = (uint64_t)htlc_var.inner;
3196         if (htlc_var.is_owned) {
3197                 htlc_ref |= 1;
3198         }
3199         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3200         CHECK(obj != NULL);
3201         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);
3202         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3203                 (*env)->ExceptionDescribe(env);
3204                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
3205         }
3206         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3207         CHECK_ACCESS(ret_ptr);
3208         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3209         FREE((void*)ret);
3210         if (get_jenv_res == JNI_EDETACHED) {
3211                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3212         }
3213         return ret_conv;
3214 }
3215 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3216         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3217         JNIEnv *env;
3218         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3219         if (get_jenv_res == JNI_EDETACHED) {
3220                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3221         } else {
3222                 DO_ASSERT(get_jenv_res == JNI_OK);
3223         }
3224         LDKClosingTransaction closing_tx_var = *closing_tx;
3225         uint64_t closing_tx_ref = 0;
3226         closing_tx_var = ClosingTransaction_clone(closing_tx);
3227         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3228         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3229         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3230         closing_tx_ref = (uint64_t)closing_tx_var.inner;
3231         if (closing_tx_var.is_owned) {
3232                 closing_tx_ref |= 1;
3233         }
3234         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3235         CHECK(obj != NULL);
3236         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
3237         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3238                 (*env)->ExceptionDescribe(env);
3239                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
3240         }
3241         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3242         CHECK_ACCESS(ret_ptr);
3243         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3244         FREE((void*)ret);
3245         if (get_jenv_res == JNI_EDETACHED) {
3246                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3247         }
3248         return ret_conv;
3249 }
3250 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3251         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3252         JNIEnv *env;
3253         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3254         if (get_jenv_res == JNI_EDETACHED) {
3255                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3256         } else {
3257                 DO_ASSERT(get_jenv_res == JNI_OK);
3258         }
3259         LDKUnsignedChannelAnnouncement msg_var = *msg;
3260         uint64_t msg_ref = 0;
3261         msg_var = UnsignedChannelAnnouncement_clone(msg);
3262         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3263         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3264         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3265         msg_ref = (uint64_t)msg_var.inner;
3266         if (msg_var.is_owned) {
3267                 msg_ref |= 1;
3268         }
3269         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3270         CHECK(obj != NULL);
3271         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
3272         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3273                 (*env)->ExceptionDescribe(env);
3274                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
3275         }
3276         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3277         CHECK_ACCESS(ret_ptr);
3278         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3279         FREE((void*)ret);
3280         if (get_jenv_res == JNI_EDETACHED) {
3281                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3282         }
3283         return ret_conv;
3284 }
3285 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3286         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3287         JNIEnv *env;
3288         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3289         if (get_jenv_res == JNI_EDETACHED) {
3290                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3291         } else {
3292                 DO_ASSERT(get_jenv_res == JNI_OK);
3293         }
3294         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3295         uint64_t channel_parameters_ref = 0;
3296         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
3297         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3298         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3299         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3300         channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
3301         if (channel_parameters_var.is_owned) {
3302                 channel_parameters_ref |= 1;
3303         }
3304         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3305         CHECK(obj != NULL);
3306         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
3307         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3308                 (*env)->ExceptionDescribe(env);
3309                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
3310         }
3311         if (get_jenv_res == JNI_EDETACHED) {
3312                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3313         }
3314 }
3315 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
3316         jclass c = (*env)->GetObjectClass(env, o);
3317         CHECK(c != NULL);
3318         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3319         atomic_init(&calls->refcnt, 1);
3320         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3321         calls->o = (*env)->NewWeakGlobalRef(env, o);
3322         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
3323         CHECK(calls->get_per_commitment_point_meth != NULL);
3324         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
3325         CHECK(calls->release_commitment_secret_meth != NULL);
3326         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J)J");
3327         CHECK(calls->validate_holder_commitment_meth != NULL);
3328         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
3329         CHECK(calls->channel_keys_id_meth != NULL);
3330         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
3331         CHECK(calls->sign_counterparty_commitment_meth != NULL);
3332         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
3333         CHECK(calls->validate_counterparty_revocation_meth != NULL);
3334         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
3335         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
3336         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
3337         CHECK(calls->sign_justice_revoked_output_meth != NULL);
3338         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
3339         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
3340         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
3341         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
3342         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
3343         CHECK(calls->sign_closing_transaction_meth != NULL);
3344         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
3345         CHECK(calls->sign_channel_announcement_meth != NULL);
3346         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
3347         CHECK(calls->ready_channel_meth != NULL);
3348
3349         LDKChannelPublicKeys pubkeys_conv;
3350         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3351         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3352         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3353
3354         LDKBaseSign ret = {
3355                 .this_arg = (void*) calls,
3356                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3357                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3358                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3359                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3360                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3361                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3362                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3363                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3364                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3365                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3366                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3367                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3368                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3369                 .free = LDKBaseSign_JCalls_free,
3370                 .pubkeys = pubkeys_conv,
3371                 .set_pubkeys = NULL,
3372         };
3373         return ret;
3374 }
3375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
3376         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3377         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
3378         return (uint64_t)res_ptr;
3379 }
3380 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) {
3381         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3382         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3383         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3384         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3385         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
3386         return ret_arr;
3387 }
3388
3389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
3390         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3391         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3392         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3393         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3394         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
3395         return ret_arr;
3396 }
3397
3398 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) {
3399         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3400         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3401         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3402         LDKHolderCommitmentTransaction holder_tx_conv;
3403         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3404         holder_tx_conv.is_owned = false;
3405         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3406         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3407         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
3408         return (uint64_t)ret_conv;
3409 }
3410
3411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
3412         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3413         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3414         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3415         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3416         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
3417         return ret_arr;
3418 }
3419
3420 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) {
3421         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3422         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3423         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3424         LDKCommitmentTransaction commitment_tx_conv;
3425         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3426         commitment_tx_conv.is_owned = false;
3427         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3428         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3429         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
3430         return (uint64_t)ret_conv;
3431 }
3432
3433 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) {
3434         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3435         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3436         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3437         unsigned char secret_arr[32];
3438         CHECK((*env)->GetArrayLength(env, secret) == 32);
3439         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
3440         unsigned char (*secret_ref)[32] = &secret_arr;
3441         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3442         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3443         return (uint64_t)ret_conv;
3444 }
3445
3446 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) {
3447         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3448         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3449         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3450         LDKHolderCommitmentTransaction commitment_tx_conv;
3451         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3452         commitment_tx_conv.is_owned = false;
3453         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3454         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3455         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3456         return (uint64_t)ret_conv;
3457 }
3458
3459 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) {
3460         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3461         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3462         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3463         LDKTransaction justice_tx_ref;
3464         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3465         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3466         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3467         justice_tx_ref.data_is_owned = true;
3468         unsigned char per_commitment_key_arr[32];
3469         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3470         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3471         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3472         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3473         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3474         return (uint64_t)ret_conv;
3475 }
3476
3477 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) {
3478         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3479         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3480         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3481         LDKTransaction justice_tx_ref;
3482         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3483         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3484         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3485         justice_tx_ref.data_is_owned = true;
3486         unsigned char per_commitment_key_arr[32];
3487         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3488         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3489         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3490         LDKHTLCOutputInCommitment htlc_conv;
3491         htlc_conv.inner = (void*)(htlc & (~1));
3492         htlc_conv.is_owned = false;
3493         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3494         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3495         *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);
3496         return (uint64_t)ret_conv;
3497 }
3498
3499 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) {
3500         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3501         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3502         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3503         LDKTransaction htlc_tx_ref;
3504         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
3505         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3506         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
3507         htlc_tx_ref.data_is_owned = true;
3508         LDKPublicKey per_commitment_point_ref;
3509         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
3510         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
3511         LDKHTLCOutputInCommitment htlc_conv;
3512         htlc_conv.inner = (void*)(htlc & (~1));
3513         htlc_conv.is_owned = false;
3514         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3515         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3516         *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);
3517         return (uint64_t)ret_conv;
3518 }
3519
3520 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) {
3521         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3522         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3523         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3524         LDKClosingTransaction closing_tx_conv;
3525         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3526         closing_tx_conv.is_owned = false;
3527         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3528         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3529         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3530         return (uint64_t)ret_conv;
3531 }
3532
3533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
3534         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3535         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3536         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3537         LDKUnsignedChannelAnnouncement msg_conv;
3538         msg_conv.inner = (void*)(msg & (~1));
3539         msg_conv.is_owned = false;
3540         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3541         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3542         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3543         return (uint64_t)ret_conv;
3544 }
3545
3546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
3547         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3548         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3549         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3550         LDKChannelTransactionParameters channel_parameters_conv;
3551         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3552         channel_parameters_conv.is_owned = false;
3553         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3554         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3555 }
3556
3557 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3558         if (this_arg->set_pubkeys != NULL)
3559                 this_arg->set_pubkeys(this_arg);
3560         return this_arg->pubkeys;
3561 }
3562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
3563         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3564         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3565         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3566         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3567         uint64_t ret_ref = 0;
3568         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3569         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3571         ret_ref = (uint64_t)ret_var.inner;
3572         if (ret_var.is_owned) {
3573                 ret_ref |= 1;
3574         }
3575         return ret_ref;
3576 }
3577
3578 typedef struct LDKSign_JCalls {
3579         atomic_size_t refcnt;
3580         JavaVM *vm;
3581         jweak o;
3582         LDKBaseSign_JCalls* BaseSign;
3583         jmethodID write_meth;
3584 } LDKSign_JCalls;
3585 static void LDKSign_JCalls_free(void* this_arg) {
3586         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3587         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3588                 JNIEnv *env;
3589                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3590                 if (get_jenv_res == JNI_EDETACHED) {
3591                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3592                 } else {
3593                         DO_ASSERT(get_jenv_res == JNI_OK);
3594                 }
3595                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3596                 if (get_jenv_res == JNI_EDETACHED) {
3597                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3598                 }
3599                 FREE(j_calls);
3600         }
3601 }
3602 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3603         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3604         JNIEnv *env;
3605         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3606         if (get_jenv_res == JNI_EDETACHED) {
3607                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3608         } else {
3609                 DO_ASSERT(get_jenv_res == JNI_OK);
3610         }
3611         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3612         CHECK(obj != NULL);
3613         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
3614         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3615                 (*env)->ExceptionDescribe(env);
3616                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
3617         }
3618         LDKCVec_u8Z ret_ref;
3619         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3620         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3621         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3622         if (get_jenv_res == JNI_EDETACHED) {
3623                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3624         }
3625         return ret_ref;
3626 }
3627 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3628         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3629         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3630         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3631 }
3632 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
3633         jclass c = (*env)->GetObjectClass(env, o);
3634         CHECK(c != NULL);
3635         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3636         atomic_init(&calls->refcnt, 1);
3637         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3638         calls->o = (*env)->NewWeakGlobalRef(env, o);
3639         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
3640         CHECK(calls->write_meth != NULL);
3641
3642         LDKChannelPublicKeys pubkeys_conv;
3643         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3644         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3645         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3646
3647         LDKSign ret = {
3648                 .this_arg = (void*) calls,
3649                 .write = write_LDKSign_jcall,
3650                 .cloned = LDKSign_JCalls_cloned,
3651                 .free = LDKSign_JCalls_free,
3652                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
3653         };
3654         calls->BaseSign = ret.BaseSign.this_arg;
3655         return ret;
3656 }
3657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
3658         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3659         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
3660         return (uint64_t)res_ptr;
3661 }
3662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
3663         LDKSign *inp = (LDKSign *)(arg & ~1);
3664         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
3665         DO_ASSERT((res_ptr & 1) == 0);
3666         return (int64_t)(res_ptr | 1);
3667 }
3668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
3669         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3670         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3671         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3672         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3673         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3674         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3675         CVec_u8Z_free(ret_var);
3676         return ret_arr;
3677 }
3678
3679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3680         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3681         CHECK(val->result_ok);
3682         LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3683         *res_ret = Sign_clone(&(*val->contents.result));
3684         return (uint64_t)res_ret;
3685 }
3686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3687         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3688         CHECK(!val->result_ok);
3689         LDKDecodeError err_var = (*val->contents.err);
3690         uint64_t err_ref = 0;
3691         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3692         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3693         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3694         err_ref = (uint64_t)err_var.inner & ~1;
3695         return err_ref;
3696 }
3697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3698         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3699         CHECK(val->result_ok);
3700         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
3701         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
3702         return es_arr;
3703 }
3704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3705         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3706         CHECK(!val->result_ok);
3707         return *val->contents.err;
3708 }
3709 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3710         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3711         for (size_t i = 0; i < ret.datalen; i++) {
3712                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3713         }
3714         return ret;
3715 }
3716 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3717         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3718         CHECK(val->result_ok);
3719         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3720         jobjectArray res_arr = NULL;
3721         res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3722         ;
3723         for (size_t i = 0; i < res_var.datalen; i++) {
3724                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3725                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3726                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3727                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3728         }
3729         
3730         return res_arr;
3731 }
3732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3733         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3734         CHECK(!val->result_ok);
3735         return *val->contents.err;
3736 }
3737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3738         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3739         CHECK(val->result_ok);
3740         LDKInMemorySigner res_var = (*val->contents.result);
3741         uint64_t res_ref = 0;
3742         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3743         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3744         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3745         res_ref = (uint64_t)res_var.inner & ~1;
3746         return res_ref;
3747 }
3748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3749         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3750         CHECK(!val->result_ok);
3751         LDKDecodeError err_var = (*val->contents.err);
3752         uint64_t err_ref = 0;
3753         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3754         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3755         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3756         err_ref = (uint64_t)err_var.inner & ~1;
3757         return err_ref;
3758 }
3759 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3760         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3761         for (size_t i = 0; i < ret.datalen; i++) {
3762                 ret.data[i] = TxOut_clone(&orig->data[i]);
3763         }
3764         return ret;
3765 }
3766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3767         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3768         CHECK(val->result_ok);
3769         LDKTransaction res_var = (*val->contents.result);
3770         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3771         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3772         return res_arr;
3773 }
3774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3775         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3776         CHECK(!val->result_ok);
3777         return *val->contents.err;
3778 }
3779 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3780         return ThirtyTwoBytes_clone(&tuple->a);
3781 }
3782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3783         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3784         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3785         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data);
3786         return ret_arr;
3787 }
3788
3789 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3790         return ChannelMonitor_clone(&tuple->b);
3791 }
3792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3793         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3794         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
3795         uint64_t ret_ref = 0;
3796         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3797         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3799         ret_ref = (uint64_t)ret_var.inner;
3800         if (ret_var.is_owned) {
3801                 ret_ref |= 1;
3802         }
3803         return ret_ref;
3804 }
3805
3806 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
3807         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
3808         for (size_t i = 0; i < ret.datalen; i++) {
3809                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
3810         }
3811         return ret;
3812 }
3813 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3814         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3815         CHECK(val->result_ok);
3816         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3817         int64_tArray res_arr = NULL;
3818         res_arr = (*env)->NewLongArray(env, res_var.datalen);
3819         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3820         for (size_t j = 0; j < res_var.datalen; j++) {
3821                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3822                 *res_conv_35_conv = res_var.data[j];
3823                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
3824                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
3825         }
3826         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3827         return res_arr;
3828 }
3829 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3830         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3831         CHECK(!val->result_ok);
3832         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3833         return err_conv;
3834 }
3835 static jclass LDKCOption_u16Z_Some_class = NULL;
3836 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3837 static jclass LDKCOption_u16Z_None_class = NULL;
3838 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3840         LDKCOption_u16Z_Some_class =
3841                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
3842         CHECK(LDKCOption_u16Z_Some_class != NULL);
3843         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3844         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3845         LDKCOption_u16Z_None_class =
3846                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
3847         CHECK(LDKCOption_u16Z_None_class != NULL);
3848         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3849         CHECK(LDKCOption_u16Z_None_meth != NULL);
3850 }
3851 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3852         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3853         switch(obj->tag) {
3854                 case LDKCOption_u16Z_Some: {
3855                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3856                 }
3857                 case LDKCOption_u16Z_None: {
3858                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3859                 }
3860                 default: abort();
3861         }
3862 }
3863 static jclass LDKAPIError_APIMisuseError_class = NULL;
3864 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3865 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3866 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3867 static jclass LDKAPIError_RouteError_class = NULL;
3868 static jmethodID LDKAPIError_RouteError_meth = NULL;
3869 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3870 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3871 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3872 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3873 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
3874 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
3875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3876         LDKAPIError_APIMisuseError_class =
3877                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
3878         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3879         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3880         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3881         LDKAPIError_FeeRateTooHigh_class =
3882                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
3883         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3884         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3885         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3886         LDKAPIError_RouteError_class =
3887                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
3888         CHECK(LDKAPIError_RouteError_class != NULL);
3889         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3890         CHECK(LDKAPIError_RouteError_meth != NULL);
3891         LDKAPIError_ChannelUnavailable_class =
3892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
3893         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3894         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3895         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3896         LDKAPIError_MonitorUpdateFailed_class =
3897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
3898         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3899         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3900         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3901         LDKAPIError_IncompatibleShutdownScript_class =
3902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
3903         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
3904         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
3905         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
3906 }
3907 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3908         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3909         switch(obj->tag) {
3910                 case LDKAPIError_APIMisuseError: {
3911                         LDKStr err_str = obj->api_misuse_error.err;
3912                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3913                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3914                 }
3915                 case LDKAPIError_FeeRateTooHigh: {
3916                         LDKStr err_str = obj->fee_rate_too_high.err;
3917                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3918                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3919                 }
3920                 case LDKAPIError_RouteError: {
3921                         LDKStr err_str = obj->route_error.err;
3922                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3923                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3924                 }
3925                 case LDKAPIError_ChannelUnavailable: {
3926                         LDKStr err_str = obj->channel_unavailable.err;
3927                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3928                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3929                 }
3930                 case LDKAPIError_MonitorUpdateFailed: {
3931                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3932                 }
3933                 case LDKAPIError_IncompatibleShutdownScript: {
3934                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3935                         uint64_t script_ref = 0;
3936                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3937                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3938                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3939                         script_ref = (uint64_t)script_var.inner & ~1;
3940                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
3941                 }
3942                 default: abort();
3943         }
3944 }
3945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3946         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3947         CHECK(val->result_ok);
3948         return *val->contents.result;
3949 }
3950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3951         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3952         CHECK(!val->result_ok);
3953         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3954         return err_ref;
3955 }
3956 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3957         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3958         for (size_t i = 0; i < ret.datalen; i++) {
3959                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3960         }
3961         return ret;
3962 }
3963 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3964         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3965         for (size_t i = 0; i < ret.datalen; i++) {
3966                 ret.data[i] = APIError_clone(&orig->data[i]);
3967         }
3968         return ret;
3969 }
3970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3971         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3972         CHECK(val->result_ok);
3973         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3974         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3975         return res_arr;
3976 }
3977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3978         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3979         CHECK(!val->result_ok);
3980         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3981         return err_ref;
3982 }
3983 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3984 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3985 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3986 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3987 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3988 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3989 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3990 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3992         LDKPaymentSendFailure_ParameterError_class =
3993                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
3994         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3995         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3996         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3997         LDKPaymentSendFailure_PathParameterError_class =
3998                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
3999         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
4000         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
4001         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
4002         LDKPaymentSendFailure_AllFailedRetrySafe_class =
4003                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
4004         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
4005         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
4006         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
4007         LDKPaymentSendFailure_PartialFailure_class =
4008                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
4009         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
4010         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
4011         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
4012 }
4013 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4014         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4015         switch(obj->tag) {
4016                 case LDKPaymentSendFailure_ParameterError: {
4017                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
4018                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
4019                 }
4020                 case LDKPaymentSendFailure_PathParameterError: {
4021                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4022                         int64_tArray path_parameter_error_arr = NULL;
4023                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
4024                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
4025                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4026                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4027                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4028                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4029                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
4030                         }
4031                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
4032                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
4033                 }
4034                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
4035                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4036                         int64_tArray all_failed_retry_safe_arr = NULL;
4037                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
4038                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
4039                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4040                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
4041                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4042                         }
4043                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
4044                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
4045                 }
4046                 case LDKPaymentSendFailure_PartialFailure: {
4047                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4048                         int64_tArray results_arr = NULL;
4049                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
4050                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
4051                         for (size_t w = 0; w < results_var.datalen; w++) {
4052                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4053                                 *results_conv_22_conv = results_var.data[w];
4054                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4055                                 results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
4056                         }
4057                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
4058                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4059                         uint64_t failed_paths_retry_ref = 0;
4060                         if ((uint64_t)failed_paths_retry_var.inner > 4096) {
4061                                 CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4062                                 CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4063                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4064                                 failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
4065                         }
4066                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4067                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
4068                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
4069                 }
4070                 default: abort();
4071         }
4072 }
4073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4074         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
4075         CHECK(val->result_ok);
4076         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
4077         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
4078         return res_arr;
4079 }
4080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4081         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
4082         CHECK(!val->result_ok);
4083         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4084         return err_ref;
4085 }
4086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4087         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
4088         CHECK(val->result_ok);
4089         return *val->contents.result;
4090 }
4091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4092         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
4093         CHECK(!val->result_ok);
4094         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4095         return err_ref;
4096 }
4097 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
4098         return ThirtyTwoBytes_clone(&tuple->a);
4099 }
4100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4101         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
4102         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data);
4104         return ret_arr;
4105 }
4106
4107 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
4108         return ThirtyTwoBytes_clone(&tuple->b);
4109 }
4110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4111         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
4112         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4113         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data);
4114         return ret_arr;
4115 }
4116
4117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4118         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
4119         CHECK(val->result_ok);
4120         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
4121         *res_conv = (*val->contents.result);
4122         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
4123         return ((uint64_t)res_conv);
4124 }
4125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4126         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
4127         CHECK(!val->result_ok);
4128         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4129         return err_ref;
4130 }
4131 static jclass LDKNetAddress_IPv4_class = NULL;
4132 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4133 static jclass LDKNetAddress_IPv6_class = NULL;
4134 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4135 static jclass LDKNetAddress_OnionV2_class = NULL;
4136 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4137 static jclass LDKNetAddress_OnionV3_class = NULL;
4138 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4140         LDKNetAddress_IPv4_class =
4141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4142         CHECK(LDKNetAddress_IPv4_class != NULL);
4143         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4144         CHECK(LDKNetAddress_IPv4_meth != NULL);
4145         LDKNetAddress_IPv6_class =
4146                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4147         CHECK(LDKNetAddress_IPv6_class != NULL);
4148         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4149         CHECK(LDKNetAddress_IPv6_meth != NULL);
4150         LDKNetAddress_OnionV2_class =
4151                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4152         CHECK(LDKNetAddress_OnionV2_class != NULL);
4153         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4154         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4155         LDKNetAddress_OnionV3_class =
4156                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4157         CHECK(LDKNetAddress_OnionV3_class != NULL);
4158         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4159         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4160 }
4161 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4162         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4163         switch(obj->tag) {
4164                 case LDKNetAddress_IPv4: {
4165                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4166                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4167                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
4168                 }
4169                 case LDKNetAddress_IPv6: {
4170                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4171                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4172                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
4173                 }
4174                 case LDKNetAddress_OnionV2: {
4175                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4176                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4177                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4178                 }
4179                 case LDKNetAddress_OnionV3: {
4180                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4181                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4182                         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);
4183                 }
4184                 default: abort();
4185         }
4186 }
4187 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4188         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4189         for (size_t i = 0; i < ret.datalen; i++) {
4190                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4191         }
4192         return ret;
4193 }
4194 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
4195         return ThirtyTwoBytes_clone(&tuple->a);
4196 }
4197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4198         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
4199         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4200         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data);
4201         return ret_arr;
4202 }
4203
4204 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
4205         return ThirtyTwoBytes_clone(&tuple->b);
4206 }
4207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4208         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
4209         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4210         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data);
4211         return ret_arr;
4212 }
4213
4214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4215         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
4216         CHECK(val->result_ok);
4217         LDKC2Tuple_PaymentHashPaymentSecretZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4218         *res_conv = (*val->contents.result);
4219         *res_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(res_conv);
4220         return ((uint64_t)res_conv);
4221 }
4222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4223         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
4224         CHECK(!val->result_ok);
4225         return *val->contents.err;
4226 }
4227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4228         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
4229         CHECK(val->result_ok);
4230         LDKC2Tuple_PaymentHashPaymentSecretZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4231         *res_conv = (*val->contents.result);
4232         *res_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(res_conv);
4233         return ((uint64_t)res_conv);
4234 }
4235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4236         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
4237         CHECK(!val->result_ok);
4238         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4239         return err_ref;
4240 }
4241 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4242         LDKCResult_PaymentSecretNoneZ *val = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
4243         CHECK(val->result_ok);
4244         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
4245         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
4246         return res_arr;
4247 }
4248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4249         LDKCResult_PaymentSecretNoneZ *val = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
4250         CHECK(!val->result_ok);
4251         return *val->contents.err;
4252 }
4253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4254         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
4255         CHECK(val->result_ok);
4256         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
4257         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
4258         return res_arr;
4259 }
4260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4261         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
4262         CHECK(!val->result_ok);
4263         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4264         return err_ref;
4265 }
4266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4267         LDKCResult_PaymentPreimageAPIErrorZ *val = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
4268         CHECK(val->result_ok);
4269         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
4270         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
4271         return res_arr;
4272 }
4273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4274         LDKCResult_PaymentPreimageAPIErrorZ *val = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
4275         CHECK(!val->result_ok);
4276         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4277         return err_ref;
4278 }
4279 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4280         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4281         for (size_t i = 0; i < ret.datalen; i++) {
4282                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4283         }
4284         return ret;
4285 }
4286 typedef struct LDKWatch_JCalls {
4287         atomic_size_t refcnt;
4288         JavaVM *vm;
4289         jweak o;
4290         jmethodID watch_channel_meth;
4291         jmethodID update_channel_meth;
4292         jmethodID release_pending_monitor_events_meth;
4293 } LDKWatch_JCalls;
4294 static void LDKWatch_JCalls_free(void* this_arg) {
4295         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4296         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4297                 JNIEnv *env;
4298                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4299                 if (get_jenv_res == JNI_EDETACHED) {
4300                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4301                 } else {
4302                         DO_ASSERT(get_jenv_res == JNI_OK);
4303                 }
4304                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4305                 if (get_jenv_res == JNI_EDETACHED) {
4306                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4307                 }
4308                 FREE(j_calls);
4309         }
4310 }
4311 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4312         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4313         JNIEnv *env;
4314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4315         if (get_jenv_res == JNI_EDETACHED) {
4316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4317         } else {
4318                 DO_ASSERT(get_jenv_res == JNI_OK);
4319         }
4320         LDKOutPoint funding_txo_var = funding_txo;
4321         uint64_t funding_txo_ref = 0;
4322         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4323         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4324         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4325         funding_txo_ref = (uint64_t)funding_txo_var.inner;
4326         if (funding_txo_var.is_owned) {
4327                 funding_txo_ref |= 1;
4328         }
4329         LDKChannelMonitor monitor_var = monitor;
4330         uint64_t monitor_ref = 0;
4331         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4332         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4333         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4334         monitor_ref = (uint64_t)monitor_var.inner;
4335         if (monitor_var.is_owned) {
4336                 monitor_ref |= 1;
4337         }
4338         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4339         CHECK(obj != NULL);
4340         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
4341         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4342                 (*env)->ExceptionDescribe(env);
4343                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
4344         }
4345         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4346         CHECK_ACCESS(ret_ptr);
4347         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4348         FREE((void*)ret);
4349         if (get_jenv_res == JNI_EDETACHED) {
4350                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4351         }
4352         return ret_conv;
4353 }
4354 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4355         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4356         JNIEnv *env;
4357         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4358         if (get_jenv_res == JNI_EDETACHED) {
4359                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4360         } else {
4361                 DO_ASSERT(get_jenv_res == JNI_OK);
4362         }
4363         LDKOutPoint funding_txo_var = funding_txo;
4364         uint64_t funding_txo_ref = 0;
4365         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4366         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4367         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4368         funding_txo_ref = (uint64_t)funding_txo_var.inner;
4369         if (funding_txo_var.is_owned) {
4370                 funding_txo_ref |= 1;
4371         }
4372         LDKChannelMonitorUpdate update_var = update;
4373         uint64_t update_ref = 0;
4374         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4375         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4376         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4377         update_ref = (uint64_t)update_var.inner;
4378         if (update_var.is_owned) {
4379                 update_ref |= 1;
4380         }
4381         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4382         CHECK(obj != NULL);
4383         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
4384         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4385                 (*env)->ExceptionDescribe(env);
4386                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
4387         }
4388         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4389         CHECK_ACCESS(ret_ptr);
4390         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4391         FREE((void*)ret);
4392         if (get_jenv_res == JNI_EDETACHED) {
4393                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4394         }
4395         return ret_conv;
4396 }
4397 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4398         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4399         JNIEnv *env;
4400         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4401         if (get_jenv_res == JNI_EDETACHED) {
4402                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4403         } else {
4404                 DO_ASSERT(get_jenv_res == JNI_OK);
4405         }
4406         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4407         CHECK(obj != NULL);
4408         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
4409         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4410                 (*env)->ExceptionDescribe(env);
4411                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
4412         }
4413         LDKCVec_MonitorEventZ ret_constr;
4414         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4415         if (ret_constr.datalen > 0)
4416                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4417         else
4418                 ret_constr.data = NULL;
4419         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4420         for (size_t o = 0; o < ret_constr.datalen; o++) {
4421                 int64_t ret_conv_14 = ret_vals[o];
4422                 void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
4423                 CHECK_ACCESS(ret_conv_14_ptr);
4424                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4425                 FREE((void*)ret_conv_14);
4426                 ret_constr.data[o] = ret_conv_14_conv;
4427         }
4428         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4429         if (get_jenv_res == JNI_EDETACHED) {
4430                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4431         }
4432         return ret_constr;
4433 }
4434 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4435         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4436         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4437 }
4438 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
4439         jclass c = (*env)->GetObjectClass(env, o);
4440         CHECK(c != NULL);
4441         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4442         atomic_init(&calls->refcnt, 1);
4443         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4444         calls->o = (*env)->NewWeakGlobalRef(env, o);
4445         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
4446         CHECK(calls->watch_channel_meth != NULL);
4447         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
4448         CHECK(calls->update_channel_meth != NULL);
4449         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
4450         CHECK(calls->release_pending_monitor_events_meth != NULL);
4451
4452         LDKWatch ret = {
4453                 .this_arg = (void*) calls,
4454                 .watch_channel = watch_channel_LDKWatch_jcall,
4455                 .update_channel = update_channel_LDKWatch_jcall,
4456                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4457                 .free = LDKWatch_JCalls_free,
4458         };
4459         return ret;
4460 }
4461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
4462         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4463         *res_ptr = LDKWatch_init(env, clz, o);
4464         return (uint64_t)res_ptr;
4465 }
4466 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) {
4467         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4468         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4469         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4470         LDKOutPoint funding_txo_conv;
4471         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4472         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4473         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4474         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4475         LDKChannelMonitor monitor_conv;
4476         monitor_conv.inner = (void*)(monitor & (~1));
4477         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4478         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4479         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4480         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4481         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4482         return (uint64_t)ret_conv;
4483 }
4484
4485 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) {
4486         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4487         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4488         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4489         LDKOutPoint funding_txo_conv;
4490         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4491         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4492         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4493         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4494         LDKChannelMonitorUpdate update_conv;
4495         update_conv.inner = (void*)(update & (~1));
4496         update_conv.is_owned = (update & 1) || (update == 0);
4497         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4498         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4499         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4500         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4501         return (uint64_t)ret_conv;
4502 }
4503
4504 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4505         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4506         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4507         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4508         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4509         int64_tArray ret_arr = NULL;
4510         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4511         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4512         for (size_t o = 0; o < ret_var.datalen; o++) {
4513                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4514                 *ret_conv_14_copy = ret_var.data[o];
4515                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
4516                 ret_arr_ptr[o] = ret_conv_14_ref;
4517         }
4518         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4519         FREE(ret_var.data);
4520         return ret_arr;
4521 }
4522
4523 typedef struct LDKBroadcasterInterface_JCalls {
4524         atomic_size_t refcnt;
4525         JavaVM *vm;
4526         jweak o;
4527         jmethodID broadcast_transaction_meth;
4528 } LDKBroadcasterInterface_JCalls;
4529 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4530         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4531         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4532                 JNIEnv *env;
4533                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4534                 if (get_jenv_res == JNI_EDETACHED) {
4535                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4536                 } else {
4537                         DO_ASSERT(get_jenv_res == JNI_OK);
4538                 }
4539                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4540                 if (get_jenv_res == JNI_EDETACHED) {
4541                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4542                 }
4543                 FREE(j_calls);
4544         }
4545 }
4546 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4547         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4548         JNIEnv *env;
4549         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4550         if (get_jenv_res == JNI_EDETACHED) {
4551                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4552         } else {
4553                 DO_ASSERT(get_jenv_res == JNI_OK);
4554         }
4555         LDKTransaction tx_var = tx;
4556         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
4557         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
4558         Transaction_free(tx_var);
4559         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4560         CHECK(obj != NULL);
4561         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
4562         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4563                 (*env)->ExceptionDescribe(env);
4564                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
4565         }
4566         if (get_jenv_res == JNI_EDETACHED) {
4567                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4568         }
4569 }
4570 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4571         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4572         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4573 }
4574 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
4575         jclass c = (*env)->GetObjectClass(env, o);
4576         CHECK(c != NULL);
4577         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4578         atomic_init(&calls->refcnt, 1);
4579         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4580         calls->o = (*env)->NewWeakGlobalRef(env, o);
4581         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
4582         CHECK(calls->broadcast_transaction_meth != NULL);
4583
4584         LDKBroadcasterInterface ret = {
4585                 .this_arg = (void*) calls,
4586                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4587                 .free = LDKBroadcasterInterface_JCalls_free,
4588         };
4589         return ret;
4590 }
4591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4592         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4593         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
4594         return (uint64_t)res_ptr;
4595 }
4596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
4597         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4598         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4599         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4600         LDKTransaction tx_ref;
4601         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
4602         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4603         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
4604         tx_ref.data_is_owned = true;
4605         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4606 }
4607
4608 typedef struct LDKKeysInterface_JCalls {
4609         atomic_size_t refcnt;
4610         JavaVM *vm;
4611         jweak o;
4612         jmethodID get_node_secret_meth;
4613         jmethodID get_destination_script_meth;
4614         jmethodID get_shutdown_scriptpubkey_meth;
4615         jmethodID get_channel_signer_meth;
4616         jmethodID get_secure_random_bytes_meth;
4617         jmethodID read_chan_signer_meth;
4618         jmethodID sign_invoice_meth;
4619         jmethodID get_inbound_payment_key_material_meth;
4620 } LDKKeysInterface_JCalls;
4621 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4622         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4623         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4624                 JNIEnv *env;
4625                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4626                 if (get_jenv_res == JNI_EDETACHED) {
4627                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4628                 } else {
4629                         DO_ASSERT(get_jenv_res == JNI_OK);
4630                 }
4631                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4632                 if (get_jenv_res == JNI_EDETACHED) {
4633                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4634                 }
4635                 FREE(j_calls);
4636         }
4637 }
4638 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
4639         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4640         JNIEnv *env;
4641         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4642         if (get_jenv_res == JNI_EDETACHED) {
4643                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4644         } else {
4645                 DO_ASSERT(get_jenv_res == JNI_OK);
4646         }
4647         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4648         CHECK(obj != NULL);
4649         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
4650         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4651                 (*env)->ExceptionDescribe(env);
4652                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
4653         }
4654         LDKSecretKey ret_ref;
4655         CHECK((*env)->GetArrayLength(env, ret) == 32);
4656         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
4657         if (get_jenv_res == JNI_EDETACHED) {
4658                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4659         }
4660         return ret_ref;
4661 }
4662 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4663         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4664         JNIEnv *env;
4665         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4666         if (get_jenv_res == JNI_EDETACHED) {
4667                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4668         } else {
4669                 DO_ASSERT(get_jenv_res == JNI_OK);
4670         }
4671         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4672         CHECK(obj != NULL);
4673         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
4674         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4675                 (*env)->ExceptionDescribe(env);
4676                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
4677         }
4678         LDKCVec_u8Z ret_ref;
4679         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4680         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4681         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4682         if (get_jenv_res == JNI_EDETACHED) {
4683                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4684         }
4685         return ret_ref;
4686 }
4687 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4688         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4689         JNIEnv *env;
4690         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4691         if (get_jenv_res == JNI_EDETACHED) {
4692                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4693         } else {
4694                 DO_ASSERT(get_jenv_res == JNI_OK);
4695         }
4696         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4697         CHECK(obj != NULL);
4698         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
4699         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4700                 (*env)->ExceptionDescribe(env);
4701                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
4702         }
4703         LDKShutdownScript ret_conv;
4704         ret_conv.inner = (void*)(ret & (~1));
4705         ret_conv.is_owned = (ret & 1) || (ret == 0);
4706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4707         if (get_jenv_res == JNI_EDETACHED) {
4708                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4709         }
4710         return ret_conv;
4711 }
4712 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4713         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4714         JNIEnv *env;
4715         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4716         if (get_jenv_res == JNI_EDETACHED) {
4717                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4718         } else {
4719                 DO_ASSERT(get_jenv_res == JNI_OK);
4720         }
4721         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4722         CHECK(obj != NULL);
4723         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
4724         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4725                 (*env)->ExceptionDescribe(env);
4726                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
4727         }
4728         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4729         CHECK_ACCESS(ret_ptr);
4730         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4731         FREE((void*)ret);
4732         if (get_jenv_res == JNI_EDETACHED) {
4733                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4734         }
4735         return ret_conv;
4736 }
4737 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4738         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4739         JNIEnv *env;
4740         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4741         if (get_jenv_res == JNI_EDETACHED) {
4742                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4743         } else {
4744                 DO_ASSERT(get_jenv_res == JNI_OK);
4745         }
4746         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4747         CHECK(obj != NULL);
4748         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
4749         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4750                 (*env)->ExceptionDescribe(env);
4751                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
4752         }
4753         LDKThirtyTwoBytes ret_ref;
4754         CHECK((*env)->GetArrayLength(env, ret) == 32);
4755         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4756         if (get_jenv_res == JNI_EDETACHED) {
4757                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4758         }
4759         return ret_ref;
4760 }
4761 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4762         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4763         JNIEnv *env;
4764         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4765         if (get_jenv_res == JNI_EDETACHED) {
4766                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4767         } else {
4768                 DO_ASSERT(get_jenv_res == JNI_OK);
4769         }
4770         LDKu8slice reader_var = reader;
4771         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
4772         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
4773         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4774         CHECK(obj != NULL);
4775         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
4776         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4777                 (*env)->ExceptionDescribe(env);
4778                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
4779         }
4780         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4781         CHECK_ACCESS(ret_ptr);
4782         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4783         FREE((void*)ret);
4784         if (get_jenv_res == JNI_EDETACHED) {
4785                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4786         }
4787         return ret_conv;
4788 }
4789 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
4790         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4791         JNIEnv *env;
4792         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4793         if (get_jenv_res == JNI_EDETACHED) {
4794                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4795         } else {
4796                 DO_ASSERT(get_jenv_res == JNI_OK);
4797         }
4798         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
4799         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
4800         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
4801         CVec_u8Z_free(invoice_preimage_var);
4802         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4803         CHECK(obj != NULL);
4804         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
4805         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4806                 (*env)->ExceptionDescribe(env);
4807                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
4808         }
4809         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4810         CHECK_ACCESS(ret_ptr);
4811         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4812         FREE((void*)ret);
4813         if (get_jenv_res == JNI_EDETACHED) {
4814                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4815         }
4816         return ret_conv;
4817 }
4818 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
4819         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4820         JNIEnv *env;
4821         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4822         if (get_jenv_res == JNI_EDETACHED) {
4823                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4824         } else {
4825                 DO_ASSERT(get_jenv_res == JNI_OK);
4826         }
4827         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4828         CHECK(obj != NULL);
4829         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
4830         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4831                 (*env)->ExceptionDescribe(env);
4832                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
4833         }
4834         LDKThirtyTwoBytes ret_ref;
4835         CHECK((*env)->GetArrayLength(env, ret) == 32);
4836         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4837         if (get_jenv_res == JNI_EDETACHED) {
4838                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4839         }
4840         return ret_ref;
4841 }
4842 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4843         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4844         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4845 }
4846 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4847         jclass c = (*env)->GetObjectClass(env, o);
4848         CHECK(c != NULL);
4849         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4850         atomic_init(&calls->refcnt, 1);
4851         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4852         calls->o = (*env)->NewWeakGlobalRef(env, o);
4853         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4854         CHECK(calls->get_node_secret_meth != NULL);
4855         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4856         CHECK(calls->get_destination_script_meth != NULL);
4857         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
4858         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
4859         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4860         CHECK(calls->get_channel_signer_meth != NULL);
4861         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4862         CHECK(calls->get_secure_random_bytes_meth != NULL);
4863         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4864         CHECK(calls->read_chan_signer_meth != NULL);
4865         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
4866         CHECK(calls->sign_invoice_meth != NULL);
4867         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
4868         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
4869
4870         LDKKeysInterface ret = {
4871                 .this_arg = (void*) calls,
4872                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4873                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4874                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4875                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4876                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4877                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4878                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4879                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
4880                 .free = LDKKeysInterface_JCalls_free,
4881         };
4882         return ret;
4883 }
4884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4885         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4886         *res_ptr = LDKKeysInterface_init(env, clz, o);
4887         return (uint64_t)res_ptr;
4888 }
4889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4890         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4891         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4892         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4893         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4894         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4895         return ret_arr;
4896 }
4897
4898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4899         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4900         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4901         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4902         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4903         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4904         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4905         CVec_u8Z_free(ret_var);
4906         return ret_arr;
4907 }
4908
4909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4910         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4911         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4912         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4913         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4914         uint64_t ret_ref = 0;
4915         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4916         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4918         ret_ref = (uint64_t)ret_var.inner;
4919         if (ret_var.is_owned) {
4920                 ret_ref |= 1;
4921         }
4922         return ret_ref;
4923 }
4924
4925 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) {
4926         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4927         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4928         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4929         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4930         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4931         return (uint64_t)ret_ret;
4932 }
4933
4934 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4935         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4936         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4937         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4938         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4940         return ret_arr;
4941 }
4942
4943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4944         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4945         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4946         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4947         LDKu8slice reader_ref;
4948         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4949         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4950         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4951         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4952         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4953         return (uint64_t)ret_conv;
4954 }
4955
4956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4957         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4958         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4959         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4960         LDKCVec_u8Z invoice_preimage_ref;
4961         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4962         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4963         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4964         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4965         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4966         return (uint64_t)ret_conv;
4967 }
4968
4969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
4970         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4971         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4972         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4973         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4974         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
4975         return ret_arr;
4976 }
4977
4978 typedef struct LDKFeeEstimator_JCalls {
4979         atomic_size_t refcnt;
4980         JavaVM *vm;
4981         jweak o;
4982         jmethodID get_est_sat_per_1000_weight_meth;
4983 } LDKFeeEstimator_JCalls;
4984 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4985         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4986         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4987                 JNIEnv *env;
4988                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4989                 if (get_jenv_res == JNI_EDETACHED) {
4990                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4991                 } else {
4992                         DO_ASSERT(get_jenv_res == JNI_OK);
4993                 }
4994                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4995                 if (get_jenv_res == JNI_EDETACHED) {
4996                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4997                 }
4998                 FREE(j_calls);
4999         }
5000 }
5001 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
5002         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5003         JNIEnv *env;
5004         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5005         if (get_jenv_res == JNI_EDETACHED) {
5006                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5007         } else {
5008                 DO_ASSERT(get_jenv_res == JNI_OK);
5009         }
5010         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
5011         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5012         CHECK(obj != NULL);
5013         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
5014         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5015                 (*env)->ExceptionDescribe(env);
5016                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
5017         }
5018         if (get_jenv_res == JNI_EDETACHED) {
5019                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5020         }
5021         return ret;
5022 }
5023 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
5024         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
5025         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5026 }
5027 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
5028         jclass c = (*env)->GetObjectClass(env, o);
5029         CHECK(c != NULL);
5030         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
5031         atomic_init(&calls->refcnt, 1);
5032         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5033         calls->o = (*env)->NewWeakGlobalRef(env, o);
5034         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
5035         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
5036
5037         LDKFeeEstimator ret = {
5038                 .this_arg = (void*) calls,
5039                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
5040                 .free = LDKFeeEstimator_JCalls_free,
5041         };
5042         return ret;
5043 }
5044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
5045         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
5046         *res_ptr = LDKFeeEstimator_init(env, clz, o);
5047         return (uint64_t)res_ptr;
5048 }
5049 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) {
5050         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5051         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5052         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
5053         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
5054         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
5055         return ret_val;
5056 }
5057
5058 typedef struct LDKLogger_JCalls {
5059         atomic_size_t refcnt;
5060         JavaVM *vm;
5061         jweak o;
5062         jmethodID log_meth;
5063 } LDKLogger_JCalls;
5064 static void LDKLogger_JCalls_free(void* this_arg) {
5065         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
5066         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5067                 JNIEnv *env;
5068                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5069                 if (get_jenv_res == JNI_EDETACHED) {
5070                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5071                 } else {
5072                         DO_ASSERT(get_jenv_res == JNI_OK);
5073                 }
5074                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5075                 if (get_jenv_res == JNI_EDETACHED) {
5076                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5077                 }
5078                 FREE(j_calls);
5079         }
5080 }
5081 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
5082         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
5083         JNIEnv *env;
5084         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5085         if (get_jenv_res == JNI_EDETACHED) {
5086                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5087         } else {
5088                 DO_ASSERT(get_jenv_res == JNI_OK);
5089         }
5090         LDKRecord record_var = *record;
5091         uint64_t record_ref = 0;
5092         record_var = Record_clone(record);
5093         CHECK((((uint64_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5094         CHECK((((uint64_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5095         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
5096         record_ref = (uint64_t)record_var.inner;
5097         if (record_var.is_owned) {
5098                 record_ref |= 1;
5099         }
5100         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5101         CHECK(obj != NULL);
5102         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
5103         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5104                 (*env)->ExceptionDescribe(env);
5105                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
5106         }
5107         if (get_jenv_res == JNI_EDETACHED) {
5108                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5109         }
5110 }
5111 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
5112         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
5113         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5114 }
5115 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
5116         jclass c = (*env)->GetObjectClass(env, o);
5117         CHECK(c != NULL);
5118         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
5119         atomic_init(&calls->refcnt, 1);
5120         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5121         calls->o = (*env)->NewWeakGlobalRef(env, o);
5122         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
5123         CHECK(calls->log_meth != NULL);
5124
5125         LDKLogger ret = {
5126                 .this_arg = (void*) calls,
5127                 .log = log_LDKLogger_jcall,
5128                 .free = LDKLogger_JCalls_free,
5129         };
5130         return ret;
5131 }
5132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
5133         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
5134         *res_ptr = LDKLogger_init(env, clz, o);
5135         return (uint64_t)res_ptr;
5136 }
5137 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
5138         return ThirtyTwoBytes_clone(&tuple->a);
5139 }
5140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5141         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
5142         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5143         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data);
5144         return ret_arr;
5145 }
5146
5147 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
5148         return &tuple->b;
5149 }
5150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5151         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
5152         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
5153         uint64_t ret_ref = 0;
5154         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5155         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5157         ret_ref = (uint64_t)ret_var.inner & ~1;
5158         return ret_ref;
5159 }
5160
5161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5162         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
5163         CHECK(val->result_ok);
5164         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
5165         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
5166         return ((uint64_t)res_conv) | 1;
5167 }
5168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5169         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
5170         CHECK(!val->result_ok);
5171         LDKDecodeError err_var = (*val->contents.err);
5172         uint64_t err_ref = 0;
5173         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5174         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5175         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5176         err_ref = (uint64_t)err_var.inner & ~1;
5177         return err_ref;
5178 }
5179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5180         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
5181         CHECK(val->result_ok);
5182         LDKChannelConfig res_var = (*val->contents.result);
5183         uint64_t res_ref = 0;
5184         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5185         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5186         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5187         res_ref = (uint64_t)res_var.inner & ~1;
5188         return res_ref;
5189 }
5190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5191         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
5192         CHECK(!val->result_ok);
5193         LDKDecodeError err_var = (*val->contents.err);
5194         uint64_t err_ref = 0;
5195         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5196         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5197         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5198         err_ref = (uint64_t)err_var.inner & ~1;
5199         return err_ref;
5200 }
5201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5202         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
5203         CHECK(val->result_ok);
5204         LDKOutPoint res_var = (*val->contents.result);
5205         uint64_t res_ref = 0;
5206         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5207         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5208         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5209         res_ref = (uint64_t)res_var.inner & ~1;
5210         return res_ref;
5211 }
5212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5213         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
5214         CHECK(!val->result_ok);
5215         LDKDecodeError err_var = (*val->contents.err);
5216         uint64_t err_ref = 0;
5217         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5218         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5219         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5220         err_ref = (uint64_t)err_var.inner & ~1;
5221         return err_ref;
5222 }
5223 typedef struct LDKType_JCalls {
5224         atomic_size_t refcnt;
5225         JavaVM *vm;
5226         jweak o;
5227         jmethodID type_id_meth;
5228         jmethodID debug_str_meth;
5229         jmethodID write_meth;
5230 } LDKType_JCalls;
5231 static void LDKType_JCalls_free(void* this_arg) {
5232         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5233         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5234                 JNIEnv *env;
5235                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5236                 if (get_jenv_res == JNI_EDETACHED) {
5237                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5238                 } else {
5239                         DO_ASSERT(get_jenv_res == JNI_OK);
5240                 }
5241                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5242                 if (get_jenv_res == JNI_EDETACHED) {
5243                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5244                 }
5245                 FREE(j_calls);
5246         }
5247 }
5248 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5249         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5250         JNIEnv *env;
5251         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5252         if (get_jenv_res == JNI_EDETACHED) {
5253                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5254         } else {
5255                 DO_ASSERT(get_jenv_res == JNI_OK);
5256         }
5257         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5258         CHECK(obj != NULL);
5259         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
5260         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5261                 (*env)->ExceptionDescribe(env);
5262                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
5263         }
5264         if (get_jenv_res == JNI_EDETACHED) {
5265                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5266         }
5267         return ret;
5268 }
5269 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5270         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5271         JNIEnv *env;
5272         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5273         if (get_jenv_res == JNI_EDETACHED) {
5274                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5275         } else {
5276                 DO_ASSERT(get_jenv_res == JNI_OK);
5277         }
5278         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5279         CHECK(obj != NULL);
5280         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
5281         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5282                 (*env)->ExceptionDescribe(env);
5283                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
5284         }
5285         LDKStr ret_conv = java_to_owned_str(env, ret);
5286         if (get_jenv_res == JNI_EDETACHED) {
5287                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5288         }
5289         return ret_conv;
5290 }
5291 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5292         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5293         JNIEnv *env;
5294         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5295         if (get_jenv_res == JNI_EDETACHED) {
5296                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5297         } else {
5298                 DO_ASSERT(get_jenv_res == JNI_OK);
5299         }
5300         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5301         CHECK(obj != NULL);
5302         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5303         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5304                 (*env)->ExceptionDescribe(env);
5305                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
5306         }
5307         LDKCVec_u8Z ret_ref;
5308         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5309         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5310         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5311         if (get_jenv_res == JNI_EDETACHED) {
5312                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5313         }
5314         return ret_ref;
5315 }
5316 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5317         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5318         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5319 }
5320 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
5321         jclass c = (*env)->GetObjectClass(env, o);
5322         CHECK(c != NULL);
5323         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5324         atomic_init(&calls->refcnt, 1);
5325         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5326         calls->o = (*env)->NewWeakGlobalRef(env, o);
5327         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
5328         CHECK(calls->type_id_meth != NULL);
5329         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
5330         CHECK(calls->debug_str_meth != NULL);
5331         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5332         CHECK(calls->write_meth != NULL);
5333
5334         LDKType ret = {
5335                 .this_arg = (void*) calls,
5336                 .type_id = type_id_LDKType_jcall,
5337                 .debug_str = debug_str_LDKType_jcall,
5338                 .write = write_LDKType_jcall,
5339                 .cloned = LDKType_JCalls_cloned,
5340                 .free = LDKType_JCalls_free,
5341         };
5342         return ret;
5343 }
5344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
5345         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5346         *res_ptr = LDKType_init(env, clz, o);
5347         return (uint64_t)res_ptr;
5348 }
5349 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5350         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5351         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5352         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5353         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5354         return ret_val;
5355 }
5356
5357 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
5358         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5359         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5360         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5361         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5362         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
5363         Str_free(ret_str);
5364         return ret_conv;
5365 }
5366
5367 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5368         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5369         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5370         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5371         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5372         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5373         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5374         CVec_u8Z_free(ret_var);
5375         return ret_arr;
5376 }
5377
5378 static jclass LDKCOption_TypeZ_Some_class = NULL;
5379 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
5380 static jclass LDKCOption_TypeZ_None_class = NULL;
5381 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
5382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
5383         LDKCOption_TypeZ_Some_class =
5384                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
5385         CHECK(LDKCOption_TypeZ_Some_class != NULL);
5386         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
5387         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
5388         LDKCOption_TypeZ_None_class =
5389                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
5390         CHECK(LDKCOption_TypeZ_None_class != NULL);
5391         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
5392         CHECK(LDKCOption_TypeZ_None_meth != NULL);
5393 }
5394 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5395         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5396         switch(obj->tag) {
5397                 case LDKCOption_TypeZ_Some: {
5398                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5399                         *some_ret = Type_clone(&obj->some);
5400                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uint64_t)some_ret);
5401                 }
5402                 case LDKCOption_TypeZ_None: {
5403                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
5404                 }
5405                 default: abort();
5406         }
5407 }
5408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5409         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
5410         CHECK(val->result_ok);
5411         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5412         return res_ref;
5413 }
5414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5415         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
5416         CHECK(!val->result_ok);
5417         LDKDecodeError err_var = (*val->contents.err);
5418         uint64_t err_ref = 0;
5419         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5420         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5421         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5422         err_ref = (uint64_t)err_var.inner & ~1;
5423         return err_ref;
5424 }
5425 static jclass LDKPaymentError_Invoice_class = NULL;
5426 static jmethodID LDKPaymentError_Invoice_meth = NULL;
5427 static jclass LDKPaymentError_Routing_class = NULL;
5428 static jmethodID LDKPaymentError_Routing_meth = NULL;
5429 static jclass LDKPaymentError_Sending_class = NULL;
5430 static jmethodID LDKPaymentError_Sending_meth = NULL;
5431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
5432         LDKPaymentError_Invoice_class =
5433                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
5434         CHECK(LDKPaymentError_Invoice_class != NULL);
5435         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
5436         CHECK(LDKPaymentError_Invoice_meth != NULL);
5437         LDKPaymentError_Routing_class =
5438                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
5439         CHECK(LDKPaymentError_Routing_class != NULL);
5440         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
5441         CHECK(LDKPaymentError_Routing_meth != NULL);
5442         LDKPaymentError_Sending_class =
5443                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
5444         CHECK(LDKPaymentError_Sending_class != NULL);
5445         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
5446         CHECK(LDKPaymentError_Sending_meth != NULL);
5447 }
5448 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5449         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5450         switch(obj->tag) {
5451                 case LDKPaymentError_Invoice: {
5452                         LDKStr invoice_str = obj->invoice;
5453                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
5454                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
5455                 }
5456                 case LDKPaymentError_Routing: {
5457                         LDKLightningError routing_var = obj->routing;
5458                         uint64_t routing_ref = 0;
5459                         CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5460                         CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5461                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5462                         routing_ref = (uint64_t)routing_var.inner & ~1;
5463                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
5464                 }
5465                 case LDKPaymentError_Sending: {
5466                         uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
5467                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
5468                 }
5469                 default: abort();
5470         }
5471 }
5472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5473         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
5474         CHECK(val->result_ok);
5475         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
5476         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
5477         return res_arr;
5478 }
5479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5480         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
5481         CHECK(!val->result_ok);
5482         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5483         return err_ref;
5484 }
5485 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5486         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
5487         CHECK(val->result_ok);
5488         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
5489         return res_conv;
5490 }
5491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5492         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
5493         CHECK(!val->result_ok);
5494         return *val->contents.err;
5495 }
5496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5497         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
5498         CHECK(val->result_ok);
5499         LDKInvoice res_var = (*val->contents.result);
5500         uint64_t res_ref = 0;
5501         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5502         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5503         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5504         res_ref = (uint64_t)res_var.inner & ~1;
5505         return res_ref;
5506 }
5507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5508         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
5509         CHECK(!val->result_ok);
5510         return *val->contents.err;
5511 }
5512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5513         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
5514         CHECK(val->result_ok);
5515         LDKSignedRawInvoice res_var = (*val->contents.result);
5516         uint64_t res_ref = 0;
5517         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5518         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5519         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5520         res_ref = (uint64_t)res_var.inner & ~1;
5521         return res_ref;
5522 }
5523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5524         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
5525         CHECK(!val->result_ok);
5526         return *val->contents.err;
5527 }
5528 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5529         return RawInvoice_clone(&tuple->a);
5530 }
5531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5532         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5533         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
5534         uint64_t ret_ref = 0;
5535         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5536         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5538         ret_ref = (uint64_t)ret_var.inner;
5539         if (ret_var.is_owned) {
5540                 ret_ref |= 1;
5541         }
5542         return ret_ref;
5543 }
5544
5545 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5546         return ThirtyTwoBytes_clone(&tuple->b);
5547 }
5548 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5549         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5550         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5551         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data);
5552         return ret_arr;
5553 }
5554
5555 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5556         return InvoiceSignature_clone(&tuple->c);
5557 }
5558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
5559         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5560         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
5561         uint64_t ret_ref = 0;
5562         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5563         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5565         ret_ref = (uint64_t)ret_var.inner;
5566         if (ret_var.is_owned) {
5567                 ret_ref |= 1;
5568         }
5569         return ret_ref;
5570 }
5571
5572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5573         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
5574         CHECK(val->result_ok);
5575         LDKPayeePubKey res_var = (*val->contents.result);
5576         uint64_t res_ref = 0;
5577         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5578         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5579         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5580         res_ref = (uint64_t)res_var.inner & ~1;
5581         return res_ref;
5582 }
5583 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5584         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
5585         CHECK(!val->result_ok);
5586         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5587         return err_conv;
5588 }
5589 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5590         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5591         for (size_t i = 0; i < ret.datalen; i++) {
5592                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5593         }
5594         return ret;
5595 }
5596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5597         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
5598         CHECK(val->result_ok);
5599         LDKPositiveTimestamp res_var = (*val->contents.result);
5600         uint64_t res_ref = 0;
5601         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5602         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5603         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5604         res_ref = (uint64_t)res_var.inner & ~1;
5605         return res_ref;
5606 }
5607 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5608         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
5609         CHECK(!val->result_ok);
5610         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5611         return err_conv;
5612 }
5613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5614         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
5615         CHECK(val->result_ok);
5616         return *val->contents.result;
5617 }
5618 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5619         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
5620         CHECK(!val->result_ok);
5621         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
5622         return err_conv;
5623 }
5624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5625         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
5626         CHECK(val->result_ok);
5627         LDKInvoice res_var = (*val->contents.result);
5628         uint64_t res_ref = 0;
5629         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5630         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5631         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5632         res_ref = (uint64_t)res_var.inner & ~1;
5633         return res_ref;
5634 }
5635 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5636         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
5637         CHECK(!val->result_ok);
5638         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
5639         return err_conv;
5640 }
5641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5642         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5643         CHECK(val->result_ok);
5644         LDKDescription res_var = (*val->contents.result);
5645         uint64_t res_ref = 0;
5646         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5647         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5648         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5649         res_ref = (uint64_t)res_var.inner & ~1;
5650         return res_ref;
5651 }
5652 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5653         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5654         CHECK(!val->result_ok);
5655         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5656         return err_conv;
5657 }
5658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5659         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5660         CHECK(val->result_ok);
5661         LDKExpiryTime res_var = (*val->contents.result);
5662         uint64_t res_ref = 0;
5663         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5664         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5665         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5666         res_ref = (uint64_t)res_var.inner & ~1;
5667         return res_ref;
5668 }
5669 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5670         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5671         CHECK(!val->result_ok);
5672         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5673         return err_conv;
5674 }
5675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5676         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5677         CHECK(val->result_ok);
5678         LDKPrivateRoute res_var = (*val->contents.result);
5679         uint64_t res_ref = 0;
5680         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5681         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5682         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5683         res_ref = (uint64_t)res_var.inner & ~1;
5684         return res_ref;
5685 }
5686 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5687         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5688         CHECK(!val->result_ok);
5689         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5690         return err_conv;
5691 }
5692 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5693         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5694         CHECK(val->result_ok);
5695         LDKStr res_str = (*val->contents.result);
5696         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
5697         return res_conv;
5698 }
5699 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5700         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5701         CHECK(!val->result_ok);
5702         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5703         return err_conv;
5704 }
5705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5706         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5707         CHECK(val->result_ok);
5708         LDKChannelMonitorUpdate res_var = (*val->contents.result);
5709         uint64_t res_ref = 0;
5710         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5711         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5712         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5713         res_ref = (uint64_t)res_var.inner & ~1;
5714         return res_ref;
5715 }
5716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5717         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5718         CHECK(!val->result_ok);
5719         LDKDecodeError err_var = (*val->contents.err);
5720         uint64_t err_ref = 0;
5721         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5722         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5723         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5724         err_ref = (uint64_t)err_var.inner & ~1;
5725         return err_ref;
5726 }
5727 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
5728 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
5729 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
5730 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
5731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
5732         LDKCOption_MonitorEventZ_Some_class =
5733                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
5734         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
5735         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
5736         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
5737         LDKCOption_MonitorEventZ_None_class =
5738                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
5739         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
5740         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
5741         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
5742 }
5743 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5744         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5745         switch(obj->tag) {
5746                 case LDKCOption_MonitorEventZ_Some: {
5747                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
5748                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
5749                 }
5750                 case LDKCOption_MonitorEventZ_None: {
5751                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
5752                 }
5753                 default: abort();
5754         }
5755 }
5756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5757         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
5758         CHECK(val->result_ok);
5759         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5760         return res_ref;
5761 }
5762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5763         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
5764         CHECK(!val->result_ok);
5765         LDKDecodeError err_var = (*val->contents.err);
5766         uint64_t err_ref = 0;
5767         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5768         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5769         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5770         err_ref = (uint64_t)err_var.inner & ~1;
5771         return err_ref;
5772 }
5773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5774         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5775         CHECK(val->result_ok);
5776         LDKHTLCUpdate res_var = (*val->contents.result);
5777         uint64_t res_ref = 0;
5778         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5779         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5780         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5781         res_ref = (uint64_t)res_var.inner & ~1;
5782         return res_ref;
5783 }
5784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5785         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5786         CHECK(!val->result_ok);
5787         LDKDecodeError err_var = (*val->contents.err);
5788         uint64_t err_ref = 0;
5789         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5790         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5791         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5792         err_ref = (uint64_t)err_var.inner & ~1;
5793         return err_ref;
5794 }
5795 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5796         return OutPoint_clone(&tuple->a);
5797 }
5798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5799         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5800         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
5801         uint64_t ret_ref = 0;
5802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5805         ret_ref = (uint64_t)ret_var.inner;
5806         if (ret_var.is_owned) {
5807                 ret_ref |= 1;
5808         }
5809         return ret_ref;
5810 }
5811
5812 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5813         return CVec_u8Z_clone(&tuple->b);
5814 }
5815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5816         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5817         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
5818         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5819         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5820         CVec_u8Z_free(ret_var);
5821         return ret_arr;
5822 }
5823
5824 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5825         return tuple->a;
5826 }
5827 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5828         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5829         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
5830         return ret_val;
5831 }
5832
5833 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5834         return CVec_u8Z_clone(&tuple->b);
5835 }
5836 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5837         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5838         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
5839         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5840         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5841         CVec_u8Z_free(ret_var);
5842         return ret_arr;
5843 }
5844
5845 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5846         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5847         for (size_t i = 0; i < ret.datalen; i++) {
5848                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5849         }
5850         return ret;
5851 }
5852 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5853         return ThirtyTwoBytes_clone(&tuple->a);
5854 }
5855 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5856         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5857         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5858         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data);
5859         return ret_arr;
5860 }
5861
5862 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5863         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
5864 }
5865 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5866         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5867         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
5868         int64_tArray ret_arr = NULL;
5869         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5870         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5871         for (size_t v = 0; v < ret_var.datalen; v++) {
5872                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5873                 *ret_conv_21_conv = ret_var.data[v];
5874                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
5875         }
5876         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5877         FREE(ret_var.data);
5878         return ret_arr;
5879 }
5880
5881 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5882         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 };
5883         for (size_t i = 0; i < ret.datalen; i++) {
5884                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5885         }
5886         return ret;
5887 }
5888 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5889         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5890         for (size_t i = 0; i < ret.datalen; i++) {
5891                 ret.data[i] = Event_clone(&orig->data[i]);
5892         }
5893         return ret;
5894 }
5895 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5896         return tuple->a;
5897 }
5898 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5899         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5900         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
5901         return ret_val;
5902 }
5903
5904 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5905         return TxOut_clone(&tuple->b);
5906 }
5907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5908         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5909         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5910         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
5911         return (uint64_t)ret_ref;
5912 }
5913
5914 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5915         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5916         for (size_t i = 0; i < ret.datalen; i++) {
5917                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5918         }
5919         return ret;
5920 }
5921 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5922         return ThirtyTwoBytes_clone(&tuple->a);
5923 }
5924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5925         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5926         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5927         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data);
5928         return ret_arr;
5929 }
5930
5931 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5932         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
5933 }
5934 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5935         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5936         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
5937         int64_tArray ret_arr = NULL;
5938         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5939         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5940         for (size_t u = 0; u < ret_var.datalen; u++) {
5941                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5942                 *ret_conv_20_conv = ret_var.data[u];
5943                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
5944         }
5945         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5946         FREE(ret_var.data);
5947         return ret_arr;
5948 }
5949
5950 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5951         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 };
5952         for (size_t i = 0; i < ret.datalen; i++) {
5953                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5954         }
5955         return ret;
5956 }
5957 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
5958 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
5959 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
5960 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
5961 static jclass LDKBalance_ContentiousClaimable_class = NULL;
5962 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
5963 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
5964 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
5965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
5966         LDKBalance_ClaimableOnChannelClose_class =
5967                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
5968         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
5969         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
5970         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
5971         LDKBalance_ClaimableAwaitingConfirmations_class =
5972                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
5973         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
5974         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
5975         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
5976         LDKBalance_ContentiousClaimable_class =
5977                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
5978         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
5979         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
5980         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
5981         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
5982                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
5983         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
5984         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
5985         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
5986 }
5987 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5988         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5989         switch(obj->tag) {
5990                 case LDKBalance_ClaimableOnChannelClose: {
5991                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
5992                 }
5993                 case LDKBalance_ClaimableAwaitingConfirmations: {
5994                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
5995                 }
5996                 case LDKBalance_ContentiousClaimable: {
5997                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
5998                 }
5999                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
6000                         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);
6001                 }
6002                 default: abort();
6003         }
6004 }
6005 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6006         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6007         for (size_t i = 0; i < ret.datalen; i++) {
6008                 ret.data[i] = Balance_clone(&orig->data[i]);
6009         }
6010         return ret;
6011 }
6012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6013         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
6014         CHECK(val->result_ok);
6015         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6016         *res_conv = (*val->contents.result);
6017         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
6018         return ((uint64_t)res_conv);
6019 }
6020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6021         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
6022         CHECK(!val->result_ok);
6023         LDKDecodeError err_var = (*val->contents.err);
6024         uint64_t err_ref = 0;
6025         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6026         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6027         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6028         err_ref = (uint64_t)err_var.inner & ~1;
6029         return err_ref;
6030 }
6031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6032         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
6033         CHECK(val->result_ok);
6034         return *val->contents.result;
6035 }
6036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6037         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
6038         CHECK(!val->result_ok);
6039         LDKLightningError err_var = (*val->contents.err);
6040         uint64_t err_ref = 0;
6041         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6042         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6043         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6044         err_ref = (uint64_t)err_var.inner & ~1;
6045         return err_ref;
6046 }
6047 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
6048         return tuple->a;
6049 }
6050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
6051         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
6052         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
6053         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form);
6054         return ret_arr;
6055 }
6056
6057 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
6058         return Type_clone(&tuple->b);
6059 }
6060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
6061         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
6062         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6063         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
6064         return (uint64_t)ret_ret;
6065 }
6066
6067 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6068         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6069         for (size_t i = 0; i < ret.datalen; i++) {
6070                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6071         }
6072         return ret;
6073 }
6074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6075         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
6076         CHECK(val->result_ok);
6077         return *val->contents.result;
6078 }
6079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6080         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
6081         CHECK(!val->result_ok);
6082         LDKLightningError err_var = (*val->contents.err);
6083         uint64_t err_ref = 0;
6084         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6085         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6086         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6087         err_ref = (uint64_t)err_var.inner & ~1;
6088         return err_ref;
6089 }
6090 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
6091         return ChannelAnnouncement_clone(&tuple->a);
6092 }
6093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
6094         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
6095         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
6096         uint64_t ret_ref = 0;
6097         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6098         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6100         ret_ref = (uint64_t)ret_var.inner;
6101         if (ret_var.is_owned) {
6102                 ret_ref |= 1;
6103         }
6104         return ret_ref;
6105 }
6106
6107 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
6108         return ChannelUpdate_clone(&tuple->b);
6109 }
6110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
6111         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
6112         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
6113         uint64_t ret_ref = 0;
6114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6117         ret_ref = (uint64_t)ret_var.inner;
6118         if (ret_var.is_owned) {
6119                 ret_ref |= 1;
6120         }
6121         return ret_ref;
6122 }
6123
6124 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
6125         return ChannelUpdate_clone(&tuple->c);
6126 }
6127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
6128         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
6129         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
6130         uint64_t ret_ref = 0;
6131         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6132         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6134         ret_ref = (uint64_t)ret_var.inner;
6135         if (ret_var.is_owned) {
6136                 ret_ref |= 1;
6137         }
6138         return ret_ref;
6139 }
6140
6141 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
6142         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
6143         for (size_t i = 0; i < ret.datalen; i++) {
6144                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
6145         }
6146         return ret;
6147 }
6148 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
6149         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
6150         for (size_t i = 0; i < ret.datalen; i++) {
6151                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
6152         }
6153         return ret;
6154 }
6155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6156         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
6157         CHECK(val->result_ok);
6158         LDKCVec_u8Z res_var = (*val->contents.result);
6159         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
6160         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
6161         return res_arr;
6162 }
6163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6164         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
6165         CHECK(!val->result_ok);
6166         LDKPeerHandleError err_var = (*val->contents.err);
6167         uint64_t err_ref = 0;
6168         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6169         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6170         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6171         err_ref = (uint64_t)err_var.inner & ~1;
6172         return err_ref;
6173 }
6174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6175         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
6176         CHECK(val->result_ok);
6177         return *val->contents.result;
6178 }
6179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6180         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
6181         CHECK(!val->result_ok);
6182         LDKPeerHandleError err_var = (*val->contents.err);
6183         uint64_t err_ref = 0;
6184         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6185         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6186         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6187         err_ref = (uint64_t)err_var.inner & ~1;
6188         return err_ref;
6189 }
6190 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6191         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
6192         CHECK(val->result_ok);
6193         return *val->contents.result;
6194 }
6195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6196         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
6197         CHECK(!val->result_ok);
6198         LDKPeerHandleError err_var = (*val->contents.err);
6199         uint64_t err_ref = 0;
6200         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6201         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6202         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6203         err_ref = (uint64_t)err_var.inner & ~1;
6204         return err_ref;
6205 }
6206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6207         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
6208         CHECK(val->result_ok);
6209         LDKNodeId res_var = (*val->contents.result);
6210         uint64_t res_ref = 0;
6211         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6212         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6213         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6214         res_ref = (uint64_t)res_var.inner & ~1;
6215         return res_ref;
6216 }
6217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6218         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
6219         CHECK(!val->result_ok);
6220         LDKDecodeError err_var = (*val->contents.err);
6221         uint64_t err_ref = 0;
6222         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6223         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6224         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6225         err_ref = (uint64_t)err_var.inner & ~1;
6226         return err_ref;
6227 }
6228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6229         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
6230         CHECK(val->result_ok);
6231         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6232         return res_ref;
6233 }
6234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6235         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
6236         CHECK(!val->result_ok);
6237         LDKDecodeError err_var = (*val->contents.err);
6238         uint64_t err_ref = 0;
6239         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6240         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6241         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6242         err_ref = (uint64_t)err_var.inner & ~1;
6243         return err_ref;
6244 }
6245 typedef struct LDKAccess_JCalls {
6246         atomic_size_t refcnt;
6247         JavaVM *vm;
6248         jweak o;
6249         jmethodID get_utxo_meth;
6250 } LDKAccess_JCalls;
6251 static void LDKAccess_JCalls_free(void* this_arg) {
6252         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6253         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6254                 JNIEnv *env;
6255                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6256                 if (get_jenv_res == JNI_EDETACHED) {
6257                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6258                 } else {
6259                         DO_ASSERT(get_jenv_res == JNI_OK);
6260                 }
6261                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6262                 if (get_jenv_res == JNI_EDETACHED) {
6263                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6264                 }
6265                 FREE(j_calls);
6266         }
6267 }
6268 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6269         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6270         JNIEnv *env;
6271         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6272         if (get_jenv_res == JNI_EDETACHED) {
6273                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6274         } else {
6275                 DO_ASSERT(get_jenv_res == JNI_OK);
6276         }
6277         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6278         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6279         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6280         CHECK(obj != NULL);
6281         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6282         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6283                 (*env)->ExceptionDescribe(env);
6284                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6285         }
6286         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6287         CHECK_ACCESS(ret_ptr);
6288         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6289         FREE((void*)ret);
6290         if (get_jenv_res == JNI_EDETACHED) {
6291                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6292         }
6293         return ret_conv;
6294 }
6295 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6296         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6297         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6298 }
6299 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6300         jclass c = (*env)->GetObjectClass(env, o);
6301         CHECK(c != NULL);
6302         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6303         atomic_init(&calls->refcnt, 1);
6304         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6305         calls->o = (*env)->NewWeakGlobalRef(env, o);
6306         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6307         CHECK(calls->get_utxo_meth != NULL);
6308
6309         LDKAccess ret = {
6310                 .this_arg = (void*) calls,
6311                 .get_utxo = get_utxo_LDKAccess_jcall,
6312                 .free = LDKAccess_JCalls_free,
6313         };
6314         return ret;
6315 }
6316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6317         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6318         *res_ptr = LDKAccess_init(env, clz, o);
6319         return (uint64_t)res_ptr;
6320 }
6321 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) {
6322         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6323         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6324         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6325         unsigned char genesis_hash_arr[32];
6326         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6327         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6328         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6329         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6330         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6331         return (uint64_t)ret_conv;
6332 }
6333
6334 static jclass LDKCOption_AccessZ_Some_class = NULL;
6335 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
6336 static jclass LDKCOption_AccessZ_None_class = NULL;
6337 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
6338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
6339         LDKCOption_AccessZ_Some_class =
6340                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
6341         CHECK(LDKCOption_AccessZ_Some_class != NULL);
6342         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
6343         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
6344         LDKCOption_AccessZ_None_class =
6345                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
6346         CHECK(LDKCOption_AccessZ_None_class != NULL);
6347         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
6348         CHECK(LDKCOption_AccessZ_None_meth != NULL);
6349 }
6350 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6351         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6352         switch(obj->tag) {
6353                 case LDKCOption_AccessZ_Some: {
6354                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6355                         *some_ret = obj->some;
6356                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
6357                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6358                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6359                                 LDKAccess_JCalls_cloned(&(*some_ret));
6360                         }
6361                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uint64_t)some_ret);
6362                 }
6363                 case LDKCOption_AccessZ_None: {
6364                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
6365                 }
6366                 default: abort();
6367         }
6368 }
6369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6370         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6371         CHECK(val->result_ok);
6372         LDKDirectionalChannelInfo res_var = (*val->contents.result);
6373         uint64_t res_ref = 0;
6374         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6375         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6376         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6377         res_ref = (uint64_t)res_var.inner & ~1;
6378         return res_ref;
6379 }
6380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6381         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6382         CHECK(!val->result_ok);
6383         LDKDecodeError err_var = (*val->contents.err);
6384         uint64_t err_ref = 0;
6385         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6386         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6387         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6388         err_ref = (uint64_t)err_var.inner & ~1;
6389         return err_ref;
6390 }
6391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6392         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6393         CHECK(val->result_ok);
6394         LDKChannelInfo res_var = (*val->contents.result);
6395         uint64_t res_ref = 0;
6396         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6397         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6398         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6399         res_ref = (uint64_t)res_var.inner & ~1;
6400         return res_ref;
6401 }
6402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6403         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6404         CHECK(!val->result_ok);
6405         LDKDecodeError err_var = (*val->contents.err);
6406         uint64_t err_ref = 0;
6407         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6408         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6409         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6410         err_ref = (uint64_t)err_var.inner & ~1;
6411         return err_ref;
6412 }
6413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6414         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6415         CHECK(val->result_ok);
6416         LDKRoutingFees res_var = (*val->contents.result);
6417         uint64_t res_ref = 0;
6418         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6419         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6420         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6421         res_ref = (uint64_t)res_var.inner & ~1;
6422         return res_ref;
6423 }
6424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6425         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6426         CHECK(!val->result_ok);
6427         LDKDecodeError err_var = (*val->contents.err);
6428         uint64_t err_ref = 0;
6429         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6430         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6431         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6432         err_ref = (uint64_t)err_var.inner & ~1;
6433         return err_ref;
6434 }
6435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6436         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6437         CHECK(val->result_ok);
6438         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
6439         uint64_t res_ref = 0;
6440         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6441         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6442         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6443         res_ref = (uint64_t)res_var.inner & ~1;
6444         return res_ref;
6445 }
6446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6447         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6448         CHECK(!val->result_ok);
6449         LDKDecodeError err_var = (*val->contents.err);
6450         uint64_t err_ref = 0;
6451         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6452         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6453         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6454         err_ref = (uint64_t)err_var.inner & ~1;
6455         return err_ref;
6456 }
6457 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6458         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6459         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6460         return ret;
6461 }
6462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6463         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6464         CHECK(val->result_ok);
6465         LDKNodeInfo res_var = (*val->contents.result);
6466         uint64_t res_ref = 0;
6467         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6468         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6469         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6470         res_ref = (uint64_t)res_var.inner & ~1;
6471         return res_ref;
6472 }
6473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6474         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6475         CHECK(!val->result_ok);
6476         LDKDecodeError err_var = (*val->contents.err);
6477         uint64_t err_ref = 0;
6478         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6479         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6480         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6481         err_ref = (uint64_t)err_var.inner & ~1;
6482         return err_ref;
6483 }
6484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6485         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6486         CHECK(val->result_ok);
6487         LDKNetworkGraph res_var = (*val->contents.result);
6488         uint64_t res_ref = 0;
6489         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6490         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6491         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6492         res_ref = (uint64_t)res_var.inner & ~1;
6493         return res_ref;
6494 }
6495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6496         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6497         CHECK(!val->result_ok);
6498         LDKDecodeError err_var = (*val->contents.err);
6499         uint64_t err_ref = 0;
6500         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6501         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6502         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6503         err_ref = (uint64_t)err_var.inner & ~1;
6504         return err_ref;
6505 }
6506 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
6507 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
6508 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
6509 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
6510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
6511         LDKCOption_CVec_NetAddressZZ_Some_class =
6512                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
6513         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
6514         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
6515         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
6516         LDKCOption_CVec_NetAddressZZ_None_class =
6517                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
6518         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
6519         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
6520         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
6521 }
6522 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6523         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6524         switch(obj->tag) {
6525                 case LDKCOption_CVec_NetAddressZZ_Some: {
6526                         LDKCVec_NetAddressZ some_var = obj->some;
6527                         int64_tArray some_arr = NULL;
6528                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
6529                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
6530                         for (size_t m = 0; m < some_var.datalen; m++) {
6531                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
6532                                 some_arr_ptr[m] = some_conv_12_ref;
6533                         }
6534                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
6535                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
6536                 }
6537                 case LDKCOption_CVec_NetAddressZZ_None: {
6538                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
6539                 }
6540                 default: abort();
6541         }
6542 }
6543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6544         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6545         CHECK(val->result_ok);
6546         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6547         return res_ref;
6548 }
6549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6550         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6551         CHECK(!val->result_ok);
6552         LDKDecodeError err_var = (*val->contents.err);
6553         uint64_t err_ref = 0;
6554         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6555         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6556         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6557         err_ref = (uint64_t)err_var.inner & ~1;
6558         return err_ref;
6559 }
6560 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6561         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6562         for (size_t i = 0; i < ret.datalen; i++) {
6563                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6564         }
6565         return ret;
6566 }
6567 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6568         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6569         for (size_t i = 0; i < ret.datalen; i++) {
6570                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6571         }
6572         return ret;
6573 }
6574 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6575         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6576         for (size_t i = 0; i < ret.datalen; i++) {
6577                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6578         }
6579         return ret;
6580 }
6581 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6582         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6583         for (size_t i = 0; i < ret.datalen; i++) {
6584                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6585         }
6586         return ret;
6587 }
6588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6589         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6590         CHECK(val->result_ok);
6591         LDKAcceptChannel res_var = (*val->contents.result);
6592         uint64_t res_ref = 0;
6593         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6594         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6595         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6596         res_ref = (uint64_t)res_var.inner & ~1;
6597         return res_ref;
6598 }
6599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6600         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6601         CHECK(!val->result_ok);
6602         LDKDecodeError err_var = (*val->contents.err);
6603         uint64_t err_ref = 0;
6604         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6605         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6606         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6607         err_ref = (uint64_t)err_var.inner & ~1;
6608         return err_ref;
6609 }
6610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6611         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6612         CHECK(val->result_ok);
6613         LDKAnnouncementSignatures res_var = (*val->contents.result);
6614         uint64_t res_ref = 0;
6615         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6616         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6617         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6618         res_ref = (uint64_t)res_var.inner & ~1;
6619         return res_ref;
6620 }
6621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6622         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6623         CHECK(!val->result_ok);
6624         LDKDecodeError err_var = (*val->contents.err);
6625         uint64_t err_ref = 0;
6626         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6627         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6628         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6629         err_ref = (uint64_t)err_var.inner & ~1;
6630         return err_ref;
6631 }
6632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6633         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6634         CHECK(val->result_ok);
6635         LDKChannelReestablish res_var = (*val->contents.result);
6636         uint64_t res_ref = 0;
6637         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6638         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6639         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6640         res_ref = (uint64_t)res_var.inner & ~1;
6641         return res_ref;
6642 }
6643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6644         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6645         CHECK(!val->result_ok);
6646         LDKDecodeError err_var = (*val->contents.err);
6647         uint64_t err_ref = 0;
6648         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6649         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6650         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6651         err_ref = (uint64_t)err_var.inner & ~1;
6652         return err_ref;
6653 }
6654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6655         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6656         CHECK(val->result_ok);
6657         LDKClosingSigned res_var = (*val->contents.result);
6658         uint64_t res_ref = 0;
6659         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6660         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6661         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6662         res_ref = (uint64_t)res_var.inner & ~1;
6663         return res_ref;
6664 }
6665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6666         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6667         CHECK(!val->result_ok);
6668         LDKDecodeError err_var = (*val->contents.err);
6669         uint64_t err_ref = 0;
6670         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6671         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6672         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6673         err_ref = (uint64_t)err_var.inner & ~1;
6674         return err_ref;
6675 }
6676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6677         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6678         CHECK(val->result_ok);
6679         LDKClosingSignedFeeRange res_var = (*val->contents.result);
6680         uint64_t res_ref = 0;
6681         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6682         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6683         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6684         res_ref = (uint64_t)res_var.inner & ~1;
6685         return res_ref;
6686 }
6687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6688         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6689         CHECK(!val->result_ok);
6690         LDKDecodeError err_var = (*val->contents.err);
6691         uint64_t err_ref = 0;
6692         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6693         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6694         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6695         err_ref = (uint64_t)err_var.inner & ~1;
6696         return err_ref;
6697 }
6698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6699         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6700         CHECK(val->result_ok);
6701         LDKCommitmentSigned res_var = (*val->contents.result);
6702         uint64_t res_ref = 0;
6703         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6704         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6705         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6706         res_ref = (uint64_t)res_var.inner & ~1;
6707         return res_ref;
6708 }
6709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6710         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6711         CHECK(!val->result_ok);
6712         LDKDecodeError err_var = (*val->contents.err);
6713         uint64_t err_ref = 0;
6714         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6715         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6716         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6717         err_ref = (uint64_t)err_var.inner & ~1;
6718         return err_ref;
6719 }
6720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6721         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6722         CHECK(val->result_ok);
6723         LDKFundingCreated res_var = (*val->contents.result);
6724         uint64_t res_ref = 0;
6725         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6726         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6727         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6728         res_ref = (uint64_t)res_var.inner & ~1;
6729         return res_ref;
6730 }
6731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6732         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6733         CHECK(!val->result_ok);
6734         LDKDecodeError err_var = (*val->contents.err);
6735         uint64_t err_ref = 0;
6736         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6737         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6738         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6739         err_ref = (uint64_t)err_var.inner & ~1;
6740         return err_ref;
6741 }
6742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6743         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6744         CHECK(val->result_ok);
6745         LDKFundingSigned res_var = (*val->contents.result);
6746         uint64_t res_ref = 0;
6747         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6748         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6749         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6750         res_ref = (uint64_t)res_var.inner & ~1;
6751         return res_ref;
6752 }
6753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6754         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6755         CHECK(!val->result_ok);
6756         LDKDecodeError err_var = (*val->contents.err);
6757         uint64_t err_ref = 0;
6758         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6759         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6760         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6761         err_ref = (uint64_t)err_var.inner & ~1;
6762         return err_ref;
6763 }
6764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6765         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6766         CHECK(val->result_ok);
6767         LDKFundingLocked res_var = (*val->contents.result);
6768         uint64_t res_ref = 0;
6769         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6770         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6771         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6772         res_ref = (uint64_t)res_var.inner & ~1;
6773         return res_ref;
6774 }
6775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6776         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6777         CHECK(!val->result_ok);
6778         LDKDecodeError err_var = (*val->contents.err);
6779         uint64_t err_ref = 0;
6780         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6781         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6782         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6783         err_ref = (uint64_t)err_var.inner & ~1;
6784         return err_ref;
6785 }
6786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6787         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6788         CHECK(val->result_ok);
6789         LDKInit res_var = (*val->contents.result);
6790         uint64_t res_ref = 0;
6791         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6792         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6793         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6794         res_ref = (uint64_t)res_var.inner & ~1;
6795         return res_ref;
6796 }
6797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6798         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6799         CHECK(!val->result_ok);
6800         LDKDecodeError err_var = (*val->contents.err);
6801         uint64_t err_ref = 0;
6802         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6803         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6804         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6805         err_ref = (uint64_t)err_var.inner & ~1;
6806         return err_ref;
6807 }
6808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6809         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6810         CHECK(val->result_ok);
6811         LDKOpenChannel res_var = (*val->contents.result);
6812         uint64_t res_ref = 0;
6813         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6814         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6815         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6816         res_ref = (uint64_t)res_var.inner & ~1;
6817         return res_ref;
6818 }
6819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6820         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6821         CHECK(!val->result_ok);
6822         LDKDecodeError err_var = (*val->contents.err);
6823         uint64_t err_ref = 0;
6824         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6825         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6826         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6827         err_ref = (uint64_t)err_var.inner & ~1;
6828         return err_ref;
6829 }
6830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6831         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6832         CHECK(val->result_ok);
6833         LDKRevokeAndACK res_var = (*val->contents.result);
6834         uint64_t res_ref = 0;
6835         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6836         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6837         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6838         res_ref = (uint64_t)res_var.inner & ~1;
6839         return res_ref;
6840 }
6841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6842         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6843         CHECK(!val->result_ok);
6844         LDKDecodeError err_var = (*val->contents.err);
6845         uint64_t err_ref = 0;
6846         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6847         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6848         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6849         err_ref = (uint64_t)err_var.inner & ~1;
6850         return err_ref;
6851 }
6852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6853         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6854         CHECK(val->result_ok);
6855         LDKShutdown res_var = (*val->contents.result);
6856         uint64_t res_ref = 0;
6857         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6858         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6859         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6860         res_ref = (uint64_t)res_var.inner & ~1;
6861         return res_ref;
6862 }
6863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6864         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6865         CHECK(!val->result_ok);
6866         LDKDecodeError err_var = (*val->contents.err);
6867         uint64_t err_ref = 0;
6868         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6869         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6870         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6871         err_ref = (uint64_t)err_var.inner & ~1;
6872         return err_ref;
6873 }
6874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6875         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6876         CHECK(val->result_ok);
6877         LDKUpdateFailHTLC res_var = (*val->contents.result);
6878         uint64_t res_ref = 0;
6879         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6880         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6881         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6882         res_ref = (uint64_t)res_var.inner & ~1;
6883         return res_ref;
6884 }
6885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6886         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6887         CHECK(!val->result_ok);
6888         LDKDecodeError err_var = (*val->contents.err);
6889         uint64_t err_ref = 0;
6890         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6891         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6892         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6893         err_ref = (uint64_t)err_var.inner & ~1;
6894         return err_ref;
6895 }
6896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6897         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6898         CHECK(val->result_ok);
6899         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
6900         uint64_t res_ref = 0;
6901         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6902         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6903         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6904         res_ref = (uint64_t)res_var.inner & ~1;
6905         return res_ref;
6906 }
6907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6908         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6909         CHECK(!val->result_ok);
6910         LDKDecodeError err_var = (*val->contents.err);
6911         uint64_t err_ref = 0;
6912         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6913         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6914         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6915         err_ref = (uint64_t)err_var.inner & ~1;
6916         return err_ref;
6917 }
6918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6919         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6920         CHECK(val->result_ok);
6921         LDKUpdateFee res_var = (*val->contents.result);
6922         uint64_t res_ref = 0;
6923         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6924         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6925         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6926         res_ref = (uint64_t)res_var.inner & ~1;
6927         return res_ref;
6928 }
6929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6930         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6931         CHECK(!val->result_ok);
6932         LDKDecodeError err_var = (*val->contents.err);
6933         uint64_t err_ref = 0;
6934         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6935         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6936         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6937         err_ref = (uint64_t)err_var.inner & ~1;
6938         return err_ref;
6939 }
6940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6941         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6942         CHECK(val->result_ok);
6943         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
6944         uint64_t res_ref = 0;
6945         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6946         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6947         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6948         res_ref = (uint64_t)res_var.inner & ~1;
6949         return res_ref;
6950 }
6951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6952         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6953         CHECK(!val->result_ok);
6954         LDKDecodeError err_var = (*val->contents.err);
6955         uint64_t err_ref = 0;
6956         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6957         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6958         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6959         err_ref = (uint64_t)err_var.inner & ~1;
6960         return err_ref;
6961 }
6962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6963         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6964         CHECK(val->result_ok);
6965         LDKUpdateAddHTLC res_var = (*val->contents.result);
6966         uint64_t res_ref = 0;
6967         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6968         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6969         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6970         res_ref = (uint64_t)res_var.inner & ~1;
6971         return res_ref;
6972 }
6973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6974         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6975         CHECK(!val->result_ok);
6976         LDKDecodeError err_var = (*val->contents.err);
6977         uint64_t err_ref = 0;
6978         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6979         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6980         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6981         err_ref = (uint64_t)err_var.inner & ~1;
6982         return err_ref;
6983 }
6984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6985         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6986         CHECK(val->result_ok);
6987         LDKPing res_var = (*val->contents.result);
6988         uint64_t res_ref = 0;
6989         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6990         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6991         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6992         res_ref = (uint64_t)res_var.inner & ~1;
6993         return res_ref;
6994 }
6995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6996         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6997         CHECK(!val->result_ok);
6998         LDKDecodeError err_var = (*val->contents.err);
6999         uint64_t err_ref = 0;
7000         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7001         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7002         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7003         err_ref = (uint64_t)err_var.inner & ~1;
7004         return err_ref;
7005 }
7006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7007         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
7008         CHECK(val->result_ok);
7009         LDKPong res_var = (*val->contents.result);
7010         uint64_t res_ref = 0;
7011         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7012         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7013         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7014         res_ref = (uint64_t)res_var.inner & ~1;
7015         return res_ref;
7016 }
7017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7018         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
7019         CHECK(!val->result_ok);
7020         LDKDecodeError err_var = (*val->contents.err);
7021         uint64_t err_ref = 0;
7022         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7023         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7024         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7025         err_ref = (uint64_t)err_var.inner & ~1;
7026         return err_ref;
7027 }
7028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7029         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
7030         CHECK(val->result_ok);
7031         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
7032         uint64_t res_ref = 0;
7033         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7034         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7035         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7036         res_ref = (uint64_t)res_var.inner & ~1;
7037         return res_ref;
7038 }
7039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7040         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
7041         CHECK(!val->result_ok);
7042         LDKDecodeError err_var = (*val->contents.err);
7043         uint64_t err_ref = 0;
7044         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7045         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7046         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7047         err_ref = (uint64_t)err_var.inner & ~1;
7048         return err_ref;
7049 }
7050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7051         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
7052         CHECK(val->result_ok);
7053         LDKChannelAnnouncement res_var = (*val->contents.result);
7054         uint64_t res_ref = 0;
7055         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7056         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7057         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7058         res_ref = (uint64_t)res_var.inner & ~1;
7059         return res_ref;
7060 }
7061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7062         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
7063         CHECK(!val->result_ok);
7064         LDKDecodeError err_var = (*val->contents.err);
7065         uint64_t err_ref = 0;
7066         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7067         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7068         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7069         err_ref = (uint64_t)err_var.inner & ~1;
7070         return err_ref;
7071 }
7072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7073         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
7074         CHECK(val->result_ok);
7075         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
7076         uint64_t res_ref = 0;
7077         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7078         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7079         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7080         res_ref = (uint64_t)res_var.inner & ~1;
7081         return res_ref;
7082 }
7083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7084         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
7085         CHECK(!val->result_ok);
7086         LDKDecodeError err_var = (*val->contents.err);
7087         uint64_t err_ref = 0;
7088         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7089         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7090         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7091         err_ref = (uint64_t)err_var.inner & ~1;
7092         return err_ref;
7093 }
7094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7095         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
7096         CHECK(val->result_ok);
7097         LDKChannelUpdate res_var = (*val->contents.result);
7098         uint64_t res_ref = 0;
7099         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7100         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7101         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7102         res_ref = (uint64_t)res_var.inner & ~1;
7103         return res_ref;
7104 }
7105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7106         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
7107         CHECK(!val->result_ok);
7108         LDKDecodeError err_var = (*val->contents.err);
7109         uint64_t err_ref = 0;
7110         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7111         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7112         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7113         err_ref = (uint64_t)err_var.inner & ~1;
7114         return err_ref;
7115 }
7116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7117         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
7118         CHECK(val->result_ok);
7119         LDKErrorMessage res_var = (*val->contents.result);
7120         uint64_t res_ref = 0;
7121         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7122         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7123         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7124         res_ref = (uint64_t)res_var.inner & ~1;
7125         return res_ref;
7126 }
7127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7128         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
7129         CHECK(!val->result_ok);
7130         LDKDecodeError err_var = (*val->contents.err);
7131         uint64_t err_ref = 0;
7132         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7133         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7134         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7135         err_ref = (uint64_t)err_var.inner & ~1;
7136         return err_ref;
7137 }
7138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7139         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
7140         CHECK(val->result_ok);
7141         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
7142         uint64_t res_ref = 0;
7143         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7144         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7145         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7146         res_ref = (uint64_t)res_var.inner & ~1;
7147         return res_ref;
7148 }
7149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7150         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
7151         CHECK(!val->result_ok);
7152         LDKDecodeError err_var = (*val->contents.err);
7153         uint64_t err_ref = 0;
7154         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7155         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7156         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7157         err_ref = (uint64_t)err_var.inner & ~1;
7158         return err_ref;
7159 }
7160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7161         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
7162         CHECK(val->result_ok);
7163         LDKNodeAnnouncement res_var = (*val->contents.result);
7164         uint64_t res_ref = 0;
7165         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7166         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7167         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7168         res_ref = (uint64_t)res_var.inner & ~1;
7169         return res_ref;
7170 }
7171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7172         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
7173         CHECK(!val->result_ok);
7174         LDKDecodeError err_var = (*val->contents.err);
7175         uint64_t err_ref = 0;
7176         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7177         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7178         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7179         err_ref = (uint64_t)err_var.inner & ~1;
7180         return err_ref;
7181 }
7182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7183         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
7184         CHECK(val->result_ok);
7185         LDKQueryShortChannelIds res_var = (*val->contents.result);
7186         uint64_t res_ref = 0;
7187         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7188         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7189         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7190         res_ref = (uint64_t)res_var.inner & ~1;
7191         return res_ref;
7192 }
7193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7194         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
7195         CHECK(!val->result_ok);
7196         LDKDecodeError err_var = (*val->contents.err);
7197         uint64_t err_ref = 0;
7198         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7199         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7200         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7201         err_ref = (uint64_t)err_var.inner & ~1;
7202         return err_ref;
7203 }
7204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7205         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
7206         CHECK(val->result_ok);
7207         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
7208         uint64_t res_ref = 0;
7209         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7210         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7211         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7212         res_ref = (uint64_t)res_var.inner & ~1;
7213         return res_ref;
7214 }
7215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7216         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
7217         CHECK(!val->result_ok);
7218         LDKDecodeError err_var = (*val->contents.err);
7219         uint64_t err_ref = 0;
7220         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7221         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7222         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7223         err_ref = (uint64_t)err_var.inner & ~1;
7224         return err_ref;
7225 }
7226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7227         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
7228         CHECK(val->result_ok);
7229         LDKQueryChannelRange res_var = (*val->contents.result);
7230         uint64_t res_ref = 0;
7231         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7232         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7233         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7234         res_ref = (uint64_t)res_var.inner & ~1;
7235         return res_ref;
7236 }
7237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7238         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
7239         CHECK(!val->result_ok);
7240         LDKDecodeError err_var = (*val->contents.err);
7241         uint64_t err_ref = 0;
7242         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7243         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7244         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7245         err_ref = (uint64_t)err_var.inner & ~1;
7246         return err_ref;
7247 }
7248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7249         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7250         CHECK(val->result_ok);
7251         LDKReplyChannelRange res_var = (*val->contents.result);
7252         uint64_t res_ref = 0;
7253         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7254         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7255         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7256         res_ref = (uint64_t)res_var.inner & ~1;
7257         return res_ref;
7258 }
7259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7260         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
7261         CHECK(!val->result_ok);
7262         LDKDecodeError err_var = (*val->contents.err);
7263         uint64_t err_ref = 0;
7264         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7265         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7266         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7267         err_ref = (uint64_t)err_var.inner & ~1;
7268         return err_ref;
7269 }
7270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7271         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7272         CHECK(val->result_ok);
7273         LDKGossipTimestampFilter res_var = (*val->contents.result);
7274         uint64_t res_ref = 0;
7275         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7276         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7277         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7278         res_ref = (uint64_t)res_var.inner & ~1;
7279         return res_ref;
7280 }
7281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7282         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7283         CHECK(!val->result_ok);
7284         LDKDecodeError err_var = (*val->contents.err);
7285         uint64_t err_ref = 0;
7286         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7287         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7288         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7289         err_ref = (uint64_t)err_var.inner & ~1;
7290         return err_ref;
7291 }
7292 static jclass LDKSignOrCreationError_SignError_class = NULL;
7293 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
7294 static jclass LDKSignOrCreationError_CreationError_class = NULL;
7295 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
7296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
7297         LDKSignOrCreationError_SignError_class =
7298                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
7299         CHECK(LDKSignOrCreationError_SignError_class != NULL);
7300         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
7301         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
7302         LDKSignOrCreationError_CreationError_class =
7303                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
7304         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
7305         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
7306         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
7307 }
7308 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7309         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7310         switch(obj->tag) {
7311                 case LDKSignOrCreationError_SignError: {
7312                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
7313                 }
7314                 case LDKSignOrCreationError_CreationError: {
7315                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
7316                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
7317                 }
7318                 default: abort();
7319         }
7320 }
7321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7322         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7323         CHECK(val->result_ok);
7324         LDKInvoice res_var = (*val->contents.result);
7325         uint64_t res_ref = 0;
7326         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7327         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7328         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7329         res_ref = (uint64_t)res_var.inner & ~1;
7330         return res_ref;
7331 }
7332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7333         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7334         CHECK(!val->result_ok);
7335         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
7336         return err_ref;
7337 }
7338 typedef struct LDKFilter_JCalls {
7339         atomic_size_t refcnt;
7340         JavaVM *vm;
7341         jweak o;
7342         jmethodID register_tx_meth;
7343         jmethodID register_output_meth;
7344 } LDKFilter_JCalls;
7345 static void LDKFilter_JCalls_free(void* this_arg) {
7346         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7347         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7348                 JNIEnv *env;
7349                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7350                 if (get_jenv_res == JNI_EDETACHED) {
7351                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7352                 } else {
7353                         DO_ASSERT(get_jenv_res == JNI_OK);
7354                 }
7355                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7356                 if (get_jenv_res == JNI_EDETACHED) {
7357                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7358                 }
7359                 FREE(j_calls);
7360         }
7361 }
7362 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7363         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7364         JNIEnv *env;
7365         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7366         if (get_jenv_res == JNI_EDETACHED) {
7367                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7368         } else {
7369                 DO_ASSERT(get_jenv_res == JNI_OK);
7370         }
7371         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7372         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7373         LDKu8slice script_pubkey_var = script_pubkey;
7374         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
7375         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
7376         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7377         CHECK(obj != NULL);
7378         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
7379         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7380                 (*env)->ExceptionDescribe(env);
7381                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
7382         }
7383         if (get_jenv_res == JNI_EDETACHED) {
7384                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7385         }
7386 }
7387 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7388         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7389         JNIEnv *env;
7390         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7391         if (get_jenv_res == JNI_EDETACHED) {
7392                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7393         } else {
7394                 DO_ASSERT(get_jenv_res == JNI_OK);
7395         }
7396         LDKWatchedOutput output_var = output;
7397         uint64_t output_ref = 0;
7398         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7399         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7400         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7401         output_ref = (uint64_t)output_var.inner;
7402         if (output_var.is_owned) {
7403                 output_ref |= 1;
7404         }
7405         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7406         CHECK(obj != NULL);
7407         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
7408         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7409                 (*env)->ExceptionDescribe(env);
7410                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
7411         }
7412         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7413         CHECK_ACCESS(ret_ptr);
7414         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7415         FREE((void*)ret);
7416         if (get_jenv_res == JNI_EDETACHED) {
7417                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7418         }
7419         return ret_conv;
7420 }
7421 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7422         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7423         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7424 }
7425 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7426         jclass c = (*env)->GetObjectClass(env, o);
7427         CHECK(c != NULL);
7428         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7429         atomic_init(&calls->refcnt, 1);
7430         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7431         calls->o = (*env)->NewWeakGlobalRef(env, o);
7432         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7433         CHECK(calls->register_tx_meth != NULL);
7434         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7435         CHECK(calls->register_output_meth != NULL);
7436
7437         LDKFilter ret = {
7438                 .this_arg = (void*) calls,
7439                 .register_tx = register_tx_LDKFilter_jcall,
7440                 .register_output = register_output_LDKFilter_jcall,
7441                 .free = LDKFilter_JCalls_free,
7442         };
7443         return ret;
7444 }
7445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7446         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7447         *res_ptr = LDKFilter_init(env, clz, o);
7448         return (uint64_t)res_ptr;
7449 }
7450 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) {
7451         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7452         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7453         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7454         unsigned char txid_arr[32];
7455         CHECK((*env)->GetArrayLength(env, txid) == 32);
7456         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7457         unsigned char (*txid_ref)[32] = &txid_arr;
7458         LDKu8slice script_pubkey_ref;
7459         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7460         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7461         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7462         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7463 }
7464
7465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7466         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7467         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7468         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7469         LDKWatchedOutput output_conv;
7470         output_conv.inner = (void*)(output & (~1));
7471         output_conv.is_owned = (output & 1) || (output == 0);
7472         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7473         output_conv = WatchedOutput_clone(&output_conv);
7474         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7475         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7476         uint64_t ret_ref = (uint64_t)ret_copy;
7477         return ret_ref;
7478 }
7479
7480 static jclass LDKCOption_FilterZ_Some_class = NULL;
7481 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
7482 static jclass LDKCOption_FilterZ_None_class = NULL;
7483 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
7484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
7485         LDKCOption_FilterZ_Some_class =
7486                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
7487         CHECK(LDKCOption_FilterZ_Some_class != NULL);
7488         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
7489         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
7490         LDKCOption_FilterZ_None_class =
7491                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
7492         CHECK(LDKCOption_FilterZ_None_class != NULL);
7493         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
7494         CHECK(LDKCOption_FilterZ_None_meth != NULL);
7495 }
7496 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7497         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7498         switch(obj->tag) {
7499                 case LDKCOption_FilterZ_Some: {
7500                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7501                         *some_ret = obj->some;
7502                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
7503                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7504                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7505                                 LDKFilter_JCalls_cloned(&(*some_ret));
7506                         }
7507                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uint64_t)some_ret);
7508                 }
7509                 case LDKCOption_FilterZ_None: {
7510                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
7511                 }
7512                 default: abort();
7513         }
7514 }
7515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7516         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7517         CHECK(val->result_ok);
7518         LDKLockedChannelMonitor res_var = (*val->contents.result);
7519         uint64_t res_ref = 0;
7520         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7521         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7522         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7523         res_ref = (uint64_t)res_var.inner & ~1;
7524         return res_ref;
7525 }
7526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7527         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7528         CHECK(!val->result_ok);
7529         return *val->contents.err;
7530 }
7531 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7532         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7533         for (size_t i = 0; i < ret.datalen; i++) {
7534                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7535         }
7536         return ret;
7537 }
7538 typedef struct LDKMessageSendEventsProvider_JCalls {
7539         atomic_size_t refcnt;
7540         JavaVM *vm;
7541         jweak o;
7542         jmethodID get_and_clear_pending_msg_events_meth;
7543 } LDKMessageSendEventsProvider_JCalls;
7544 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7545         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7546         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7547                 JNIEnv *env;
7548                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7549                 if (get_jenv_res == JNI_EDETACHED) {
7550                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7551                 } else {
7552                         DO_ASSERT(get_jenv_res == JNI_OK);
7553                 }
7554                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7555                 if (get_jenv_res == JNI_EDETACHED) {
7556                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7557                 }
7558                 FREE(j_calls);
7559         }
7560 }
7561 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7562         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7563         JNIEnv *env;
7564         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7565         if (get_jenv_res == JNI_EDETACHED) {
7566                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7567         } else {
7568                 DO_ASSERT(get_jenv_res == JNI_OK);
7569         }
7570         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7571         CHECK(obj != NULL);
7572         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
7573         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7574                 (*env)->ExceptionDescribe(env);
7575                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
7576         }
7577         LDKCVec_MessageSendEventZ ret_constr;
7578         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7579         if (ret_constr.datalen > 0)
7580                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7581         else
7582                 ret_constr.data = NULL;
7583         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7584         for (size_t s = 0; s < ret_constr.datalen; s++) {
7585                 int64_t ret_conv_18 = ret_vals[s];
7586                 void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
7587                 CHECK_ACCESS(ret_conv_18_ptr);
7588                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
7589                 FREE((void*)ret_conv_18);
7590                 ret_constr.data[s] = ret_conv_18_conv;
7591         }
7592         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7593         if (get_jenv_res == JNI_EDETACHED) {
7594                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7595         }
7596         return ret_constr;
7597 }
7598 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7599         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7600         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7601 }
7602 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7603         jclass c = (*env)->GetObjectClass(env, o);
7604         CHECK(c != NULL);
7605         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7606         atomic_init(&calls->refcnt, 1);
7607         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7608         calls->o = (*env)->NewWeakGlobalRef(env, o);
7609         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
7610         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
7611
7612         LDKMessageSendEventsProvider ret = {
7613                 .this_arg = (void*) calls,
7614                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7615                 .free = LDKMessageSendEventsProvider_JCalls_free,
7616         };
7617         return ret;
7618 }
7619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7620         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7621         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
7622         return (uint64_t)res_ptr;
7623 }
7624 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7625         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7626         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7627         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
7628         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7629         int64_tArray ret_arr = NULL;
7630         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7631         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7632         for (size_t s = 0; s < ret_var.datalen; s++) {
7633                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7634                 *ret_conv_18_copy = ret_var.data[s];
7635                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
7636                 ret_arr_ptr[s] = ret_conv_18_ref;
7637         }
7638         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7639         FREE(ret_var.data);
7640         return ret_arr;
7641 }
7642
7643 typedef struct LDKEventHandler_JCalls {
7644         atomic_size_t refcnt;
7645         JavaVM *vm;
7646         jweak o;
7647         jmethodID handle_event_meth;
7648 } LDKEventHandler_JCalls;
7649 static void LDKEventHandler_JCalls_free(void* this_arg) {
7650         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7651         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7652                 JNIEnv *env;
7653                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7654                 if (get_jenv_res == JNI_EDETACHED) {
7655                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7656                 } else {
7657                         DO_ASSERT(get_jenv_res == JNI_OK);
7658                 }
7659                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7660                 if (get_jenv_res == JNI_EDETACHED) {
7661                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7662                 }
7663                 FREE(j_calls);
7664         }
7665 }
7666 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7667         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7668         JNIEnv *env;
7669         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7670         if (get_jenv_res == JNI_EDETACHED) {
7671                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7672         } else {
7673                 DO_ASSERT(get_jenv_res == JNI_OK);
7674         }
7675         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7676         *ret_event = Event_clone(event);
7677         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7678         CHECK(obj != NULL);
7679         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uint64_t)ret_event);
7680         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7681                 (*env)->ExceptionDescribe(env);
7682                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
7683         }
7684         if (get_jenv_res == JNI_EDETACHED) {
7685                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7686         }
7687 }
7688 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7689         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7690         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7691 }
7692 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
7693         jclass c = (*env)->GetObjectClass(env, o);
7694         CHECK(c != NULL);
7695         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7696         atomic_init(&calls->refcnt, 1);
7697         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7698         calls->o = (*env)->NewWeakGlobalRef(env, o);
7699         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
7700         CHECK(calls->handle_event_meth != NULL);
7701
7702         LDKEventHandler ret = {
7703                 .this_arg = (void*) calls,
7704                 .handle_event = handle_event_LDKEventHandler_jcall,
7705                 .free = LDKEventHandler_JCalls_free,
7706         };
7707         return ret;
7708 }
7709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
7710         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7711         *res_ptr = LDKEventHandler_init(env, clz, o);
7712         return (uint64_t)res_ptr;
7713 }
7714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
7715         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7716         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7717         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
7718         LDKEvent* event_conv = (LDKEvent*)event;
7719         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
7720 }
7721
7722 typedef struct LDKEventsProvider_JCalls {
7723         atomic_size_t refcnt;
7724         JavaVM *vm;
7725         jweak o;
7726         jmethodID process_pending_events_meth;
7727 } LDKEventsProvider_JCalls;
7728 static void LDKEventsProvider_JCalls_free(void* this_arg) {
7729         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7730         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7731                 JNIEnv *env;
7732                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7733                 if (get_jenv_res == JNI_EDETACHED) {
7734                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7735                 } else {
7736                         DO_ASSERT(get_jenv_res == JNI_OK);
7737                 }
7738                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7739                 if (get_jenv_res == JNI_EDETACHED) {
7740                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7741                 }
7742                 FREE(j_calls);
7743         }
7744 }
7745 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
7746         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7747         JNIEnv *env;
7748         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7749         if (get_jenv_res == JNI_EDETACHED) {
7750                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7751         } else {
7752                 DO_ASSERT(get_jenv_res == JNI_OK);
7753         }
7754         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7755         *handler_ret = handler;
7756         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7757         CHECK(obj != NULL);
7758         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)handler_ret);
7759         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7760                 (*env)->ExceptionDescribe(env);
7761                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
7762         }
7763         if (get_jenv_res == JNI_EDETACHED) {
7764                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7765         }
7766 }
7767 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
7768         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
7769         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7770 }
7771 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7772         jclass c = (*env)->GetObjectClass(env, o);
7773         CHECK(c != NULL);
7774         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
7775         atomic_init(&calls->refcnt, 1);
7776         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7777         calls->o = (*env)->NewWeakGlobalRef(env, o);
7778         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
7779         CHECK(calls->process_pending_events_meth != NULL);
7780
7781         LDKEventsProvider ret = {
7782                 .this_arg = (void*) calls,
7783                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
7784                 .free = LDKEventsProvider_JCalls_free,
7785         };
7786         return ret;
7787 }
7788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7789         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7790         *res_ptr = LDKEventsProvider_init(env, clz, o);
7791         return (uint64_t)res_ptr;
7792 }
7793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
7794         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7795         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7796         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
7797         void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
7798         CHECK_ACCESS(handler_ptr);
7799         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
7800         if (handler_conv.free == LDKEventHandler_JCalls_free) {
7801                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7802                 LDKEventHandler_JCalls_cloned(&handler_conv);
7803         }
7804         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
7805 }
7806
7807 typedef struct LDKListen_JCalls {
7808         atomic_size_t refcnt;
7809         JavaVM *vm;
7810         jweak o;
7811         jmethodID block_connected_meth;
7812         jmethodID block_disconnected_meth;
7813 } LDKListen_JCalls;
7814 static void LDKListen_JCalls_free(void* this_arg) {
7815         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7816         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7817                 JNIEnv *env;
7818                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7819                 if (get_jenv_res == JNI_EDETACHED) {
7820                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7821                 } else {
7822                         DO_ASSERT(get_jenv_res == JNI_OK);
7823                 }
7824                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7825                 if (get_jenv_res == JNI_EDETACHED) {
7826                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7827                 }
7828                 FREE(j_calls);
7829         }
7830 }
7831 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
7832         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7833         JNIEnv *env;
7834         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7835         if (get_jenv_res == JNI_EDETACHED) {
7836                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7837         } else {
7838                 DO_ASSERT(get_jenv_res == JNI_OK);
7839         }
7840         LDKu8slice block_var = block;
7841         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
7842         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
7843         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7844         CHECK(obj != NULL);
7845         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
7846         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7847                 (*env)->ExceptionDescribe(env);
7848                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
7849         }
7850         if (get_jenv_res == JNI_EDETACHED) {
7851                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7852         }
7853 }
7854 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7855         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7856         JNIEnv *env;
7857         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7858         if (get_jenv_res == JNI_EDETACHED) {
7859                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7860         } else {
7861                 DO_ASSERT(get_jenv_res == JNI_OK);
7862         }
7863         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7864         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7865         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7866         CHECK(obj != NULL);
7867         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
7868         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7869                 (*env)->ExceptionDescribe(env);
7870                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
7871         }
7872         if (get_jenv_res == JNI_EDETACHED) {
7873                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7874         }
7875 }
7876 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
7877         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
7878         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7879 }
7880 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
7881         jclass c = (*env)->GetObjectClass(env, o);
7882         CHECK(c != NULL);
7883         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
7884         atomic_init(&calls->refcnt, 1);
7885         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7886         calls->o = (*env)->NewWeakGlobalRef(env, o);
7887         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
7888         CHECK(calls->block_connected_meth != NULL);
7889         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
7890         CHECK(calls->block_disconnected_meth != NULL);
7891
7892         LDKListen ret = {
7893                 .this_arg = (void*) calls,
7894                 .block_connected = block_connected_LDKListen_jcall,
7895                 .block_disconnected = block_disconnected_LDKListen_jcall,
7896                 .free = LDKListen_JCalls_free,
7897         };
7898         return ret;
7899 }
7900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
7901         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
7902         *res_ptr = LDKListen_init(env, clz, o);
7903         return (uint64_t)res_ptr;
7904 }
7905 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) {
7906         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7907         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7908         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7909         LDKu8slice block_ref;
7910         block_ref.datalen = (*env)->GetArrayLength(env, block);
7911         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
7912         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
7913         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
7914 }
7915
7916 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) {
7917         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7918         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7919         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7920         unsigned char header_arr[80];
7921         CHECK((*env)->GetArrayLength(env, header) == 80);
7922         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7923         unsigned char (*header_ref)[80] = &header_arr;
7924         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
7925 }
7926
7927 typedef struct LDKConfirm_JCalls {
7928         atomic_size_t refcnt;
7929         JavaVM *vm;
7930         jweak o;
7931         jmethodID transactions_confirmed_meth;
7932         jmethodID transaction_unconfirmed_meth;
7933         jmethodID best_block_updated_meth;
7934         jmethodID get_relevant_txids_meth;
7935 } LDKConfirm_JCalls;
7936 static void LDKConfirm_JCalls_free(void* this_arg) {
7937         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7938         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7939                 JNIEnv *env;
7940                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7941                 if (get_jenv_res == JNI_EDETACHED) {
7942                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7943                 } else {
7944                         DO_ASSERT(get_jenv_res == JNI_OK);
7945                 }
7946                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7947                 if (get_jenv_res == JNI_EDETACHED) {
7948                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7949                 }
7950                 FREE(j_calls);
7951         }
7952 }
7953 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
7954         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7955         JNIEnv *env;
7956         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7957         if (get_jenv_res == JNI_EDETACHED) {
7958                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7959         } else {
7960                 DO_ASSERT(get_jenv_res == JNI_OK);
7961         }
7962         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7963         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7964         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
7965         int64_tArray txdata_arr = NULL;
7966         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
7967         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
7968         for (size_t c = 0; c < txdata_var.datalen; c++) {
7969                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7970                 *txdata_conv_28_conv = txdata_var.data[c];
7971                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
7972         }
7973         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
7974         FREE(txdata_var.data);
7975         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7976         CHECK(obj != NULL);
7977         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
7978         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7979                 (*env)->ExceptionDescribe(env);
7980                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
7981         }
7982         if (get_jenv_res == JNI_EDETACHED) {
7983                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7984         }
7985 }
7986 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
7987         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7988         JNIEnv *env;
7989         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7990         if (get_jenv_res == JNI_EDETACHED) {
7991                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7992         } else {
7993                 DO_ASSERT(get_jenv_res == JNI_OK);
7994         }
7995         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7996         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7997         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7998         CHECK(obj != NULL);
7999         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
8000         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8001                 (*env)->ExceptionDescribe(env);
8002                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
8003         }
8004         if (get_jenv_res == JNI_EDETACHED) {
8005                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8006         }
8007 }
8008 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8009         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8010         JNIEnv *env;
8011         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8012         if (get_jenv_res == JNI_EDETACHED) {
8013                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8014         } else {
8015                 DO_ASSERT(get_jenv_res == JNI_OK);
8016         }
8017         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
8018         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
8019         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8020         CHECK(obj != NULL);
8021         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
8022         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8023                 (*env)->ExceptionDescribe(env);
8024                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
8025         }
8026         if (get_jenv_res == JNI_EDETACHED) {
8027                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8028         }
8029 }
8030 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8031         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8032         JNIEnv *env;
8033         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8034         if (get_jenv_res == JNI_EDETACHED) {
8035                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8036         } else {
8037                 DO_ASSERT(get_jenv_res == JNI_OK);
8038         }
8039         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8040         CHECK(obj != NULL);
8041         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
8042         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8043                 (*env)->ExceptionDescribe(env);
8044                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
8045         }
8046         LDKCVec_TxidZ ret_constr;
8047         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8048         if (ret_constr.datalen > 0)
8049                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8050         else
8051                 ret_constr.data = NULL;
8052         for (size_t i = 0; i < ret_constr.datalen; i++) {
8053                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
8054                 LDKThirtyTwoBytes ret_conv_8_ref;
8055                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
8056                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
8057                 ret_constr.data[i] = ret_conv_8_ref;
8058         }
8059         if (get_jenv_res == JNI_EDETACHED) {
8060                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8061         }
8062         return ret_constr;
8063 }
8064 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8065         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8066         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8067 }
8068 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
8069         jclass c = (*env)->GetObjectClass(env, o);
8070         CHECK(c != NULL);
8071         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8072         atomic_init(&calls->refcnt, 1);
8073         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8074         calls->o = (*env)->NewWeakGlobalRef(env, o);
8075         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
8076         CHECK(calls->transactions_confirmed_meth != NULL);
8077         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
8078         CHECK(calls->transaction_unconfirmed_meth != NULL);
8079         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
8080         CHECK(calls->best_block_updated_meth != NULL);
8081         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
8082         CHECK(calls->get_relevant_txids_meth != NULL);
8083
8084         LDKConfirm ret = {
8085                 .this_arg = (void*) calls,
8086                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8087                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8088                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8089                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8090                 .free = LDKConfirm_JCalls_free,
8091         };
8092         return ret;
8093 }
8094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
8095         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8096         *res_ptr = LDKConfirm_init(env, clz, o);
8097         return (uint64_t)res_ptr;
8098 }
8099 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) {
8100         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8101         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8102         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8103         unsigned char header_arr[80];
8104         CHECK((*env)->GetArrayLength(env, header) == 80);
8105         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
8106         unsigned char (*header_ref)[80] = &header_arr;
8107         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8108         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
8109         if (txdata_constr.datalen > 0)
8110                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8111         else
8112                 txdata_constr.data = NULL;
8113         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
8114         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8115                 int64_t txdata_conv_28 = txdata_vals[c];
8116                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
8117                 CHECK_ACCESS(txdata_conv_28_ptr);
8118                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8119                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
8120                 txdata_constr.data[c] = txdata_conv_28_conv;
8121         }
8122         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
8123         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8124 }
8125
8126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
8127         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8128         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8129         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8130         unsigned char txid_arr[32];
8131         CHECK((*env)->GetArrayLength(env, txid) == 32);
8132         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
8133         unsigned char (*txid_ref)[32] = &txid_arr;
8134         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8135 }
8136
8137 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) {
8138         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8139         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8140         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8141         unsigned char header_arr[80];
8142         CHECK((*env)->GetArrayLength(env, header) == 80);
8143         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
8144         unsigned char (*header_ref)[80] = &header_arr;
8145         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8146 }
8147
8148 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
8149         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8150         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8151         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8152         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8153         jobjectArray ret_arr = NULL;
8154         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
8155         ;
8156         for (size_t i = 0; i < ret_var.datalen; i++) {
8157                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
8158                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
8159                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
8160         }
8161         
8162         FREE(ret_var.data);
8163         return ret_arr;
8164 }
8165
8166 typedef struct LDKPersist_JCalls {
8167         atomic_size_t refcnt;
8168         JavaVM *vm;
8169         jweak o;
8170         jmethodID persist_new_channel_meth;
8171         jmethodID update_persisted_channel_meth;
8172 } LDKPersist_JCalls;
8173 static void LDKPersist_JCalls_free(void* this_arg) {
8174         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8175         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8176                 JNIEnv *env;
8177                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8178                 if (get_jenv_res == JNI_EDETACHED) {
8179                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8180                 } else {
8181                         DO_ASSERT(get_jenv_res == JNI_OK);
8182                 }
8183                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8184                 if (get_jenv_res == JNI_EDETACHED) {
8185                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8186                 }
8187                 FREE(j_calls);
8188         }
8189 }
8190 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8191         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8192         JNIEnv *env;
8193         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8194         if (get_jenv_res == JNI_EDETACHED) {
8195                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8196         } else {
8197                 DO_ASSERT(get_jenv_res == JNI_OK);
8198         }
8199         LDKOutPoint channel_id_var = channel_id;
8200         uint64_t channel_id_ref = 0;
8201         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8202         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8203         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8204         channel_id_ref = (uint64_t)channel_id_var.inner;
8205         if (channel_id_var.is_owned) {
8206                 channel_id_ref |= 1;
8207         }
8208         LDKChannelMonitor data_var = *data;
8209         uint64_t data_ref = 0;
8210         data_var = ChannelMonitor_clone(data);
8211         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8212         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8213         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8214         data_ref = (uint64_t)data_var.inner;
8215         if (data_var.is_owned) {
8216                 data_ref |= 1;
8217         }
8218         LDKMonitorUpdateId update_id_var = update_id;
8219         uint64_t update_id_ref = 0;
8220         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8221         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8222         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8223         update_id_ref = (uint64_t)update_id_var.inner;
8224         if (update_id_var.is_owned) {
8225                 update_id_ref |= 1;
8226         }
8227         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8228         CHECK(obj != NULL);
8229         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
8230         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8231                 (*env)->ExceptionDescribe(env);
8232                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
8233         }
8234         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8235         CHECK_ACCESS(ret_ptr);
8236         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8237         FREE((void*)ret);
8238         if (get_jenv_res == JNI_EDETACHED) {
8239                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8240         }
8241         return ret_conv;
8242 }
8243 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8244         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8245         JNIEnv *env;
8246         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8247         if (get_jenv_res == JNI_EDETACHED) {
8248                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8249         } else {
8250                 DO_ASSERT(get_jenv_res == JNI_OK);
8251         }
8252         LDKOutPoint channel_id_var = channel_id;
8253         uint64_t channel_id_ref = 0;
8254         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8255         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8256         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8257         channel_id_ref = (uint64_t)channel_id_var.inner;
8258         if (channel_id_var.is_owned) {
8259                 channel_id_ref |= 1;
8260         }
8261         LDKChannelMonitorUpdate update_var = *update;
8262         uint64_t update_ref = 0;
8263         if ((uint64_t)update_var.inner > 4096) {
8264                 update_var = ChannelMonitorUpdate_clone(update);
8265                 CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8266                 CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8267         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8268                 update_ref = (uint64_t)update_var.inner;
8269                 if (update_var.is_owned) {
8270                         update_ref |= 1;
8271                 }
8272         }
8273         LDKChannelMonitor data_var = *data;
8274         uint64_t data_ref = 0;
8275         data_var = ChannelMonitor_clone(data);
8276         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8277         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8278         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8279         data_ref = (uint64_t)data_var.inner;
8280         if (data_var.is_owned) {
8281                 data_ref |= 1;
8282         }
8283         LDKMonitorUpdateId update_id_var = update_id;
8284         uint64_t update_id_ref = 0;
8285         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8286         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8287         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8288         update_id_ref = (uint64_t)update_id_var.inner;
8289         if (update_id_var.is_owned) {
8290                 update_id_ref |= 1;
8291         }
8292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8293         CHECK(obj != NULL);
8294         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
8295         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8296                 (*env)->ExceptionDescribe(env);
8297                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
8298         }
8299         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8300         CHECK_ACCESS(ret_ptr);
8301         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8302         FREE((void*)ret);
8303         if (get_jenv_res == JNI_EDETACHED) {
8304                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8305         }
8306         return ret_conv;
8307 }
8308 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8309         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8310         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8311 }
8312 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
8313         jclass c = (*env)->GetObjectClass(env, o);
8314         CHECK(c != NULL);
8315         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8316         atomic_init(&calls->refcnt, 1);
8317         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8318         calls->o = (*env)->NewWeakGlobalRef(env, o);
8319         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
8320         CHECK(calls->persist_new_channel_meth != NULL);
8321         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
8322         CHECK(calls->update_persisted_channel_meth != NULL);
8323
8324         LDKPersist ret = {
8325                 .this_arg = (void*) calls,
8326                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8327                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8328                 .free = LDKPersist_JCalls_free,
8329         };
8330         return ret;
8331 }
8332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
8333         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8334         *res_ptr = LDKPersist_init(env, clz, o);
8335         return (uint64_t)res_ptr;
8336 }
8337 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) {
8338         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8339         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8340         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8341         LDKOutPoint channel_id_conv;
8342         channel_id_conv.inner = (void*)(channel_id & (~1));
8343         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8344         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8345         channel_id_conv = OutPoint_clone(&channel_id_conv);
8346         LDKChannelMonitor data_conv;
8347         data_conv.inner = (void*)(data & (~1));
8348         data_conv.is_owned = false;
8349         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8350         LDKMonitorUpdateId update_id_conv;
8351         update_id_conv.inner = (void*)(update_id & (~1));
8352         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8353         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8354         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8355         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8356         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8357         return (uint64_t)ret_conv;
8358 }
8359
8360 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) {
8361         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8362         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8363         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8364         LDKOutPoint channel_id_conv;
8365         channel_id_conv.inner = (void*)(channel_id & (~1));
8366         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8367         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8368         channel_id_conv = OutPoint_clone(&channel_id_conv);
8369         LDKChannelMonitorUpdate update_conv;
8370         update_conv.inner = (void*)(update & (~1));
8371         update_conv.is_owned = false;
8372         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8373         LDKChannelMonitor data_conv;
8374         data_conv.inner = (void*)(data & (~1));
8375         data_conv.is_owned = false;
8376         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8377         LDKMonitorUpdateId update_id_conv;
8378         update_id_conv.inner = (void*)(update_id & (~1));
8379         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8380         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8381         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8382         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8383         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8384         return (uint64_t)ret_conv;
8385 }
8386
8387 typedef struct LDKChannelMessageHandler_JCalls {
8388         atomic_size_t refcnt;
8389         JavaVM *vm;
8390         jweak o;
8391         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8392         jmethodID handle_open_channel_meth;
8393         jmethodID handle_accept_channel_meth;
8394         jmethodID handle_funding_created_meth;
8395         jmethodID handle_funding_signed_meth;
8396         jmethodID handle_funding_locked_meth;
8397         jmethodID handle_shutdown_meth;
8398         jmethodID handle_closing_signed_meth;
8399         jmethodID handle_update_add_htlc_meth;
8400         jmethodID handle_update_fulfill_htlc_meth;
8401         jmethodID handle_update_fail_htlc_meth;
8402         jmethodID handle_update_fail_malformed_htlc_meth;
8403         jmethodID handle_commitment_signed_meth;
8404         jmethodID handle_revoke_and_ack_meth;
8405         jmethodID handle_update_fee_meth;
8406         jmethodID handle_announcement_signatures_meth;
8407         jmethodID peer_disconnected_meth;
8408         jmethodID peer_connected_meth;
8409         jmethodID handle_channel_reestablish_meth;
8410         jmethodID handle_channel_update_meth;
8411         jmethodID handle_error_meth;
8412 } LDKChannelMessageHandler_JCalls;
8413 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8414         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8415         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8416                 JNIEnv *env;
8417                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8418                 if (get_jenv_res == JNI_EDETACHED) {
8419                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8420                 } else {
8421                         DO_ASSERT(get_jenv_res == JNI_OK);
8422                 }
8423                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8424                 if (get_jenv_res == JNI_EDETACHED) {
8425                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8426                 }
8427                 FREE(j_calls);
8428         }
8429 }
8430 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8431         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8432         JNIEnv *env;
8433         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8434         if (get_jenv_res == JNI_EDETACHED) {
8435                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8436         } else {
8437                 DO_ASSERT(get_jenv_res == JNI_OK);
8438         }
8439         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8440         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8441         LDKInitFeatures their_features_var = their_features;
8442         uint64_t their_features_ref = 0;
8443         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8444         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8445         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8446         their_features_ref = (uint64_t)their_features_var.inner;
8447         if (their_features_var.is_owned) {
8448                 their_features_ref |= 1;
8449         }
8450         LDKOpenChannel msg_var = *msg;
8451         uint64_t msg_ref = 0;
8452         msg_var = OpenChannel_clone(msg);
8453         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8454         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8455         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8456         msg_ref = (uint64_t)msg_var.inner;
8457         if (msg_var.is_owned) {
8458                 msg_ref |= 1;
8459         }
8460         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8461         CHECK(obj != NULL);
8462         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8463         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8464                 (*env)->ExceptionDescribe(env);
8465                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
8466         }
8467         if (get_jenv_res == JNI_EDETACHED) {
8468                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8469         }
8470 }
8471 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8472         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8473         JNIEnv *env;
8474         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8475         if (get_jenv_res == JNI_EDETACHED) {
8476                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8477         } else {
8478                 DO_ASSERT(get_jenv_res == JNI_OK);
8479         }
8480         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8481         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8482         LDKInitFeatures their_features_var = their_features;
8483         uint64_t their_features_ref = 0;
8484         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8485         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8486         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8487         their_features_ref = (uint64_t)their_features_var.inner;
8488         if (their_features_var.is_owned) {
8489                 their_features_ref |= 1;
8490         }
8491         LDKAcceptChannel msg_var = *msg;
8492         uint64_t msg_ref = 0;
8493         msg_var = AcceptChannel_clone(msg);
8494         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8495         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8496         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8497         msg_ref = (uint64_t)msg_var.inner;
8498         if (msg_var.is_owned) {
8499                 msg_ref |= 1;
8500         }
8501         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8502         CHECK(obj != NULL);
8503         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8504         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8505                 (*env)->ExceptionDescribe(env);
8506                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
8507         }
8508         if (get_jenv_res == JNI_EDETACHED) {
8509                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8510         }
8511 }
8512 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8513         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8514         JNIEnv *env;
8515         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8516         if (get_jenv_res == JNI_EDETACHED) {
8517                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8518         } else {
8519                 DO_ASSERT(get_jenv_res == JNI_OK);
8520         }
8521         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8522         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8523         LDKFundingCreated msg_var = *msg;
8524         uint64_t msg_ref = 0;
8525         msg_var = FundingCreated_clone(msg);
8526         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8527         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8528         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8529         msg_ref = (uint64_t)msg_var.inner;
8530         if (msg_var.is_owned) {
8531                 msg_ref |= 1;
8532         }
8533         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8534         CHECK(obj != NULL);
8535         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
8536         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8537                 (*env)->ExceptionDescribe(env);
8538                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
8539         }
8540         if (get_jenv_res == JNI_EDETACHED) {
8541                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8542         }
8543 }
8544 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8545         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8546         JNIEnv *env;
8547         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8548         if (get_jenv_res == JNI_EDETACHED) {
8549                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8550         } else {
8551                 DO_ASSERT(get_jenv_res == JNI_OK);
8552         }
8553         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8554         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8555         LDKFundingSigned msg_var = *msg;
8556         uint64_t msg_ref = 0;
8557         msg_var = FundingSigned_clone(msg);
8558         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8559         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8560         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8561         msg_ref = (uint64_t)msg_var.inner;
8562         if (msg_var.is_owned) {
8563                 msg_ref |= 1;
8564         }
8565         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8566         CHECK(obj != NULL);
8567         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
8568         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8569                 (*env)->ExceptionDescribe(env);
8570                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
8571         }
8572         if (get_jenv_res == JNI_EDETACHED) {
8573                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8574         }
8575 }
8576 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8577         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8578         JNIEnv *env;
8579         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8580         if (get_jenv_res == JNI_EDETACHED) {
8581                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8582         } else {
8583                 DO_ASSERT(get_jenv_res == JNI_OK);
8584         }
8585         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8586         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8587         LDKFundingLocked msg_var = *msg;
8588         uint64_t msg_ref = 0;
8589         msg_var = FundingLocked_clone(msg);
8590         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8591         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8592         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8593         msg_ref = (uint64_t)msg_var.inner;
8594         if (msg_var.is_owned) {
8595                 msg_ref |= 1;
8596         }
8597         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8598         CHECK(obj != NULL);
8599         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
8600         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8601                 (*env)->ExceptionDescribe(env);
8602                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
8603         }
8604         if (get_jenv_res == JNI_EDETACHED) {
8605                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8606         }
8607 }
8608 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8609         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8610         JNIEnv *env;
8611         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8612         if (get_jenv_res == JNI_EDETACHED) {
8613                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8614         } else {
8615                 DO_ASSERT(get_jenv_res == JNI_OK);
8616         }
8617         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8618         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8619         LDKInitFeatures their_features_var = *their_features;
8620         uint64_t their_features_ref = 0;
8621         their_features_var = InitFeatures_clone(their_features);
8622         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8623         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8624         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8625         their_features_ref = (uint64_t)their_features_var.inner;
8626         if (their_features_var.is_owned) {
8627                 their_features_ref |= 1;
8628         }
8629         LDKShutdown msg_var = *msg;
8630         uint64_t msg_ref = 0;
8631         msg_var = Shutdown_clone(msg);
8632         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8633         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8634         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8635         msg_ref = (uint64_t)msg_var.inner;
8636         if (msg_var.is_owned) {
8637                 msg_ref |= 1;
8638         }
8639         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8640         CHECK(obj != NULL);
8641         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
8642         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8643                 (*env)->ExceptionDescribe(env);
8644                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
8645         }
8646         if (get_jenv_res == JNI_EDETACHED) {
8647                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8648         }
8649 }
8650 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8651         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8652         JNIEnv *env;
8653         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8654         if (get_jenv_res == JNI_EDETACHED) {
8655                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8656         } else {
8657                 DO_ASSERT(get_jenv_res == JNI_OK);
8658         }
8659         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8660         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8661         LDKClosingSigned msg_var = *msg;
8662         uint64_t msg_ref = 0;
8663         msg_var = ClosingSigned_clone(msg);
8664         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8665         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8666         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8667         msg_ref = (uint64_t)msg_var.inner;
8668         if (msg_var.is_owned) {
8669                 msg_ref |= 1;
8670         }
8671         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8672         CHECK(obj != NULL);
8673         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
8674         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8675                 (*env)->ExceptionDescribe(env);
8676                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
8677         }
8678         if (get_jenv_res == JNI_EDETACHED) {
8679                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8680         }
8681 }
8682 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8683         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8684         JNIEnv *env;
8685         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8686         if (get_jenv_res == JNI_EDETACHED) {
8687                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8688         } else {
8689                 DO_ASSERT(get_jenv_res == JNI_OK);
8690         }
8691         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8692         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8693         LDKUpdateAddHTLC msg_var = *msg;
8694         uint64_t msg_ref = 0;
8695         msg_var = UpdateAddHTLC_clone(msg);
8696         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8697         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8698         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8699         msg_ref = (uint64_t)msg_var.inner;
8700         if (msg_var.is_owned) {
8701                 msg_ref |= 1;
8702         }
8703         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8704         CHECK(obj != NULL);
8705         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
8706         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8707                 (*env)->ExceptionDescribe(env);
8708                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
8709         }
8710         if (get_jenv_res == JNI_EDETACHED) {
8711                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8712         }
8713 }
8714 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8715         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8716         JNIEnv *env;
8717         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8718         if (get_jenv_res == JNI_EDETACHED) {
8719                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8720         } else {
8721                 DO_ASSERT(get_jenv_res == JNI_OK);
8722         }
8723         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8724         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8725         LDKUpdateFulfillHTLC msg_var = *msg;
8726         uint64_t msg_ref = 0;
8727         msg_var = UpdateFulfillHTLC_clone(msg);
8728         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8729         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8730         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8731         msg_ref = (uint64_t)msg_var.inner;
8732         if (msg_var.is_owned) {
8733                 msg_ref |= 1;
8734         }
8735         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8736         CHECK(obj != NULL);
8737         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
8738         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8739                 (*env)->ExceptionDescribe(env);
8740                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
8741         }
8742         if (get_jenv_res == JNI_EDETACHED) {
8743                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8744         }
8745 }
8746 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8747         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8748         JNIEnv *env;
8749         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8750         if (get_jenv_res == JNI_EDETACHED) {
8751                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8752         } else {
8753                 DO_ASSERT(get_jenv_res == JNI_OK);
8754         }
8755         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8756         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8757         LDKUpdateFailHTLC msg_var = *msg;
8758         uint64_t msg_ref = 0;
8759         msg_var = UpdateFailHTLC_clone(msg);
8760         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8761         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8762         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8763         msg_ref = (uint64_t)msg_var.inner;
8764         if (msg_var.is_owned) {
8765                 msg_ref |= 1;
8766         }
8767         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8768         CHECK(obj != NULL);
8769         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
8770         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8771                 (*env)->ExceptionDescribe(env);
8772                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
8773         }
8774         if (get_jenv_res == JNI_EDETACHED) {
8775                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8776         }
8777 }
8778 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8779         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8780         JNIEnv *env;
8781         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8782         if (get_jenv_res == JNI_EDETACHED) {
8783                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8784         } else {
8785                 DO_ASSERT(get_jenv_res == JNI_OK);
8786         }
8787         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8788         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8789         LDKUpdateFailMalformedHTLC msg_var = *msg;
8790         uint64_t msg_ref = 0;
8791         msg_var = UpdateFailMalformedHTLC_clone(msg);
8792         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8793         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8794         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8795         msg_ref = (uint64_t)msg_var.inner;
8796         if (msg_var.is_owned) {
8797                 msg_ref |= 1;
8798         }
8799         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8800         CHECK(obj != NULL);
8801         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
8802         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8803                 (*env)->ExceptionDescribe(env);
8804                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
8805         }
8806         if (get_jenv_res == JNI_EDETACHED) {
8807                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8808         }
8809 }
8810 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8811         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8812         JNIEnv *env;
8813         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8814         if (get_jenv_res == JNI_EDETACHED) {
8815                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8816         } else {
8817                 DO_ASSERT(get_jenv_res == JNI_OK);
8818         }
8819         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8820         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8821         LDKCommitmentSigned msg_var = *msg;
8822         uint64_t msg_ref = 0;
8823         msg_var = CommitmentSigned_clone(msg);
8824         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8825         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8826         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8827         msg_ref = (uint64_t)msg_var.inner;
8828         if (msg_var.is_owned) {
8829                 msg_ref |= 1;
8830         }
8831         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8832         CHECK(obj != NULL);
8833         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
8834         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8835                 (*env)->ExceptionDescribe(env);
8836                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
8837         }
8838         if (get_jenv_res == JNI_EDETACHED) {
8839                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8840         }
8841 }
8842 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8843         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8844         JNIEnv *env;
8845         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8846         if (get_jenv_res == JNI_EDETACHED) {
8847                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8848         } else {
8849                 DO_ASSERT(get_jenv_res == JNI_OK);
8850         }
8851         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8852         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8853         LDKRevokeAndACK msg_var = *msg;
8854         uint64_t msg_ref = 0;
8855         msg_var = RevokeAndACK_clone(msg);
8856         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8857         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8858         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8859         msg_ref = (uint64_t)msg_var.inner;
8860         if (msg_var.is_owned) {
8861                 msg_ref |= 1;
8862         }
8863         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8864         CHECK(obj != NULL);
8865         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
8866         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8867                 (*env)->ExceptionDescribe(env);
8868                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
8869         }
8870         if (get_jenv_res == JNI_EDETACHED) {
8871                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8872         }
8873 }
8874 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8875         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8876         JNIEnv *env;
8877         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8878         if (get_jenv_res == JNI_EDETACHED) {
8879                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8880         } else {
8881                 DO_ASSERT(get_jenv_res == JNI_OK);
8882         }
8883         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8884         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8885         LDKUpdateFee msg_var = *msg;
8886         uint64_t msg_ref = 0;
8887         msg_var = UpdateFee_clone(msg);
8888         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8889         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8890         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8891         msg_ref = (uint64_t)msg_var.inner;
8892         if (msg_var.is_owned) {
8893                 msg_ref |= 1;
8894         }
8895         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8896         CHECK(obj != NULL);
8897         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
8898         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8899                 (*env)->ExceptionDescribe(env);
8900                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
8901         }
8902         if (get_jenv_res == JNI_EDETACHED) {
8903                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8904         }
8905 }
8906 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8907         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8908         JNIEnv *env;
8909         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8910         if (get_jenv_res == JNI_EDETACHED) {
8911                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8912         } else {
8913                 DO_ASSERT(get_jenv_res == JNI_OK);
8914         }
8915         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8916         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8917         LDKAnnouncementSignatures msg_var = *msg;
8918         uint64_t msg_ref = 0;
8919         msg_var = AnnouncementSignatures_clone(msg);
8920         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8921         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8922         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8923         msg_ref = (uint64_t)msg_var.inner;
8924         if (msg_var.is_owned) {
8925                 msg_ref |= 1;
8926         }
8927         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8928         CHECK(obj != NULL);
8929         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
8930         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8931                 (*env)->ExceptionDescribe(env);
8932                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
8933         }
8934         if (get_jenv_res == JNI_EDETACHED) {
8935                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8936         }
8937 }
8938 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8939         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8940         JNIEnv *env;
8941         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8942         if (get_jenv_res == JNI_EDETACHED) {
8943                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8944         } else {
8945                 DO_ASSERT(get_jenv_res == JNI_OK);
8946         }
8947         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8948         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8949         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8950         CHECK(obj != NULL);
8951         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
8952         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8953                 (*env)->ExceptionDescribe(env);
8954                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
8955         }
8956         if (get_jenv_res == JNI_EDETACHED) {
8957                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8958         }
8959 }
8960 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8961         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8962         JNIEnv *env;
8963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8964         if (get_jenv_res == JNI_EDETACHED) {
8965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8966         } else {
8967                 DO_ASSERT(get_jenv_res == JNI_OK);
8968         }
8969         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8970         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8971         LDKInit msg_var = *msg;
8972         uint64_t msg_ref = 0;
8973         msg_var = Init_clone(msg);
8974         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8975         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8976         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8977         msg_ref = (uint64_t)msg_var.inner;
8978         if (msg_var.is_owned) {
8979                 msg_ref |= 1;
8980         }
8981         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8982         CHECK(obj != NULL);
8983         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
8984         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8985                 (*env)->ExceptionDescribe(env);
8986                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
8987         }
8988         if (get_jenv_res == JNI_EDETACHED) {
8989                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8990         }
8991 }
8992 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8993         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8994         JNIEnv *env;
8995         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8996         if (get_jenv_res == JNI_EDETACHED) {
8997                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8998         } else {
8999                 DO_ASSERT(get_jenv_res == JNI_OK);
9000         }
9001         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9002         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9003         LDKChannelReestablish msg_var = *msg;
9004         uint64_t msg_ref = 0;
9005         msg_var = ChannelReestablish_clone(msg);
9006         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9007         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9008         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9009         msg_ref = (uint64_t)msg_var.inner;
9010         if (msg_var.is_owned) {
9011                 msg_ref |= 1;
9012         }
9013         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9014         CHECK(obj != NULL);
9015         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
9016         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9017                 (*env)->ExceptionDescribe(env);
9018                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
9019         }
9020         if (get_jenv_res == JNI_EDETACHED) {
9021                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9022         }
9023 }
9024 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
9025         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9026         JNIEnv *env;
9027         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9028         if (get_jenv_res == JNI_EDETACHED) {
9029                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9030         } else {
9031                 DO_ASSERT(get_jenv_res == JNI_OK);
9032         }
9033         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9034         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9035         LDKChannelUpdate msg_var = *msg;
9036         uint64_t msg_ref = 0;
9037         msg_var = ChannelUpdate_clone(msg);
9038         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9039         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9040         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9041         msg_ref = (uint64_t)msg_var.inner;
9042         if (msg_var.is_owned) {
9043                 msg_ref |= 1;
9044         }
9045         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9046         CHECK(obj != NULL);
9047         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
9048         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9049                 (*env)->ExceptionDescribe(env);
9050                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
9051         }
9052         if (get_jenv_res == JNI_EDETACHED) {
9053                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9054         }
9055 }
9056 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
9057         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9058         JNIEnv *env;
9059         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9060         if (get_jenv_res == JNI_EDETACHED) {
9061                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9062         } else {
9063                 DO_ASSERT(get_jenv_res == JNI_OK);
9064         }
9065         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9066         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9067         LDKErrorMessage msg_var = *msg;
9068         uint64_t msg_ref = 0;
9069         msg_var = ErrorMessage_clone(msg);
9070         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9071         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9072         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9073         msg_ref = (uint64_t)msg_var.inner;
9074         if (msg_var.is_owned) {
9075                 msg_ref |= 1;
9076         }
9077         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9078         CHECK(obj != NULL);
9079         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
9080         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9081                 (*env)->ExceptionDescribe(env);
9082                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
9083         }
9084         if (get_jenv_res == JNI_EDETACHED) {
9085                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9086         }
9087 }
9088 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
9089         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
9090         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9091         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9092 }
9093 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9094         jclass c = (*env)->GetObjectClass(env, o);
9095         CHECK(c != NULL);
9096         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
9097         atomic_init(&calls->refcnt, 1);
9098         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9099         calls->o = (*env)->NewWeakGlobalRef(env, o);
9100         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
9101         CHECK(calls->handle_open_channel_meth != NULL);
9102         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
9103         CHECK(calls->handle_accept_channel_meth != NULL);
9104         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
9105         CHECK(calls->handle_funding_created_meth != NULL);
9106         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
9107         CHECK(calls->handle_funding_signed_meth != NULL);
9108         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
9109         CHECK(calls->handle_funding_locked_meth != NULL);
9110         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
9111         CHECK(calls->handle_shutdown_meth != NULL);
9112         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
9113         CHECK(calls->handle_closing_signed_meth != NULL);
9114         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
9115         CHECK(calls->handle_update_add_htlc_meth != NULL);
9116         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
9117         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
9118         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
9119         CHECK(calls->handle_update_fail_htlc_meth != NULL);
9120         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
9121         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
9122         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
9123         CHECK(calls->handle_commitment_signed_meth != NULL);
9124         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
9125         CHECK(calls->handle_revoke_and_ack_meth != NULL);
9126         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
9127         CHECK(calls->handle_update_fee_meth != NULL);
9128         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
9129         CHECK(calls->handle_announcement_signatures_meth != NULL);
9130         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
9131         CHECK(calls->peer_disconnected_meth != NULL);
9132         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
9133         CHECK(calls->peer_connected_meth != NULL);
9134         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
9135         CHECK(calls->handle_channel_reestablish_meth != NULL);
9136         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
9137         CHECK(calls->handle_channel_update_meth != NULL);
9138         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
9139         CHECK(calls->handle_error_meth != NULL);
9140
9141         LDKChannelMessageHandler ret = {
9142                 .this_arg = (void*) calls,
9143                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
9144                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
9145                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
9146                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
9147                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
9148                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
9149                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
9150                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
9151                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
9152                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
9153                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
9154                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
9155                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
9156                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
9157                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
9158                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
9159                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
9160                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
9161                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
9162                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
9163                 .free = LDKChannelMessageHandler_JCalls_free,
9164                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
9165         };
9166         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9167         return ret;
9168 }
9169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9170         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
9171         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
9172         return (uint64_t)res_ptr;
9173 }
9174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
9175         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
9176         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
9177         DO_ASSERT((res_ptr & 1) == 0);
9178         return (int64_t)(res_ptr | 1);
9179 }
9180 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) {
9181         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9182         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9183         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9184         LDKPublicKey their_node_id_ref;
9185         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9186         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9187         LDKInitFeatures their_features_conv;
9188         their_features_conv.inner = (void*)(their_features & (~1));
9189         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9190         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9191         their_features_conv = InitFeatures_clone(&their_features_conv);
9192         LDKOpenChannel msg_conv;
9193         msg_conv.inner = (void*)(msg & (~1));
9194         msg_conv.is_owned = false;
9195         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9196         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9197 }
9198
9199 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) {
9200         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9201         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9202         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9203         LDKPublicKey their_node_id_ref;
9204         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9205         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9206         LDKInitFeatures their_features_conv;
9207         their_features_conv.inner = (void*)(their_features & (~1));
9208         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9209         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9210         their_features_conv = InitFeatures_clone(&their_features_conv);
9211         LDKAcceptChannel msg_conv;
9212         msg_conv.inner = (void*)(msg & (~1));
9213         msg_conv.is_owned = false;
9214         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9215         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9216 }
9217
9218 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) {
9219         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9220         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9221         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9222         LDKPublicKey their_node_id_ref;
9223         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9224         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9225         LDKFundingCreated msg_conv;
9226         msg_conv.inner = (void*)(msg & (~1));
9227         msg_conv.is_owned = false;
9228         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9229         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9230 }
9231
9232 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) {
9233         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9234         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9235         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9236         LDKPublicKey their_node_id_ref;
9237         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9238         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9239         LDKFundingSigned msg_conv;
9240         msg_conv.inner = (void*)(msg & (~1));
9241         msg_conv.is_owned = false;
9242         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9243         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9244 }
9245
9246 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) {
9247         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9248         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9249         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9250         LDKPublicKey their_node_id_ref;
9251         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9252         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9253         LDKFundingLocked msg_conv;
9254         msg_conv.inner = (void*)(msg & (~1));
9255         msg_conv.is_owned = false;
9256         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9257         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9258 }
9259
9260 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) {
9261         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9262         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9263         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9264         LDKPublicKey their_node_id_ref;
9265         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9266         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9267         LDKInitFeatures their_features_conv;
9268         their_features_conv.inner = (void*)(their_features & (~1));
9269         their_features_conv.is_owned = false;
9270         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9271         LDKShutdown msg_conv;
9272         msg_conv.inner = (void*)(msg & (~1));
9273         msg_conv.is_owned = false;
9274         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9275         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9276 }
9277
9278 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) {
9279         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9280         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9281         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9282         LDKPublicKey their_node_id_ref;
9283         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9284         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9285         LDKClosingSigned msg_conv;
9286         msg_conv.inner = (void*)(msg & (~1));
9287         msg_conv.is_owned = false;
9288         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9289         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9290 }
9291
9292 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) {
9293         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9294         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9295         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9296         LDKPublicKey their_node_id_ref;
9297         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9298         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9299         LDKUpdateAddHTLC msg_conv;
9300         msg_conv.inner = (void*)(msg & (~1));
9301         msg_conv.is_owned = false;
9302         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9303         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9304 }
9305
9306 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) {
9307         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9308         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9309         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9310         LDKPublicKey their_node_id_ref;
9311         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9312         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9313         LDKUpdateFulfillHTLC msg_conv;
9314         msg_conv.inner = (void*)(msg & (~1));
9315         msg_conv.is_owned = false;
9316         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9317         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9318 }
9319
9320 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) {
9321         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9322         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9323         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9324         LDKPublicKey their_node_id_ref;
9325         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9326         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9327         LDKUpdateFailHTLC msg_conv;
9328         msg_conv.inner = (void*)(msg & (~1));
9329         msg_conv.is_owned = false;
9330         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9331         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9332 }
9333
9334 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) {
9335         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9336         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9337         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9338         LDKPublicKey their_node_id_ref;
9339         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9340         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9341         LDKUpdateFailMalformedHTLC msg_conv;
9342         msg_conv.inner = (void*)(msg & (~1));
9343         msg_conv.is_owned = false;
9344         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9345         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9346 }
9347
9348 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) {
9349         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9350         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9351         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9352         LDKPublicKey their_node_id_ref;
9353         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9354         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9355         LDKCommitmentSigned msg_conv;
9356         msg_conv.inner = (void*)(msg & (~1));
9357         msg_conv.is_owned = false;
9358         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9359         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9360 }
9361
9362 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) {
9363         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9364         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9365         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9366         LDKPublicKey their_node_id_ref;
9367         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9368         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9369         LDKRevokeAndACK msg_conv;
9370         msg_conv.inner = (void*)(msg & (~1));
9371         msg_conv.is_owned = false;
9372         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9373         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9374 }
9375
9376 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) {
9377         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9378         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9379         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9380         LDKPublicKey their_node_id_ref;
9381         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9382         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9383         LDKUpdateFee msg_conv;
9384         msg_conv.inner = (void*)(msg & (~1));
9385         msg_conv.is_owned = false;
9386         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9387         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9388 }
9389
9390 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) {
9391         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9392         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9393         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9394         LDKPublicKey their_node_id_ref;
9395         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9396         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9397         LDKAnnouncementSignatures msg_conv;
9398         msg_conv.inner = (void*)(msg & (~1));
9399         msg_conv.is_owned = false;
9400         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9401         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9402 }
9403
9404 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) {
9405         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9406         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9407         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9408         LDKPublicKey their_node_id_ref;
9409         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9410         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9411         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9412 }
9413
9414 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) {
9415         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9416         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9417         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9418         LDKPublicKey their_node_id_ref;
9419         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9420         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9421         LDKInit msg_conv;
9422         msg_conv.inner = (void*)(msg & (~1));
9423         msg_conv.is_owned = false;
9424         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9425         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9426 }
9427
9428 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) {
9429         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9430         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9431         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9432         LDKPublicKey their_node_id_ref;
9433         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9434         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9435         LDKChannelReestablish msg_conv;
9436         msg_conv.inner = (void*)(msg & (~1));
9437         msg_conv.is_owned = false;
9438         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9439         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9440 }
9441
9442 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) {
9443         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9444         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9445         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9446         LDKPublicKey their_node_id_ref;
9447         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9448         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9449         LDKChannelUpdate msg_conv;
9450         msg_conv.inner = (void*)(msg & (~1));
9451         msg_conv.is_owned = false;
9452         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9453         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9454 }
9455
9456 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) {
9457         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9458         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9459         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9460         LDKPublicKey their_node_id_ref;
9461         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9462         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9463         LDKErrorMessage msg_conv;
9464         msg_conv.inner = (void*)(msg & (~1));
9465         msg_conv.is_owned = false;
9466         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9467         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9468 }
9469
9470 typedef struct LDKRoutingMessageHandler_JCalls {
9471         atomic_size_t refcnt;
9472         JavaVM *vm;
9473         jweak o;
9474         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9475         jmethodID handle_node_announcement_meth;
9476         jmethodID handle_channel_announcement_meth;
9477         jmethodID handle_channel_update_meth;
9478         jmethodID get_next_channel_announcements_meth;
9479         jmethodID get_next_node_announcements_meth;
9480         jmethodID sync_routing_table_meth;
9481         jmethodID handle_reply_channel_range_meth;
9482         jmethodID handle_reply_short_channel_ids_end_meth;
9483         jmethodID handle_query_channel_range_meth;
9484         jmethodID handle_query_short_channel_ids_meth;
9485 } LDKRoutingMessageHandler_JCalls;
9486 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9487         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9488         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9489                 JNIEnv *env;
9490                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9491                 if (get_jenv_res == JNI_EDETACHED) {
9492                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9493                 } else {
9494                         DO_ASSERT(get_jenv_res == JNI_OK);
9495                 }
9496                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9497                 if (get_jenv_res == JNI_EDETACHED) {
9498                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9499                 }
9500                 FREE(j_calls);
9501         }
9502 }
9503 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9504         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9505         JNIEnv *env;
9506         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9507         if (get_jenv_res == JNI_EDETACHED) {
9508                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9509         } else {
9510                 DO_ASSERT(get_jenv_res == JNI_OK);
9511         }
9512         LDKNodeAnnouncement msg_var = *msg;
9513         uint64_t msg_ref = 0;
9514         msg_var = NodeAnnouncement_clone(msg);
9515         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9516         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9517         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9518         msg_ref = (uint64_t)msg_var.inner;
9519         if (msg_var.is_owned) {
9520                 msg_ref |= 1;
9521         }
9522         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9523         CHECK(obj != NULL);
9524         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
9525         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9526                 (*env)->ExceptionDescribe(env);
9527                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9528         }
9529         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9530         CHECK_ACCESS(ret_ptr);
9531         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9532         FREE((void*)ret);
9533         if (get_jenv_res == JNI_EDETACHED) {
9534                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9535         }
9536         return ret_conv;
9537 }
9538 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9539         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9540         JNIEnv *env;
9541         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9542         if (get_jenv_res == JNI_EDETACHED) {
9543                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9544         } else {
9545                 DO_ASSERT(get_jenv_res == JNI_OK);
9546         }
9547         LDKChannelAnnouncement msg_var = *msg;
9548         uint64_t msg_ref = 0;
9549         msg_var = ChannelAnnouncement_clone(msg);
9550         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9551         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9552         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9553         msg_ref = (uint64_t)msg_var.inner;
9554         if (msg_var.is_owned) {
9555                 msg_ref |= 1;
9556         }
9557         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9558         CHECK(obj != NULL);
9559         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
9560         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9561                 (*env)->ExceptionDescribe(env);
9562                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9563         }
9564         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9565         CHECK_ACCESS(ret_ptr);
9566         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9567         FREE((void*)ret);
9568         if (get_jenv_res == JNI_EDETACHED) {
9569                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9570         }
9571         return ret_conv;
9572 }
9573 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9574         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9575         JNIEnv *env;
9576         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9577         if (get_jenv_res == JNI_EDETACHED) {
9578                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9579         } else {
9580                 DO_ASSERT(get_jenv_res == JNI_OK);
9581         }
9582         LDKChannelUpdate msg_var = *msg;
9583         uint64_t msg_ref = 0;
9584         msg_var = ChannelUpdate_clone(msg);
9585         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9586         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9587         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9588         msg_ref = (uint64_t)msg_var.inner;
9589         if (msg_var.is_owned) {
9590                 msg_ref |= 1;
9591         }
9592         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9593         CHECK(obj != NULL);
9594         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
9595         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9596                 (*env)->ExceptionDescribe(env);
9597                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
9598         }
9599         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9600         CHECK_ACCESS(ret_ptr);
9601         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9602         FREE((void*)ret);
9603         if (get_jenv_res == JNI_EDETACHED) {
9604                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9605         }
9606         return ret_conv;
9607 }
9608 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9609         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9610         JNIEnv *env;
9611         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9612         if (get_jenv_res == JNI_EDETACHED) {
9613                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9614         } else {
9615                 DO_ASSERT(get_jenv_res == JNI_OK);
9616         }
9617         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9618         CHECK(obj != NULL);
9619         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
9620         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9621                 (*env)->ExceptionDescribe(env);
9622                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9623         }
9624         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9625         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9626         if (ret_constr.datalen > 0)
9627                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9628         else
9629                 ret_constr.data = NULL;
9630         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9631         for (size_t h = 0; h < ret_constr.datalen; h++) {
9632                 int64_t ret_conv_59 = ret_vals[h];
9633                 void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
9634                 CHECK_ACCESS(ret_conv_59_ptr);
9635                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9636                 FREE((void*)ret_conv_59);
9637                 ret_constr.data[h] = ret_conv_59_conv;
9638         }
9639         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9640         if (get_jenv_res == JNI_EDETACHED) {
9641                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9642         }
9643         return ret_constr;
9644 }
9645 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9646         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9647         JNIEnv *env;
9648         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9649         if (get_jenv_res == JNI_EDETACHED) {
9650                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9651         } else {
9652                 DO_ASSERT(get_jenv_res == JNI_OK);
9653         }
9654         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
9655         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
9656         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9657         CHECK(obj != NULL);
9658         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
9659         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9660                 (*env)->ExceptionDescribe(env);
9661                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9662         }
9663         LDKCVec_NodeAnnouncementZ ret_constr;
9664         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9665         if (ret_constr.datalen > 0)
9666                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9667         else
9668                 ret_constr.data = NULL;
9669         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9670         for (size_t s = 0; s < ret_constr.datalen; s++) {
9671                 int64_t ret_conv_18 = ret_vals[s];
9672                 LDKNodeAnnouncement ret_conv_18_conv;
9673                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9674                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9675                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9676                 ret_constr.data[s] = ret_conv_18_conv;
9677         }
9678         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9679         if (get_jenv_res == JNI_EDETACHED) {
9680                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9681         }
9682         return ret_constr;
9683 }
9684 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9685         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9686         JNIEnv *env;
9687         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9688         if (get_jenv_res == JNI_EDETACHED) {
9689                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9690         } else {
9691                 DO_ASSERT(get_jenv_res == JNI_OK);
9692         }
9693         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9694         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9695         LDKInit init_var = *init;
9696         uint64_t init_ref = 0;
9697         init_var = Init_clone(init);
9698         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9699         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9700         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9701         init_ref = (uint64_t)init_var.inner;
9702         if (init_var.is_owned) {
9703                 init_ref |= 1;
9704         }
9705         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9706         CHECK(obj != NULL);
9707         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
9708         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9709                 (*env)->ExceptionDescribe(env);
9710                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
9711         }
9712         if (get_jenv_res == JNI_EDETACHED) {
9713                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9714         }
9715 }
9716 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9717         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9718         JNIEnv *env;
9719         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9720         if (get_jenv_res == JNI_EDETACHED) {
9721                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9722         } else {
9723                 DO_ASSERT(get_jenv_res == JNI_OK);
9724         }
9725         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9726         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9727         LDKReplyChannelRange msg_var = msg;
9728         uint64_t msg_ref = 0;
9729         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9730         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9731         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9732         msg_ref = (uint64_t)msg_var.inner;
9733         if (msg_var.is_owned) {
9734                 msg_ref |= 1;
9735         }
9736         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9737         CHECK(obj != NULL);
9738         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
9739         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9740                 (*env)->ExceptionDescribe(env);
9741                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9742         }
9743         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9744         CHECK_ACCESS(ret_ptr);
9745         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9746         FREE((void*)ret);
9747         if (get_jenv_res == JNI_EDETACHED) {
9748                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9749         }
9750         return ret_conv;
9751 }
9752 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9753         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9754         JNIEnv *env;
9755         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9756         if (get_jenv_res == JNI_EDETACHED) {
9757                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9758         } else {
9759                 DO_ASSERT(get_jenv_res == JNI_OK);
9760         }
9761         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9762         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9763         LDKReplyShortChannelIdsEnd msg_var = msg;
9764         uint64_t msg_ref = 0;
9765         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9766         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9767         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9768         msg_ref = (uint64_t)msg_var.inner;
9769         if (msg_var.is_owned) {
9770                 msg_ref |= 1;
9771         }
9772         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9773         CHECK(obj != NULL);
9774         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
9775         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9776                 (*env)->ExceptionDescribe(env);
9777                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
9778         }
9779         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9780         CHECK_ACCESS(ret_ptr);
9781         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9782         FREE((void*)ret);
9783         if (get_jenv_res == JNI_EDETACHED) {
9784                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9785         }
9786         return ret_conv;
9787 }
9788 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9789         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9790         JNIEnv *env;
9791         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9792         if (get_jenv_res == JNI_EDETACHED) {
9793                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9794         } else {
9795                 DO_ASSERT(get_jenv_res == JNI_OK);
9796         }
9797         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9798         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9799         LDKQueryChannelRange msg_var = msg;
9800         uint64_t msg_ref = 0;
9801         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9802         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9803         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9804         msg_ref = (uint64_t)msg_var.inner;
9805         if (msg_var.is_owned) {
9806                 msg_ref |= 1;
9807         }
9808         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9809         CHECK(obj != NULL);
9810         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
9811         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9812                 (*env)->ExceptionDescribe(env);
9813                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9814         }
9815         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9816         CHECK_ACCESS(ret_ptr);
9817         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9818         FREE((void*)ret);
9819         if (get_jenv_res == JNI_EDETACHED) {
9820                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9821         }
9822         return ret_conv;
9823 }
9824 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9825         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9826         JNIEnv *env;
9827         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9828         if (get_jenv_res == JNI_EDETACHED) {
9829                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9830         } else {
9831                 DO_ASSERT(get_jenv_res == JNI_OK);
9832         }
9833         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9834         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9835         LDKQueryShortChannelIds msg_var = msg;
9836         uint64_t msg_ref = 0;
9837         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9838         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9839         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9840         msg_ref = (uint64_t)msg_var.inner;
9841         if (msg_var.is_owned) {
9842                 msg_ref |= 1;
9843         }
9844         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9845         CHECK(obj != NULL);
9846         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
9847         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9848                 (*env)->ExceptionDescribe(env);
9849                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
9850         }
9851         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9852         CHECK_ACCESS(ret_ptr);
9853         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9854         FREE((void*)ret);
9855         if (get_jenv_res == JNI_EDETACHED) {
9856                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9857         }
9858         return ret_conv;
9859 }
9860 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9861         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9862         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9863         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9864 }
9865 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9866         jclass c = (*env)->GetObjectClass(env, o);
9867         CHECK(c != NULL);
9868         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9869         atomic_init(&calls->refcnt, 1);
9870         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9871         calls->o = (*env)->NewWeakGlobalRef(env, o);
9872         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
9873         CHECK(calls->handle_node_announcement_meth != NULL);
9874         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
9875         CHECK(calls->handle_channel_announcement_meth != NULL);
9876         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
9877         CHECK(calls->handle_channel_update_meth != NULL);
9878         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
9879         CHECK(calls->get_next_channel_announcements_meth != NULL);
9880         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
9881         CHECK(calls->get_next_node_announcements_meth != NULL);
9882         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
9883         CHECK(calls->sync_routing_table_meth != NULL);
9884         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
9885         CHECK(calls->handle_reply_channel_range_meth != NULL);
9886         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
9887         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
9888         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
9889         CHECK(calls->handle_query_channel_range_meth != NULL);
9890         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
9891         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
9892
9893         LDKRoutingMessageHandler ret = {
9894                 .this_arg = (void*) calls,
9895                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9896                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9897                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9898                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9899                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9900                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
9901                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9902                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9903                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9904                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9905                 .free = LDKRoutingMessageHandler_JCalls_free,
9906                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
9907         };
9908         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9909         return ret;
9910 }
9911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9912         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9913         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
9914         return (uint64_t)res_ptr;
9915 }
9916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
9917         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
9918         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
9919         DO_ASSERT((res_ptr & 1) == 0);
9920         return (int64_t)(res_ptr | 1);
9921 }
9922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9923         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9924         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9925         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9926         LDKNodeAnnouncement msg_conv;
9927         msg_conv.inner = (void*)(msg & (~1));
9928         msg_conv.is_owned = false;
9929         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9930         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9931         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9932         return (uint64_t)ret_conv;
9933 }
9934
9935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9936         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9937         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9938         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9939         LDKChannelAnnouncement msg_conv;
9940         msg_conv.inner = (void*)(msg & (~1));
9941         msg_conv.is_owned = false;
9942         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9943         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9944         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9945         return (uint64_t)ret_conv;
9946 }
9947
9948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9949         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9950         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9951         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9952         LDKChannelUpdate msg_conv;
9953         msg_conv.inner = (void*)(msg & (~1));
9954         msg_conv.is_owned = false;
9955         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9956         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9957         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9958         return (uint64_t)ret_conv;
9959 }
9960
9961 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) {
9962         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9963         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9964         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9965         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9966         int64_tArray ret_arr = NULL;
9967         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9968         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9969         for (size_t h = 0; h < ret_var.datalen; h++) {
9970                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9971                 *ret_conv_59_conv = ret_var.data[h];
9972                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
9973         }
9974         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9975         FREE(ret_var.data);
9976         return ret_arr;
9977 }
9978
9979 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) {
9980         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9981         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9982         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9983         LDKPublicKey starting_point_ref;
9984         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
9985         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
9986         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9987         int64_tArray ret_arr = NULL;
9988         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9989         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9990         for (size_t s = 0; s < ret_var.datalen; s++) {
9991                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9992                 uint64_t ret_conv_18_ref = 0;
9993                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9994                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9995                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9996                 ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
9997                 if (ret_conv_18_var.is_owned) {
9998                         ret_conv_18_ref |= 1;
9999                 }
10000                 ret_arr_ptr[s] = ret_conv_18_ref;
10001         }
10002         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10003         FREE(ret_var.data);
10004         return ret_arr;
10005 }
10006
10007 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) {
10008         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10009         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10010         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10011         LDKPublicKey their_node_id_ref;
10012         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10013         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10014         LDKInit init_conv;
10015         init_conv.inner = (void*)(init & (~1));
10016         init_conv.is_owned = false;
10017         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
10018         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
10019 }
10020
10021 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) {
10022         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10023         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10024         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10025         LDKPublicKey their_node_id_ref;
10026         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10027         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10028         LDKReplyChannelRange msg_conv;
10029         msg_conv.inner = (void*)(msg & (~1));
10030         msg_conv.is_owned = (msg & 1) || (msg == 0);
10031         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10032         msg_conv = ReplyChannelRange_clone(&msg_conv);
10033         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10034         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10035         return (uint64_t)ret_conv;
10036 }
10037
10038 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) {
10039         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10040         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10041         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10042         LDKPublicKey their_node_id_ref;
10043         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10044         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10045         LDKReplyShortChannelIdsEnd msg_conv;
10046         msg_conv.inner = (void*)(msg & (~1));
10047         msg_conv.is_owned = (msg & 1) || (msg == 0);
10048         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10049         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
10050         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10051         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10052         return (uint64_t)ret_conv;
10053 }
10054
10055 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) {
10056         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10057         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10058         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10059         LDKPublicKey their_node_id_ref;
10060         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10061         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10062         LDKQueryChannelRange msg_conv;
10063         msg_conv.inner = (void*)(msg & (~1));
10064         msg_conv.is_owned = (msg & 1) || (msg == 0);
10065         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10066         msg_conv = QueryChannelRange_clone(&msg_conv);
10067         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10068         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10069         return (uint64_t)ret_conv;
10070 }
10071
10072 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) {
10073         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10074         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10075         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10076         LDKPublicKey their_node_id_ref;
10077         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10078         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10079         LDKQueryShortChannelIds msg_conv;
10080         msg_conv.inner = (void*)(msg & (~1));
10081         msg_conv.is_owned = (msg & 1) || (msg == 0);
10082         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10083         msg_conv = QueryShortChannelIds_clone(&msg_conv);
10084         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10085         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10086         return (uint64_t)ret_conv;
10087 }
10088
10089 typedef struct LDKCustomMessageReader_JCalls {
10090         atomic_size_t refcnt;
10091         JavaVM *vm;
10092         jweak o;
10093         jmethodID read_meth;
10094 } LDKCustomMessageReader_JCalls;
10095 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
10096         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10097         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10098                 JNIEnv *env;
10099                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10100                 if (get_jenv_res == JNI_EDETACHED) {
10101                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10102                 } else {
10103                         DO_ASSERT(get_jenv_res == JNI_OK);
10104                 }
10105                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10106                 if (get_jenv_res == JNI_EDETACHED) {
10107                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10108                 }
10109                 FREE(j_calls);
10110         }
10111 }
10112 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
10113         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10114         JNIEnv *env;
10115         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10116         if (get_jenv_res == JNI_EDETACHED) {
10117                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10118         } else {
10119                 DO_ASSERT(get_jenv_res == JNI_OK);
10120         }
10121         LDKu8slice buffer_var = buffer;
10122         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
10123         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
10124         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10125         CHECK(obj != NULL);
10126         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
10127         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10128                 (*env)->ExceptionDescribe(env);
10129                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
10130         }
10131         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10132         CHECK_ACCESS(ret_ptr);
10133         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
10134         FREE((void*)ret);
10135         if (get_jenv_res == JNI_EDETACHED) {
10136                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10137         }
10138         return ret_conv;
10139 }
10140 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
10141         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
10142         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10143 }
10144 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
10145         jclass c = (*env)->GetObjectClass(env, o);
10146         CHECK(c != NULL);
10147         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
10148         atomic_init(&calls->refcnt, 1);
10149         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10150         calls->o = (*env)->NewWeakGlobalRef(env, o);
10151         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
10152         CHECK(calls->read_meth != NULL);
10153
10154         LDKCustomMessageReader ret = {
10155                 .this_arg = (void*) calls,
10156                 .read = read_LDKCustomMessageReader_jcall,
10157                 .free = LDKCustomMessageReader_JCalls_free,
10158         };
10159         return ret;
10160 }
10161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
10162         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
10163         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
10164         return (uint64_t)res_ptr;
10165 }
10166 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) {
10167         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10168         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10169         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
10170         LDKu8slice buffer_ref;
10171         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
10172         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
10173         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10174         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
10175         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
10176         return (uint64_t)ret_conv;
10177 }
10178
10179 typedef struct LDKCustomMessageHandler_JCalls {
10180         atomic_size_t refcnt;
10181         JavaVM *vm;
10182         jweak o;
10183         LDKCustomMessageReader_JCalls* CustomMessageReader;
10184         jmethodID handle_custom_message_meth;
10185         jmethodID get_and_clear_pending_msg_meth;
10186 } LDKCustomMessageHandler_JCalls;
10187 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
10188         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10189         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10190                 JNIEnv *env;
10191                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10192                 if (get_jenv_res == JNI_EDETACHED) {
10193                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10194                 } else {
10195                         DO_ASSERT(get_jenv_res == JNI_OK);
10196                 }
10197                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10198                 if (get_jenv_res == JNI_EDETACHED) {
10199                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10200                 }
10201                 FREE(j_calls);
10202         }
10203 }
10204 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
10205         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10206         JNIEnv *env;
10207         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10208         if (get_jenv_res == JNI_EDETACHED) {
10209                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10210         } else {
10211                 DO_ASSERT(get_jenv_res == JNI_OK);
10212         }
10213         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
10214         *msg_ret = msg;
10215         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
10216         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
10217         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10218         CHECK(obj != NULL);
10219         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
10220         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10221                 (*env)->ExceptionDescribe(env);
10222                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
10223         }
10224         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10225         CHECK_ACCESS(ret_ptr);
10226         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10227         FREE((void*)ret);
10228         if (get_jenv_res == JNI_EDETACHED) {
10229                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10230         }
10231         return ret_conv;
10232 }
10233 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
10234         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10235         JNIEnv *env;
10236         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10237         if (get_jenv_res == JNI_EDETACHED) {
10238                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10239         } else {
10240                 DO_ASSERT(get_jenv_res == JNI_OK);
10241         }
10242         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10243         CHECK(obj != NULL);
10244         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
10245         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10246                 (*env)->ExceptionDescribe(env);
10247                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
10248         }
10249         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
10250         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10251         if (ret_constr.datalen > 0)
10252                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10253         else
10254                 ret_constr.data = NULL;
10255         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10256         for (size_t z = 0; z < ret_constr.datalen; z++) {
10257                 int64_t ret_conv_25 = ret_vals[z];
10258                 void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
10259                 CHECK_ACCESS(ret_conv_25_ptr);
10260                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
10261                 FREE((void*)ret_conv_25);
10262                 ret_constr.data[z] = ret_conv_25_conv;
10263         }
10264         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10265         if (get_jenv_res == JNI_EDETACHED) {
10266                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10267         }
10268         return ret_constr;
10269 }
10270 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
10271         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10272         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10273         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10274 }
10275 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
10276         jclass c = (*env)->GetObjectClass(env, o);
10277         CHECK(c != NULL);
10278         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10279         atomic_init(&calls->refcnt, 1);
10280         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10281         calls->o = (*env)->NewWeakGlobalRef(env, o);
10282         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
10283         CHECK(calls->handle_custom_message_meth != NULL);
10284         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
10285         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
10286
10287         LDKCustomMessageHandler ret = {
10288                 .this_arg = (void*) calls,
10289                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10290                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10291                 .free = LDKCustomMessageHandler_JCalls_free,
10292                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
10293         };
10294         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10295         return ret;
10296 }
10297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
10298         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10299         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
10300         return (uint64_t)res_ptr;
10301 }
10302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
10303         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
10304         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
10305         DO_ASSERT((res_ptr & 1) == 0);
10306         return (int64_t)(res_ptr | 1);
10307 }
10308 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) {
10309         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10310         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10311         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10312         void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
10313         CHECK_ACCESS(msg_ptr);
10314         LDKType msg_conv = *(LDKType*)(msg_ptr);
10315         if (msg_conv.free == LDKType_JCalls_free) {
10316                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10317                 LDKType_JCalls_cloned(&msg_conv);
10318         }
10319         LDKPublicKey sender_node_id_ref;
10320         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
10321         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
10322         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10323         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10324         return (uint64_t)ret_conv;
10325 }
10326
10327 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
10328         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10329         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10330         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10331         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10332         int64_tArray ret_arr = NULL;
10333         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10334         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10335         for (size_t z = 0; z < ret_var.datalen; z++) {
10336                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10337                 *ret_conv_25_conv = ret_var.data[z];
10338                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
10339         }
10340         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10341         FREE(ret_var.data);
10342         return ret_arr;
10343 }
10344
10345 typedef struct LDKSocketDescriptor_JCalls {
10346         atomic_size_t refcnt;
10347         JavaVM *vm;
10348         jweak o;
10349         jmethodID send_data_meth;
10350         jmethodID disconnect_socket_meth;
10351         jmethodID eq_meth;
10352         jmethodID hash_meth;
10353 } LDKSocketDescriptor_JCalls;
10354 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10355         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10356         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10357                 JNIEnv *env;
10358                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10359                 if (get_jenv_res == JNI_EDETACHED) {
10360                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10361                 } else {
10362                         DO_ASSERT(get_jenv_res == JNI_OK);
10363                 }
10364                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10365                 if (get_jenv_res == JNI_EDETACHED) {
10366                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10367                 }
10368                 FREE(j_calls);
10369         }
10370 }
10371 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10372         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10373         JNIEnv *env;
10374         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10375         if (get_jenv_res == JNI_EDETACHED) {
10376                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10377         } else {
10378                 DO_ASSERT(get_jenv_res == JNI_OK);
10379         }
10380         LDKu8slice data_var = data;
10381         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
10382         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
10383         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10384         CHECK(obj != NULL);
10385         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
10386         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10387                 (*env)->ExceptionDescribe(env);
10388                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
10389         }
10390         if (get_jenv_res == JNI_EDETACHED) {
10391                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10392         }
10393         return ret;
10394 }
10395 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10396         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10397         JNIEnv *env;
10398         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10399         if (get_jenv_res == JNI_EDETACHED) {
10400                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10401         } else {
10402                 DO_ASSERT(get_jenv_res == JNI_OK);
10403         }
10404         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10405         CHECK(obj != NULL);
10406         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
10407         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10408                 (*env)->ExceptionDescribe(env);
10409                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
10410         }
10411         if (get_jenv_res == JNI_EDETACHED) {
10412                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10413         }
10414 }
10415 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10416         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10417         JNIEnv *env;
10418         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10419         if (get_jenv_res == JNI_EDETACHED) {
10420                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10421         } else {
10422                 DO_ASSERT(get_jenv_res == JNI_OK);
10423         }
10424         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10425         *other_arg_clone = SocketDescriptor_clone(other_arg);
10426         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10427         CHECK(obj != NULL);
10428         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
10429         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10430                 (*env)->ExceptionDescribe(env);
10431                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
10432         }
10433         if (get_jenv_res == JNI_EDETACHED) {
10434                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10435         }
10436         return ret;
10437 }
10438 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10439         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10440         JNIEnv *env;
10441         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10442         if (get_jenv_res == JNI_EDETACHED) {
10443                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10444         } else {
10445                 DO_ASSERT(get_jenv_res == JNI_OK);
10446         }
10447         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10448         CHECK(obj != NULL);
10449         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
10450         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10451                 (*env)->ExceptionDescribe(env);
10452                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
10453         }
10454         if (get_jenv_res == JNI_EDETACHED) {
10455                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10456         }
10457         return ret;
10458 }
10459 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10460         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10461         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10462 }
10463 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
10464         jclass c = (*env)->GetObjectClass(env, o);
10465         CHECK(c != NULL);
10466         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10467         atomic_init(&calls->refcnt, 1);
10468         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10469         calls->o = (*env)->NewWeakGlobalRef(env, o);
10470         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
10471         CHECK(calls->send_data_meth != NULL);
10472         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
10473         CHECK(calls->disconnect_socket_meth != NULL);
10474         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
10475         CHECK(calls->eq_meth != NULL);
10476         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
10477         CHECK(calls->hash_meth != NULL);
10478
10479         LDKSocketDescriptor ret = {
10480                 .this_arg = (void*) calls,
10481                 .send_data = send_data_LDKSocketDescriptor_jcall,
10482                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10483                 .eq = eq_LDKSocketDescriptor_jcall,
10484                 .hash = hash_LDKSocketDescriptor_jcall,
10485                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10486                 .free = LDKSocketDescriptor_JCalls_free,
10487         };
10488         return ret;
10489 }
10490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
10491         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10492         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
10493         return (uint64_t)res_ptr;
10494 }
10495 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) {
10496         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10497         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10498         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10499         LDKu8slice data_ref;
10500         data_ref.datalen = (*env)->GetArrayLength(env, data);
10501         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
10502         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10503         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
10504         return ret_val;
10505 }
10506
10507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
10508         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10509         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10510         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10511         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10512 }
10513
10514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
10515         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10516         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10517         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10518         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
10519         return ret_val;
10520 }
10521
10522 typedef struct LDKScore_JCalls {
10523         atomic_size_t refcnt;
10524         JavaVM *vm;
10525         jweak o;
10526         jmethodID channel_penalty_msat_meth;
10527         jmethodID payment_path_failed_meth;
10528         jmethodID payment_path_successful_meth;
10529         jmethodID write_meth;
10530 } LDKScore_JCalls;
10531 static void LDKScore_JCalls_free(void* this_arg) {
10532         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10533         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10534                 JNIEnv *env;
10535                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10536                 if (get_jenv_res == JNI_EDETACHED) {
10537                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10538                 } else {
10539                         DO_ASSERT(get_jenv_res == JNI_OK);
10540                 }
10541                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10542                 if (get_jenv_res == JNI_EDETACHED) {
10543                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10544                 }
10545                 FREE(j_calls);
10546         }
10547 }
10548 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, LDKCOption_u64Z channel_capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
10549         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10550         JNIEnv *env;
10551         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10552         if (get_jenv_res == JNI_EDETACHED) {
10553                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10554         } else {
10555                 DO_ASSERT(get_jenv_res == JNI_OK);
10556         }
10557         LDKCOption_u64Z *channel_capacity_msat_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
10558         *channel_capacity_msat_copy = channel_capacity_msat;
10559         uint64_t channel_capacity_msat_ref = (uint64_t)channel_capacity_msat_copy;
10560         LDKNodeId source_var = *source;
10561         uint64_t source_ref = 0;
10562         source_var = NodeId_clone(source);
10563         CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10564         CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10565         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
10566         source_ref = (uint64_t)source_var.inner;
10567         if (source_var.is_owned) {
10568                 source_ref |= 1;
10569         }
10570         LDKNodeId target_var = *target;
10571         uint64_t target_ref = 0;
10572         target_var = NodeId_clone(target);
10573         CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10574         CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10575         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
10576         target_ref = (uint64_t)target_var.inner;
10577         if (target_var.is_owned) {
10578                 target_ref |= 1;
10579         }
10580         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10581         CHECK(obj != NULL);
10582         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, send_amt_msat, channel_capacity_msat_ref, source_ref, target_ref);
10583         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10584                 (*env)->ExceptionDescribe(env);
10585                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10586         }
10587         if (get_jenv_res == JNI_EDETACHED) {
10588                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10589         }
10590         return ret;
10591 }
10592 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10593         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10594         JNIEnv *env;
10595         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10596         if (get_jenv_res == JNI_EDETACHED) {
10597                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10598         } else {
10599                 DO_ASSERT(get_jenv_res == JNI_OK);
10600         }
10601         LDKCVec_RouteHopZ path_var = path;
10602         int64_tArray path_arr = NULL;
10603         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10604         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10605         for (size_t k = 0; k < path_var.datalen; k++) {
10606                 LDKRouteHop path_conv_10_var = path_var.data[k];
10607                 uint64_t path_conv_10_ref = 0;
10608                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10609                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10610                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10611                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
10612                 if (path_conv_10_var.is_owned) {
10613                         path_conv_10_ref |= 1;
10614                 }
10615                 path_arr_ptr[k] = path_conv_10_ref;
10616         }
10617         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10618         FREE(path_var.data);
10619         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10620         CHECK(obj != NULL);
10621         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
10622         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10623                 (*env)->ExceptionDescribe(env);
10624                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10625         }
10626         if (get_jenv_res == JNI_EDETACHED) {
10627                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10628         }
10629 }
10630 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10631         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10632         JNIEnv *env;
10633         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10634         if (get_jenv_res == JNI_EDETACHED) {
10635                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10636         } else {
10637                 DO_ASSERT(get_jenv_res == JNI_OK);
10638         }
10639         LDKCVec_RouteHopZ path_var = path;
10640         int64_tArray path_arr = NULL;
10641         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10642         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10643         for (size_t k = 0; k < path_var.datalen; k++) {
10644                 LDKRouteHop path_conv_10_var = path_var.data[k];
10645                 uint64_t path_conv_10_ref = 0;
10646                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10647                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10648                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10649                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
10650                 if (path_conv_10_var.is_owned) {
10651                         path_conv_10_ref |= 1;
10652                 }
10653                 path_arr_ptr[k] = path_conv_10_ref;
10654         }
10655         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10656         FREE(path_var.data);
10657         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10658         CHECK(obj != NULL);
10659         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
10660         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10661                 (*env)->ExceptionDescribe(env);
10662                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
10663         }
10664         if (get_jenv_res == JNI_EDETACHED) {
10665                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10666         }
10667 }
10668 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10669         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10670         JNIEnv *env;
10671         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10672         if (get_jenv_res == JNI_EDETACHED) {
10673                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10674         } else {
10675                 DO_ASSERT(get_jenv_res == JNI_OK);
10676         }
10677         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10678         CHECK(obj != NULL);
10679         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10680         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10681                 (*env)->ExceptionDescribe(env);
10682                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10683         }
10684         LDKCVec_u8Z ret_ref;
10685         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10686         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10687         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10688         if (get_jenv_res == JNI_EDETACHED) {
10689                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10690         }
10691         return ret_ref;
10692 }
10693 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10694         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10695         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10696 }
10697 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10698         jclass c = (*env)->GetObjectClass(env, o);
10699         CHECK(c != NULL);
10700         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10701         atomic_init(&calls->refcnt, 1);
10702         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10703         calls->o = (*env)->NewWeakGlobalRef(env, o);
10704         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJJ)J");
10705         CHECK(calls->channel_penalty_msat_meth != NULL);
10706         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10707         CHECK(calls->payment_path_failed_meth != NULL);
10708         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
10709         CHECK(calls->payment_path_successful_meth != NULL);
10710         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10711         CHECK(calls->write_meth != NULL);
10712
10713         LDKScore ret = {
10714                 .this_arg = (void*) calls,
10715                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10716                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10717                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
10718                 .write = write_LDKScore_jcall,
10719                 .free = LDKScore_JCalls_free,
10720         };
10721         return ret;
10722 }
10723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10724         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10725         *res_ptr = LDKScore_init(env, clz, o);
10726         return (uint64_t)res_ptr;
10727 }
10728 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 channel_capacity_msat, int64_t source, int64_t target) {
10729         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10730         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10731         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10732         void* channel_capacity_msat_ptr = (void*)(((uint64_t)channel_capacity_msat) & ~1);
10733         CHECK_ACCESS(channel_capacity_msat_ptr);
10734         LDKCOption_u64Z channel_capacity_msat_conv = *(LDKCOption_u64Z*)(channel_capacity_msat_ptr);
10735         channel_capacity_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)channel_capacity_msat) & ~1));
10736         LDKNodeId source_conv;
10737         source_conv.inner = (void*)(source & (~1));
10738         source_conv.is_owned = false;
10739         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10740         LDKNodeId target_conv;
10741         target_conv.inner = (void*)(target & (~1));
10742         target_conv.is_owned = false;
10743         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10744         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, channel_capacity_msat_conv, &source_conv, &target_conv);
10745         return ret_val;
10746 }
10747
10748 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) {
10749         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10750         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10751         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10752         LDKCVec_RouteHopZ path_constr;
10753         path_constr.datalen = (*env)->GetArrayLength(env, path);
10754         if (path_constr.datalen > 0)
10755                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10756         else
10757                 path_constr.data = NULL;
10758         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10759         for (size_t k = 0; k < path_constr.datalen; k++) {
10760                 int64_t path_conv_10 = path_vals[k];
10761                 LDKRouteHop path_conv_10_conv;
10762                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10763                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10764                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10765                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10766                 path_constr.data[k] = path_conv_10_conv;
10767         }
10768         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10769         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10770 }
10771
10772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10773         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10774         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10775         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10776         LDKCVec_RouteHopZ path_constr;
10777         path_constr.datalen = (*env)->GetArrayLength(env, path);
10778         if (path_constr.datalen > 0)
10779                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10780         else
10781                 path_constr.data = NULL;
10782         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10783         for (size_t k = 0; k < path_constr.datalen; k++) {
10784                 int64_t path_conv_10 = path_vals[k];
10785                 LDKRouteHop path_conv_10_conv;
10786                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10787                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10788                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10789                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10790                 path_constr.data[k] = path_conv_10_conv;
10791         }
10792         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10793         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10794 }
10795
10796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
10797         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10798         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10799         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10800         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10801         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10802         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10803         CVec_u8Z_free(ret_var);
10804         return ret_arr;
10805 }
10806
10807 typedef struct LDKLockableScore_JCalls {
10808         atomic_size_t refcnt;
10809         JavaVM *vm;
10810         jweak o;
10811         jmethodID lock_meth;
10812 } LDKLockableScore_JCalls;
10813 static void LDKLockableScore_JCalls_free(void* this_arg) {
10814         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10815         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10816                 JNIEnv *env;
10817                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10818                 if (get_jenv_res == JNI_EDETACHED) {
10819                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10820                 } else {
10821                         DO_ASSERT(get_jenv_res == JNI_OK);
10822                 }
10823                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10824                 if (get_jenv_res == JNI_EDETACHED) {
10825                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10826                 }
10827                 FREE(j_calls);
10828         }
10829 }
10830 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10831         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10832         JNIEnv *env;
10833         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10834         if (get_jenv_res == JNI_EDETACHED) {
10835                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10836         } else {
10837                 DO_ASSERT(get_jenv_res == JNI_OK);
10838         }
10839         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10840         CHECK(obj != NULL);
10841         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
10842         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10843                 (*env)->ExceptionDescribe(env);
10844                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
10845         }
10846         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10847         CHECK_ACCESS(ret_ptr);
10848         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10849         if (ret_conv.free == LDKScore_JCalls_free) {
10850                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10851                 LDKScore_JCalls_cloned(&ret_conv);
10852         }// Warning: we may need a move here but no clone is available for LDKScore
10853         
10854         if (get_jenv_res == JNI_EDETACHED) {
10855                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10856         }
10857         return ret_conv;
10858 }
10859 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10860         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10861         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10862 }
10863 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
10864         jclass c = (*env)->GetObjectClass(env, o);
10865         CHECK(c != NULL);
10866         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10867         atomic_init(&calls->refcnt, 1);
10868         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10869         calls->o = (*env)->NewWeakGlobalRef(env, o);
10870         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
10871         CHECK(calls->lock_meth != NULL);
10872
10873         LDKLockableScore ret = {
10874                 .this_arg = (void*) calls,
10875                 .lock = lock_LDKLockableScore_jcall,
10876                 .free = LDKLockableScore_JCalls_free,
10877         };
10878         return ret;
10879 }
10880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
10881         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10882         *res_ptr = LDKLockableScore_init(env, clz, o);
10883         return (uint64_t)res_ptr;
10884 }
10885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
10886         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10887         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10888         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10889         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10890         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10891         return (uint64_t)ret_ret;
10892 }
10893
10894 typedef struct LDKChannelManagerPersister_JCalls {
10895         atomic_size_t refcnt;
10896         JavaVM *vm;
10897         jweak o;
10898         jmethodID persist_manager_meth;
10899 } LDKChannelManagerPersister_JCalls;
10900 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
10901         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10902         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10903                 JNIEnv *env;
10904                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10905                 if (get_jenv_res == JNI_EDETACHED) {
10906                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10907                 } else {
10908                         DO_ASSERT(get_jenv_res == JNI_OK);
10909                 }
10910                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10911                 if (get_jenv_res == JNI_EDETACHED) {
10912                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10913                 }
10914                 FREE(j_calls);
10915         }
10916 }
10917 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10918         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10919         JNIEnv *env;
10920         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10921         if (get_jenv_res == JNI_EDETACHED) {
10922                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10923         } else {
10924                 DO_ASSERT(get_jenv_res == JNI_OK);
10925         }
10926         LDKChannelManager channel_manager_var = *channel_manager;
10927         uint64_t channel_manager_ref = 0;
10928         // Warning: we may need a move here but no clone is available for LDKChannelManager
10929         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10930         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10931         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
10932         channel_manager_ref = (uint64_t)channel_manager_var.inner;
10933         if (channel_manager_var.is_owned) {
10934                 channel_manager_ref |= 1;
10935         }
10936         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10937         CHECK(obj != NULL);
10938         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10939         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10940                 (*env)->ExceptionDescribe(env);
10941                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
10942         }
10943         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10944         CHECK_ACCESS(ret_ptr);
10945         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10946         FREE((void*)ret);
10947         if (get_jenv_res == JNI_EDETACHED) {
10948                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10949         }
10950         return ret_conv;
10951 }
10952 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
10953         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
10954         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10955 }
10956 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
10957         jclass c = (*env)->GetObjectClass(env, o);
10958         CHECK(c != NULL);
10959         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
10960         atomic_init(&calls->refcnt, 1);
10961         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10962         calls->o = (*env)->NewWeakGlobalRef(env, o);
10963         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10964         CHECK(calls->persist_manager_meth != NULL);
10965
10966         LDKChannelManagerPersister ret = {
10967                 .this_arg = (void*) calls,
10968                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
10969                 .free = LDKChannelManagerPersister_JCalls_free,
10970         };
10971         return ret;
10972 }
10973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10974         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
10975         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
10976         return (uint64_t)res_ptr;
10977 }
10978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10979         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10980         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10981         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
10982         LDKChannelManager channel_manager_conv;
10983         channel_manager_conv.inner = (void*)(channel_manager & (~1));
10984         channel_manager_conv.is_owned = false;
10985         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
10986         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10987         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10988         return (uint64_t)ret_conv;
10989 }
10990
10991 static jclass LDKFallback_SegWitProgram_class = NULL;
10992 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
10993 static jclass LDKFallback_PubKeyHash_class = NULL;
10994 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
10995 static jclass LDKFallback_ScriptHash_class = NULL;
10996 static jmethodID LDKFallback_ScriptHash_meth = NULL;
10997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
10998         LDKFallback_SegWitProgram_class =
10999                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
11000         CHECK(LDKFallback_SegWitProgram_class != NULL);
11001         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
11002         CHECK(LDKFallback_SegWitProgram_meth != NULL);
11003         LDKFallback_PubKeyHash_class =
11004                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
11005         CHECK(LDKFallback_PubKeyHash_class != NULL);
11006         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
11007         CHECK(LDKFallback_PubKeyHash_meth != NULL);
11008         LDKFallback_ScriptHash_class =
11009                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
11010         CHECK(LDKFallback_ScriptHash_class != NULL);
11011         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
11012         CHECK(LDKFallback_ScriptHash_meth != NULL);
11013 }
11014 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11015         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
11016         switch(obj->tag) {
11017                 case LDKFallback_SegWitProgram: {
11018                         uint8_t version_val = obj->seg_wit_program.version._0;
11019                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
11020                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
11021                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
11022                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
11023                 }
11024                 case LDKFallback_PubKeyHash: {
11025                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
11026                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
11027                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
11028                 }
11029                 case LDKFallback_ScriptHash: {
11030                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
11031                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
11032                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
11033                 }
11034                 default: abort();
11035         }
11036 }
11037 typedef struct LDKPayer_JCalls {
11038         atomic_size_t refcnt;
11039         JavaVM *vm;
11040         jweak o;
11041         jmethodID node_id_meth;
11042         jmethodID first_hops_meth;
11043         jmethodID send_payment_meth;
11044         jmethodID send_spontaneous_payment_meth;
11045         jmethodID retry_payment_meth;
11046         jmethodID abandon_payment_meth;
11047 } LDKPayer_JCalls;
11048 static void LDKPayer_JCalls_free(void* this_arg) {
11049         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11050         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11051                 JNIEnv *env;
11052                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11053                 if (get_jenv_res == JNI_EDETACHED) {
11054                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11055                 } else {
11056                         DO_ASSERT(get_jenv_res == JNI_OK);
11057                 }
11058                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11059                 if (get_jenv_res == JNI_EDETACHED) {
11060                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11061                 }
11062                 FREE(j_calls);
11063         }
11064 }
11065 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
11066         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11067         JNIEnv *env;
11068         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11069         if (get_jenv_res == JNI_EDETACHED) {
11070                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11071         } else {
11072                 DO_ASSERT(get_jenv_res == JNI_OK);
11073         }
11074         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11075         CHECK(obj != NULL);
11076         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
11077         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11078                 (*env)->ExceptionDescribe(env);
11079                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
11080         }
11081         LDKPublicKey ret_ref;
11082         CHECK((*env)->GetArrayLength(env, ret) == 33);
11083         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
11084         if (get_jenv_res == JNI_EDETACHED) {
11085                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11086         }
11087         return ret_ref;
11088 }
11089 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
11090         LDKPayer_JCalls *j_calls = (LDKPayer_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         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11099         CHECK(obj != NULL);
11100         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
11101         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11102                 (*env)->ExceptionDescribe(env);
11103                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
11104         }
11105         LDKCVec_ChannelDetailsZ ret_constr;
11106         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11107         if (ret_constr.datalen > 0)
11108                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11109         else
11110                 ret_constr.data = NULL;
11111         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11112         for (size_t q = 0; q < ret_constr.datalen; q++) {
11113                 int64_t ret_conv_16 = ret_vals[q];
11114                 LDKChannelDetails ret_conv_16_conv;
11115                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
11116                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
11117                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
11118                 ret_constr.data[q] = ret_conv_16_conv;
11119         }
11120         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11121         if (get_jenv_res == JNI_EDETACHED) {
11122                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11123         }
11124         return ret_constr;
11125 }
11126 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
11127         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11128         JNIEnv *env;
11129         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11130         if (get_jenv_res == JNI_EDETACHED) {
11131                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11132         } else {
11133                 DO_ASSERT(get_jenv_res == JNI_OK);
11134         }
11135         LDKRoute route_var = *route;
11136         uint64_t route_ref = 0;
11137         route_var = Route_clone(route);
11138         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11139         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11140         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
11141         route_ref = (uint64_t)route_var.inner;
11142         if (route_var.is_owned) {
11143                 route_ref |= 1;
11144         }
11145         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
11146         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
11147         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
11148         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
11149         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11150         CHECK(obj != NULL);
11151         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
11152         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11153                 (*env)->ExceptionDescribe(env);
11154                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
11155         }
11156         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
11157         CHECK_ACCESS(ret_ptr);
11158         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
11159         FREE((void*)ret);
11160         if (get_jenv_res == JNI_EDETACHED) {
11161                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11162         }
11163         return ret_conv;
11164 }
11165 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
11166         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11167         JNIEnv *env;
11168         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11169         if (get_jenv_res == JNI_EDETACHED) {
11170                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11171         } else {
11172                 DO_ASSERT(get_jenv_res == JNI_OK);
11173         }
11174         LDKRoute route_var = *route;
11175         uint64_t route_ref = 0;
11176         route_var = Route_clone(route);
11177         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11178         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11179         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
11180         route_ref = (uint64_t)route_var.inner;
11181         if (route_var.is_owned) {
11182                 route_ref |= 1;
11183         }
11184         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
11185         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
11186         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11187         CHECK(obj != NULL);
11188         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
11189         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11190                 (*env)->ExceptionDescribe(env);
11191                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
11192         }
11193         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
11194         CHECK_ACCESS(ret_ptr);
11195         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
11196         FREE((void*)ret);
11197         if (get_jenv_res == JNI_EDETACHED) {
11198                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11199         }
11200         return ret_conv;
11201 }
11202 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
11203         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11204         JNIEnv *env;
11205         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11206         if (get_jenv_res == JNI_EDETACHED) {
11207                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11208         } else {
11209                 DO_ASSERT(get_jenv_res == JNI_OK);
11210         }
11211         LDKRoute route_var = *route;
11212         uint64_t route_ref = 0;
11213         route_var = Route_clone(route);
11214         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11215         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11216         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
11217         route_ref = (uint64_t)route_var.inner;
11218         if (route_var.is_owned) {
11219                 route_ref |= 1;
11220         }
11221         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
11222         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
11223         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11224         CHECK(obj != NULL);
11225         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
11226         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11227                 (*env)->ExceptionDescribe(env);
11228                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
11229         }
11230         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
11231         CHECK_ACCESS(ret_ptr);
11232         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
11233         FREE((void*)ret);
11234         if (get_jenv_res == JNI_EDETACHED) {
11235                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11236         }
11237         return ret_conv;
11238 }
11239 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
11240         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11241         JNIEnv *env;
11242         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11243         if (get_jenv_res == JNI_EDETACHED) {
11244                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11245         } else {
11246                 DO_ASSERT(get_jenv_res == JNI_OK);
11247         }
11248         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
11249         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
11250         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11251         CHECK(obj != NULL);
11252         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
11253         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11254                 (*env)->ExceptionDescribe(env);
11255                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
11256         }
11257         if (get_jenv_res == JNI_EDETACHED) {
11258                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11259         }
11260 }
11261 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
11262         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
11263         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11264 }
11265 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
11266         jclass c = (*env)->GetObjectClass(env, o);
11267         CHECK(c != NULL);
11268         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
11269         atomic_init(&calls->refcnt, 1);
11270         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11271         calls->o = (*env)->NewWeakGlobalRef(env, o);
11272         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
11273         CHECK(calls->node_id_meth != NULL);
11274         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
11275         CHECK(calls->first_hops_meth != NULL);
11276         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
11277         CHECK(calls->send_payment_meth != NULL);
11278         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
11279         CHECK(calls->send_spontaneous_payment_meth != NULL);
11280         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
11281         CHECK(calls->retry_payment_meth != NULL);
11282         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
11283         CHECK(calls->abandon_payment_meth != NULL);
11284
11285         LDKPayer ret = {
11286                 .this_arg = (void*) calls,
11287                 .node_id = node_id_LDKPayer_jcall,
11288                 .first_hops = first_hops_LDKPayer_jcall,
11289                 .send_payment = send_payment_LDKPayer_jcall,
11290                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
11291                 .retry_payment = retry_payment_LDKPayer_jcall,
11292                 .abandon_payment = abandon_payment_LDKPayer_jcall,
11293                 .free = LDKPayer_JCalls_free,
11294         };
11295         return ret;
11296 }
11297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
11298         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
11299         *res_ptr = LDKPayer_init(env, clz, o);
11300         return (uint64_t)res_ptr;
11301 }
11302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
11303         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11304         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11305         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11306         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
11307         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
11308         return ret_arr;
11309 }
11310
11311 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
11312         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11313         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11314         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11315         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
11316         int64_tArray ret_arr = NULL;
11317         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11318         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11319         for (size_t q = 0; q < ret_var.datalen; q++) {
11320                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11321                 uint64_t ret_conv_16_ref = 0;
11322                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11323                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11324                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
11325                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
11326                 if (ret_conv_16_var.is_owned) {
11327                         ret_conv_16_ref |= 1;
11328                 }
11329                 ret_arr_ptr[q] = ret_conv_16_ref;
11330         }
11331         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11332         FREE(ret_var.data);
11333         return ret_arr;
11334 }
11335
11336 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) {
11337         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11338         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11339         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11340         LDKRoute route_conv;
11341         route_conv.inner = (void*)(route & (~1));
11342         route_conv.is_owned = false;
11343         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11344         LDKThirtyTwoBytes payment_hash_ref;
11345         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
11346         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
11347         LDKThirtyTwoBytes payment_secret_ref;
11348         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
11349         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
11350         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11351         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
11352         return (uint64_t)ret_conv;
11353 }
11354
11355 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) {
11356         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11357         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11358         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11359         LDKRoute route_conv;
11360         route_conv.inner = (void*)(route & (~1));
11361         route_conv.is_owned = false;
11362         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11363         LDKThirtyTwoBytes payment_preimage_ref;
11364         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
11365         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
11366         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11367         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
11368         return (uint64_t)ret_conv;
11369 }
11370
11371 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) {
11372         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11373         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11374         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11375         LDKRoute route_conv;
11376         route_conv.inner = (void*)(route & (~1));
11377         route_conv.is_owned = false;
11378         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11379         LDKThirtyTwoBytes payment_id_ref;
11380         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
11381         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
11382         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11383         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
11384         return (uint64_t)ret_conv;
11385 }
11386
11387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
11388         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11389         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11390         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11391         LDKThirtyTwoBytes payment_id_ref;
11392         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
11393         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
11394         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
11395 }
11396
11397 typedef struct LDKRouter_JCalls {
11398         atomic_size_t refcnt;
11399         JavaVM *vm;
11400         jweak o;
11401         jmethodID find_route_meth;
11402 } LDKRouter_JCalls;
11403 static void LDKRouter_JCalls_free(void* this_arg) {
11404         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11405         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11406                 JNIEnv *env;
11407                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11408                 if (get_jenv_res == JNI_EDETACHED) {
11409                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11410                 } else {
11411                         DO_ASSERT(get_jenv_res == JNI_OK);
11412                 }
11413                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11414                 if (get_jenv_res == JNI_EDETACHED) {
11415                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11416                 }
11417                 FREE(j_calls);
11418         }
11419 }
11420 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
11421         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11422         JNIEnv *env;
11423         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11424         if (get_jenv_res == JNI_EDETACHED) {
11425                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11426         } else {
11427                 DO_ASSERT(get_jenv_res == JNI_OK);
11428         }
11429         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
11430         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
11431         LDKRouteParameters params_var = *params;
11432         uint64_t params_ref = 0;
11433         params_var = RouteParameters_clone(params);
11434         CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11435         CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11436         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_var);
11437         params_ref = (uint64_t)params_var.inner;
11438         if (params_var.is_owned) {
11439                 params_ref |= 1;
11440         }
11441         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
11442         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
11443         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
11444         int64_tArray first_hops_arr = NULL;
11445         if (first_hops != NULL) {
11446                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
11447                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
11448                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
11449                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
11450                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
11451                         uint64_t first_hops_conv_16_ref = 0;
11452                         CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11453                         CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11454                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
11455                         first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
11456                         if (first_hops_conv_16_var.is_owned) {
11457                                 first_hops_conv_16_ref |= 1;
11458                         }
11459                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
11460                 }
11461                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
11462         }
11463         // WARNING: This object doesn't live past this scope, needs clone!
11464         uint64_t ret_scorer = ((uint64_t)scorer) | 1;
11465         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11466         CHECK(obj != NULL);
11467         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, params_ref, payment_hash_arr, first_hops_arr, ret_scorer);
11468         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11469                 (*env)->ExceptionDescribe(env);
11470                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
11471         }
11472         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
11473         CHECK_ACCESS(ret_ptr);
11474         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
11475         FREE((void*)ret);
11476         if (get_jenv_res == JNI_EDETACHED) {
11477                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11478         }
11479         return ret_conv;
11480 }
11481 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
11482         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
11483         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11484 }
11485 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
11486         jclass c = (*env)->GetObjectClass(env, o);
11487         CHECK(c != NULL);
11488         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
11489         atomic_init(&calls->refcnt, 1);
11490         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11491         calls->o = (*env)->NewWeakGlobalRef(env, o);
11492         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
11493         CHECK(calls->find_route_meth != NULL);
11494
11495         LDKRouter ret = {
11496                 .this_arg = (void*) calls,
11497                 .find_route = find_route_LDKRouter_jcall,
11498                 .free = LDKRouter_JCalls_free,
11499         };
11500         return ret;
11501 }
11502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
11503         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
11504         *res_ptr = LDKRouter_init(env, clz, o);
11505         return (uint64_t)res_ptr;
11506 }
11507 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 params, int8_tArray payment_hash, int64_tArray first_hops, int64_t scorer) {
11508         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
11509         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11510         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
11511         LDKPublicKey payer_ref;
11512         CHECK((*env)->GetArrayLength(env, payer) == 33);
11513         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
11514         LDKRouteParameters params_conv;
11515         params_conv.inner = (void*)(params & (~1));
11516         params_conv.is_owned = false;
11517         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
11518         unsigned char payment_hash_arr[32];
11519         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
11520         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
11521         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11522         LDKCVec_ChannelDetailsZ first_hops_constr;
11523         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
11524         if (first_hops != NULL) {
11525                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
11526                 if (first_hops_constr.datalen > 0)
11527                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11528                 else
11529                         first_hops_constr.data = NULL;
11530                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
11531                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
11532                         int64_t first_hops_conv_16 = first_hops_vals[q];
11533                         LDKChannelDetails first_hops_conv_16_conv;
11534                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
11535                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
11536                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
11537                         first_hops_constr.data[q] = first_hops_conv_16_conv;
11538                 }
11539                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
11540                 first_hops_ptr = &first_hops_constr;
11541         }
11542         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
11543         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
11544         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
11545         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11546         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, payment_hash_ref, first_hops_ptr, scorer_conv);
11547         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
11548         return (uint64_t)ret_conv;
11549 }
11550
11551 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
11552         LDKStr ret_str = _ldk_get_compiled_version();
11553         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
11554         Str_free(ret_str);
11555         return ret_conv;
11556 }
11557
11558 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
11559         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11560         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
11561         Str_free(ret_str);
11562         return ret_conv;
11563 }
11564
11565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
11566         LDKTransaction _res_ref;
11567         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
11568         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11569         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
11570         _res_ref.data_is_owned = true;
11571         Transaction_free(_res_ref);
11572 }
11573
11574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
11575         LDKCVec_u8Z script_pubkey_ref;
11576         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
11577         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11578         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
11579         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11580         *ret_ref = TxOut_new(script_pubkey_ref, value);
11581         return (uint64_t)ret_ref;
11582 }
11583
11584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
11585         if ((_res & 1) != 0) return;
11586         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11587         CHECK_ACCESS(_res_ptr);
11588         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11589         FREE((void*)_res);
11590         TxOut_free(_res_conv);
11591 }
11592
11593 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
11594         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11595         *ret_ref = TxOut_clone(arg);
11596         return (uint64_t)ret_ref;
11597 }
11598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11599         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
11600         int64_t ret_val = TxOut_clone_ptr(arg_conv);
11601         return ret_val;
11602 }
11603
11604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11605         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
11606         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11607         *ret_ref = TxOut_clone(orig_conv);
11608         return (uint64_t)ret_ref;
11609 }
11610
11611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
11612         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11613         Str_free(dummy);
11614 }
11615
11616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11617         LDKSecretKey o_ref;
11618         CHECK((*env)->GetArrayLength(env, o) == 32);
11619         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
11620         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11621         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11622         return (uint64_t)ret_conv;
11623 }
11624
11625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11626         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11627         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11628         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11629         return (uint64_t)ret_conv;
11630 }
11631
11632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11633         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
11634         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
11635         return ret_val;
11636 }
11637
11638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11639         if ((_res & 1) != 0) return;
11640         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11641         CHECK_ACCESS(_res_ptr);
11642         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11643         FREE((void*)_res);
11644         CResult_SecretKeyErrorZ_free(_res_conv);
11645 }
11646
11647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11648         LDKPublicKey o_ref;
11649         CHECK((*env)->GetArrayLength(env, o) == 33);
11650         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
11651         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11652         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11653         return (uint64_t)ret_conv;
11654 }
11655
11656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11657         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11658         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11659         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11660         return (uint64_t)ret_conv;
11661 }
11662
11663 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11664         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
11665         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
11666         return ret_val;
11667 }
11668
11669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11670         if ((_res & 1) != 0) return;
11671         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11672         CHECK_ACCESS(_res_ptr);
11673         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11674         FREE((void*)_res);
11675         CResult_PublicKeyErrorZ_free(_res_conv);
11676 }
11677
11678 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11679         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11680         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11681         return (uint64_t)ret_conv;
11682 }
11683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11684         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
11685         int64_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11686         return ret_val;
11687 }
11688
11689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11690         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11691         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11692         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11693         return (uint64_t)ret_conv;
11694 }
11695
11696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11697         LDKTxCreationKeys o_conv;
11698         o_conv.inner = (void*)(o & (~1));
11699         o_conv.is_owned = (o & 1) || (o == 0);
11700         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11701         o_conv = TxCreationKeys_clone(&o_conv);
11702         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11703         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11704         return (uint64_t)ret_conv;
11705 }
11706
11707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11708         LDKDecodeError e_conv;
11709         e_conv.inner = (void*)(e & (~1));
11710         e_conv.is_owned = (e & 1) || (e == 0);
11711         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11712         e_conv = DecodeError_clone(&e_conv);
11713         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11714         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11715         return (uint64_t)ret_conv;
11716 }
11717
11718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11719         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
11720         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11721         return ret_val;
11722 }
11723
11724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11725         if ((_res & 1) != 0) return;
11726         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11727         CHECK_ACCESS(_res_ptr);
11728         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11729         FREE((void*)_res);
11730         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11731 }
11732
11733 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11734         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11735         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11736         return (uint64_t)ret_conv;
11737 }
11738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11739         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
11740         int64_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11741         return ret_val;
11742 }
11743
11744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11745         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11746         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11747         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11748         return (uint64_t)ret_conv;
11749 }
11750
11751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11752         LDKChannelPublicKeys o_conv;
11753         o_conv.inner = (void*)(o & (~1));
11754         o_conv.is_owned = (o & 1) || (o == 0);
11755         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11756         o_conv = ChannelPublicKeys_clone(&o_conv);
11757         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11758         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11759         return (uint64_t)ret_conv;
11760 }
11761
11762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11763         LDKDecodeError e_conv;
11764         e_conv.inner = (void*)(e & (~1));
11765         e_conv.is_owned = (e & 1) || (e == 0);
11766         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11767         e_conv = DecodeError_clone(&e_conv);
11768         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11769         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11770         return (uint64_t)ret_conv;
11771 }
11772
11773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11774         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
11775         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11776         return ret_val;
11777 }
11778
11779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11780         if ((_res & 1) != 0) return;
11781         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11782         CHECK_ACCESS(_res_ptr);
11783         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11784         FREE((void*)_res);
11785         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11786 }
11787
11788 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11789         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11790         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11791         return (uint64_t)ret_conv;
11792 }
11793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11794         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
11795         int64_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11796         return ret_val;
11797 }
11798
11799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11800         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11801         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11802         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11803         return (uint64_t)ret_conv;
11804 }
11805
11806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11807         LDKTxCreationKeys o_conv;
11808         o_conv.inner = (void*)(o & (~1));
11809         o_conv.is_owned = (o & 1) || (o == 0);
11810         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11811         o_conv = TxCreationKeys_clone(&o_conv);
11812         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11813         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11814         return (uint64_t)ret_conv;
11815 }
11816
11817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11818         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11819         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11820         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11821         return (uint64_t)ret_conv;
11822 }
11823
11824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11825         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
11826         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11827         return ret_val;
11828 }
11829
11830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11831         if ((_res & 1) != 0) return;
11832         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11833         CHECK_ACCESS(_res_ptr);
11834         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11835         FREE((void*)_res);
11836         CResult_TxCreationKeysErrorZ_free(_res_conv);
11837 }
11838
11839 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11840         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11841         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11842         return (uint64_t)ret_conv;
11843 }
11844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11845         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11846         int64_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11847         return ret_val;
11848 }
11849
11850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11851         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11852         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11853         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11854         return (uint64_t)ret_conv;
11855 }
11856
11857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
11858         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11859         *ret_copy = COption_u32Z_some(o);
11860         uint64_t ret_ref = (uint64_t)ret_copy;
11861         return ret_ref;
11862 }
11863
11864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
11865         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11866         *ret_copy = COption_u32Z_none();
11867         uint64_t ret_ref = (uint64_t)ret_copy;
11868         return ret_ref;
11869 }
11870
11871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11872         if ((_res & 1) != 0) return;
11873         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11874         CHECK_ACCESS(_res_ptr);
11875         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11876         FREE((void*)_res);
11877         COption_u32Z_free(_res_conv);
11878 }
11879
11880 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11881         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11882         *ret_copy = COption_u32Z_clone(arg);
11883 uint64_t ret_ref = (uint64_t)ret_copy;
11884         return ret_ref;
11885 }
11886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11887         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11888         int64_t ret_val = COption_u32Z_clone_ptr(arg_conv);
11889         return ret_val;
11890 }
11891
11892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11893         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11894         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11895         *ret_copy = COption_u32Z_clone(orig_conv);
11896         uint64_t ret_ref = (uint64_t)ret_copy;
11897         return ret_ref;
11898 }
11899
11900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11901         LDKHTLCOutputInCommitment o_conv;
11902         o_conv.inner = (void*)(o & (~1));
11903         o_conv.is_owned = (o & 1) || (o == 0);
11904         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11905         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11906         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11907         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11908         return (uint64_t)ret_conv;
11909 }
11910
11911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11912         LDKDecodeError e_conv;
11913         e_conv.inner = (void*)(e & (~1));
11914         e_conv.is_owned = (e & 1) || (e == 0);
11915         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11916         e_conv = DecodeError_clone(&e_conv);
11917         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11918         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11919         return (uint64_t)ret_conv;
11920 }
11921
11922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11923         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11924         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11925         return ret_val;
11926 }
11927
11928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11929         if ((_res & 1) != 0) return;
11930         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11931         CHECK_ACCESS(_res_ptr);
11932         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11933         FREE((void*)_res);
11934         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11935 }
11936
11937 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11938         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11939         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11940         return (uint64_t)ret_conv;
11941 }
11942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11943         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11944         int64_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11945         return ret_val;
11946 }
11947
11948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11949         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11950         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11951         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11952         return (uint64_t)ret_conv;
11953 }
11954
11955 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
11956         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
11957         return ret_conv;
11958 }
11959
11960 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
11961         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
11962         return ret_conv;
11963 }
11964
11965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
11966         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
11967         COption_NoneZ_free(_res_conv);
11968 }
11969
11970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11971         LDKCounterpartyChannelTransactionParameters o_conv;
11972         o_conv.inner = (void*)(o & (~1));
11973         o_conv.is_owned = (o & 1) || (o == 0);
11974         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11975         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11976         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11977         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11978         return (uint64_t)ret_conv;
11979 }
11980
11981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11982         LDKDecodeError e_conv;
11983         e_conv.inner = (void*)(e & (~1));
11984         e_conv.is_owned = (e & 1) || (e == 0);
11985         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11986         e_conv = DecodeError_clone(&e_conv);
11987         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11988         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11989         return (uint64_t)ret_conv;
11990 }
11991
11992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11993         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11994         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11995         return ret_val;
11996 }
11997
11998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11999         if ((_res & 1) != 0) return;
12000         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12001         CHECK_ACCESS(_res_ptr);
12002         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
12003         FREE((void*)_res);
12004         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
12005 }
12006
12007 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
12008         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
12009         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
12010         return (uint64_t)ret_conv;
12011 }
12012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12013         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
12014         int64_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
12015         return ret_val;
12016 }
12017
12018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12019         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
12020         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
12021         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
12022         return (uint64_t)ret_conv;
12023 }
12024
12025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12026         LDKChannelTransactionParameters o_conv;
12027         o_conv.inner = (void*)(o & (~1));
12028         o_conv.is_owned = (o & 1) || (o == 0);
12029         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12030         o_conv = ChannelTransactionParameters_clone(&o_conv);
12031         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
12032         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
12033         return (uint64_t)ret_conv;
12034 }
12035
12036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12037         LDKDecodeError e_conv;
12038         e_conv.inner = (void*)(e & (~1));
12039         e_conv.is_owned = (e & 1) || (e == 0);
12040         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12041         e_conv = DecodeError_clone(&e_conv);
12042         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
12043         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
12044         return (uint64_t)ret_conv;
12045 }
12046
12047 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12048         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
12049         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
12050         return ret_val;
12051 }
12052
12053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12054         if ((_res & 1) != 0) return;
12055         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12056         CHECK_ACCESS(_res_ptr);
12057         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
12058         FREE((void*)_res);
12059         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
12060 }
12061
12062 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
12063         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
12064         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
12065         return (uint64_t)ret_conv;
12066 }
12067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12068         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
12069         int64_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
12070         return ret_val;
12071 }
12072
12073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12074         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
12075         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
12076         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
12077         return (uint64_t)ret_conv;
12078 }
12079
12080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12081         LDKCVec_SignatureZ _res_constr;
12082         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12083         if (_res_constr.datalen > 0)
12084                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12085         else
12086                 _res_constr.data = NULL;
12087         for (size_t i = 0; i < _res_constr.datalen; i++) {
12088                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
12089                 LDKSignature _res_conv_8_ref;
12090                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
12091                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
12092                 _res_constr.data[i] = _res_conv_8_ref;
12093         }
12094         CVec_SignatureZ_free(_res_constr);
12095 }
12096
12097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12098         LDKHolderCommitmentTransaction o_conv;
12099         o_conv.inner = (void*)(o & (~1));
12100         o_conv.is_owned = (o & 1) || (o == 0);
12101         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12102         o_conv = HolderCommitmentTransaction_clone(&o_conv);
12103         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12104         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
12105         return (uint64_t)ret_conv;
12106 }
12107
12108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12109         LDKDecodeError e_conv;
12110         e_conv.inner = (void*)(e & (~1));
12111         e_conv.is_owned = (e & 1) || (e == 0);
12112         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12113         e_conv = DecodeError_clone(&e_conv);
12114         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12115         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
12116         return (uint64_t)ret_conv;
12117 }
12118
12119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12120         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
12121         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12122         return ret_val;
12123 }
12124
12125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12126         if ((_res & 1) != 0) return;
12127         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12128         CHECK_ACCESS(_res_ptr);
12129         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
12130         FREE((void*)_res);
12131         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
12132 }
12133
12134 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12135         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12136         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
12137         return (uint64_t)ret_conv;
12138 }
12139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12140         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
12141         int64_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12142         return ret_val;
12143 }
12144
12145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12146         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
12147         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12148         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
12149         return (uint64_t)ret_conv;
12150 }
12151
12152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12153         LDKBuiltCommitmentTransaction o_conv;
12154         o_conv.inner = (void*)(o & (~1));
12155         o_conv.is_owned = (o & 1) || (o == 0);
12156         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12157         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
12158         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12159         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
12160         return (uint64_t)ret_conv;
12161 }
12162
12163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12164         LDKDecodeError e_conv;
12165         e_conv.inner = (void*)(e & (~1));
12166         e_conv.is_owned = (e & 1) || (e == 0);
12167         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12168         e_conv = DecodeError_clone(&e_conv);
12169         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12170         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
12171         return (uint64_t)ret_conv;
12172 }
12173
12174 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12175         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
12176         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12177         return ret_val;
12178 }
12179
12180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12181         if ((_res & 1) != 0) return;
12182         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12183         CHECK_ACCESS(_res_ptr);
12184         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
12185         FREE((void*)_res);
12186         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
12187 }
12188
12189 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12190         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12191         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
12192         return (uint64_t)ret_conv;
12193 }
12194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12195         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
12196         int64_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12197         return ret_val;
12198 }
12199
12200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12201         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
12202         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12203         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
12204         return (uint64_t)ret_conv;
12205 }
12206
12207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12208         LDKTrustedClosingTransaction o_conv;
12209         o_conv.inner = (void*)(o & (~1));
12210         o_conv.is_owned = (o & 1) || (o == 0);
12211         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12212         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
12213         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
12214         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
12215         return (uint64_t)ret_conv;
12216 }
12217
12218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
12219         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
12220         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
12221         return (uint64_t)ret_conv;
12222 }
12223
12224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12225         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
12226         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
12227         return ret_val;
12228 }
12229
12230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12231         if ((_res & 1) != 0) return;
12232         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12233         CHECK_ACCESS(_res_ptr);
12234         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
12235         FREE((void*)_res);
12236         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
12237 }
12238
12239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12240         LDKCommitmentTransaction o_conv;
12241         o_conv.inner = (void*)(o & (~1));
12242         o_conv.is_owned = (o & 1) || (o == 0);
12243         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12244         o_conv = CommitmentTransaction_clone(&o_conv);
12245         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12246         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
12247         return (uint64_t)ret_conv;
12248 }
12249
12250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12251         LDKDecodeError e_conv;
12252         e_conv.inner = (void*)(e & (~1));
12253         e_conv.is_owned = (e & 1) || (e == 0);
12254         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12255         e_conv = DecodeError_clone(&e_conv);
12256         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12257         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
12258         return (uint64_t)ret_conv;
12259 }
12260
12261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12262         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
12263         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12264         return ret_val;
12265 }
12266
12267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12268         if ((_res & 1) != 0) return;
12269         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12270         CHECK_ACCESS(_res_ptr);
12271         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
12272         FREE((void*)_res);
12273         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
12274 }
12275
12276 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12277         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12278         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
12279         return (uint64_t)ret_conv;
12280 }
12281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12282         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
12283         int64_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12284         return ret_val;
12285 }
12286
12287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12288         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
12289         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12290         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
12291         return (uint64_t)ret_conv;
12292 }
12293
12294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12295         LDKTrustedCommitmentTransaction o_conv;
12296         o_conv.inner = (void*)(o & (~1));
12297         o_conv.is_owned = (o & 1) || (o == 0);
12298         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12299         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
12300         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12301         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
12302         return (uint64_t)ret_conv;
12303 }
12304
12305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
12306         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12307         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
12308         return (uint64_t)ret_conv;
12309 }
12310
12311 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12312         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
12313         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
12314         return ret_val;
12315 }
12316
12317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12318         if ((_res & 1) != 0) return;
12319         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12320         CHECK_ACCESS(_res_ptr);
12321         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
12322         FREE((void*)_res);
12323         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
12324 }
12325
12326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
12327         LDKCVec_SignatureZ o_constr;
12328         o_constr.datalen = (*env)->GetArrayLength(env, o);
12329         if (o_constr.datalen > 0)
12330                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12331         else
12332                 o_constr.data = NULL;
12333         for (size_t i = 0; i < o_constr.datalen; i++) {
12334                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
12335                 LDKSignature o_conv_8_ref;
12336                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
12337                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
12338                 o_constr.data[i] = o_conv_8_ref;
12339         }
12340         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12341         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
12342         return (uint64_t)ret_conv;
12343 }
12344
12345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
12346         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12347         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
12348         return (uint64_t)ret_conv;
12349 }
12350
12351 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12352         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
12353         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
12354         return ret_val;
12355 }
12356
12357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12358         if ((_res & 1) != 0) return;
12359         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12360         CHECK_ACCESS(_res_ptr);
12361         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
12362         FREE((void*)_res);
12363         CResult_CVec_SignatureZNoneZ_free(_res_conv);
12364 }
12365
12366 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
12367         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12368         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
12369         return (uint64_t)ret_conv;
12370 }
12371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12372         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
12373         int64_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
12374         return ret_val;
12375 }
12376
12377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12378         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
12379         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12380         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
12381         return (uint64_t)ret_conv;
12382 }
12383
12384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12385         LDKShutdownScript o_conv;
12386         o_conv.inner = (void*)(o & (~1));
12387         o_conv.is_owned = (o & 1) || (o == 0);
12388         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12389         o_conv = ShutdownScript_clone(&o_conv);
12390         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12391         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
12392         return (uint64_t)ret_conv;
12393 }
12394
12395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12396         LDKDecodeError e_conv;
12397         e_conv.inner = (void*)(e & (~1));
12398         e_conv.is_owned = (e & 1) || (e == 0);
12399         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12400         e_conv = DecodeError_clone(&e_conv);
12401         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12402         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
12403         return (uint64_t)ret_conv;
12404 }
12405
12406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12407         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
12408         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
12409         return ret_val;
12410 }
12411
12412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12413         if ((_res & 1) != 0) return;
12414         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12415         CHECK_ACCESS(_res_ptr);
12416         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
12417         FREE((void*)_res);
12418         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
12419 }
12420
12421 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
12422         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12423         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
12424         return (uint64_t)ret_conv;
12425 }
12426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12427         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
12428         int64_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
12429         return ret_val;
12430 }
12431
12432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12433         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
12434         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12435         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
12436         return (uint64_t)ret_conv;
12437 }
12438
12439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12440         LDKShutdownScript o_conv;
12441         o_conv.inner = (void*)(o & (~1));
12442         o_conv.is_owned = (o & 1) || (o == 0);
12443         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12444         o_conv = ShutdownScript_clone(&o_conv);
12445         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12446         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
12447         return (uint64_t)ret_conv;
12448 }
12449
12450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12451         LDKInvalidShutdownScript e_conv;
12452         e_conv.inner = (void*)(e & (~1));
12453         e_conv.is_owned = (e & 1) || (e == 0);
12454         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12455         e_conv = InvalidShutdownScript_clone(&e_conv);
12456         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12457         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
12458         return (uint64_t)ret_conv;
12459 }
12460
12461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12462         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
12463         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
12464         return ret_val;
12465 }
12466
12467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12468         if ((_res & 1) != 0) return;
12469         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12470         CHECK_ACCESS(_res_ptr);
12471         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
12472         FREE((void*)_res);
12473         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
12474 }
12475
12476 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
12477         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12478         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
12479         return (uint64_t)ret_conv;
12480 }
12481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12482         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
12483         int64_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
12484         return ret_val;
12485 }
12486
12487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12488         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
12489         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12490         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
12491         return (uint64_t)ret_conv;
12492 }
12493
12494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
12495         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12496         *ret_conv = CResult_NoneErrorZ_ok();
12497         return (uint64_t)ret_conv;
12498 }
12499
12500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12501         LDKIOError e_conv = LDKIOError_from_java(env, e);
12502         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12503         *ret_conv = CResult_NoneErrorZ_err(e_conv);
12504         return (uint64_t)ret_conv;
12505 }
12506
12507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12508         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
12509         jboolean ret_val = CResult_NoneErrorZ_is_ok(o_conv);
12510         return ret_val;
12511 }
12512
12513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12514         if ((_res & 1) != 0) return;
12515         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12516         CHECK_ACCESS(_res_ptr);
12517         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
12518         FREE((void*)_res);
12519         CResult_NoneErrorZ_free(_res_conv);
12520 }
12521
12522 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
12523         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12524         *ret_conv = CResult_NoneErrorZ_clone(arg);
12525         return (uint64_t)ret_conv;
12526 }
12527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12528         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
12529         int64_t ret_val = CResult_NoneErrorZ_clone_ptr(arg_conv);
12530         return ret_val;
12531 }
12532
12533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12534         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
12535         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12536         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
12537         return (uint64_t)ret_conv;
12538 }
12539
12540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12541         LDKRouteHop o_conv;
12542         o_conv.inner = (void*)(o & (~1));
12543         o_conv.is_owned = (o & 1) || (o == 0);
12544         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12545         o_conv = RouteHop_clone(&o_conv);
12546         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12547         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12548         return (uint64_t)ret_conv;
12549 }
12550
12551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12552         LDKDecodeError e_conv;
12553         e_conv.inner = (void*)(e & (~1));
12554         e_conv.is_owned = (e & 1) || (e == 0);
12555         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12556         e_conv = DecodeError_clone(&e_conv);
12557         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12558         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12559         return (uint64_t)ret_conv;
12560 }
12561
12562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12563         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
12564         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
12565         return ret_val;
12566 }
12567
12568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12569         if ((_res & 1) != 0) return;
12570         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12571         CHECK_ACCESS(_res_ptr);
12572         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12573         FREE((void*)_res);
12574         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12575 }
12576
12577 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12578         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12579         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12580         return (uint64_t)ret_conv;
12581 }
12582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12583         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
12584         int64_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12585         return ret_val;
12586 }
12587
12588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12589         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12590         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12591         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12592         return (uint64_t)ret_conv;
12593 }
12594
12595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12596         LDKCVec_RouteHopZ _res_constr;
12597         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12598         if (_res_constr.datalen > 0)
12599                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12600         else
12601                 _res_constr.data = NULL;
12602         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12603         for (size_t k = 0; k < _res_constr.datalen; k++) {
12604                 int64_t _res_conv_10 = _res_vals[k];
12605                 LDKRouteHop _res_conv_10_conv;
12606                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12607                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12608                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12609                 _res_constr.data[k] = _res_conv_10_conv;
12610         }
12611         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12612         CVec_RouteHopZ_free(_res_constr);
12613 }
12614
12615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12616         LDKCVec_CVec_RouteHopZZ _res_constr;
12617         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12618         if (_res_constr.datalen > 0)
12619                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12620         else
12621                 _res_constr.data = NULL;
12622         for (size_t m = 0; m < _res_constr.datalen; m++) {
12623                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
12624                 LDKCVec_RouteHopZ _res_conv_12_constr;
12625                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
12626                 if (_res_conv_12_constr.datalen > 0)
12627                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12628                 else
12629                         _res_conv_12_constr.data = NULL;
12630                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
12631                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12632                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12633                         LDKRouteHop _res_conv_12_conv_10_conv;
12634                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12635                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12636                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12637                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12638                 }
12639                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
12640                 _res_constr.data[m] = _res_conv_12_constr;
12641         }
12642         CVec_CVec_RouteHopZZ_free(_res_constr);
12643 }
12644
12645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12646         LDKRoute o_conv;
12647         o_conv.inner = (void*)(o & (~1));
12648         o_conv.is_owned = (o & 1) || (o == 0);
12649         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12650         o_conv = Route_clone(&o_conv);
12651         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12652         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12653         return (uint64_t)ret_conv;
12654 }
12655
12656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12657         LDKDecodeError e_conv;
12658         e_conv.inner = (void*)(e & (~1));
12659         e_conv.is_owned = (e & 1) || (e == 0);
12660         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12661         e_conv = DecodeError_clone(&e_conv);
12662         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12663         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12664         return (uint64_t)ret_conv;
12665 }
12666
12667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12668         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
12669         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12670         return ret_val;
12671 }
12672
12673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12674         if ((_res & 1) != 0) return;
12675         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12676         CHECK_ACCESS(_res_ptr);
12677         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12678         FREE((void*)_res);
12679         CResult_RouteDecodeErrorZ_free(_res_conv);
12680 }
12681
12682 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12683         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12684         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12685         return (uint64_t)ret_conv;
12686 }
12687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12688         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
12689         int64_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12690         return ret_val;
12691 }
12692
12693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12694         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12695         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12696         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12697         return (uint64_t)ret_conv;
12698 }
12699
12700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12701         LDKRouteParameters o_conv;
12702         o_conv.inner = (void*)(o & (~1));
12703         o_conv.is_owned = (o & 1) || (o == 0);
12704         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12705         o_conv = RouteParameters_clone(&o_conv);
12706         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12707         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12708         return (uint64_t)ret_conv;
12709 }
12710
12711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12712         LDKDecodeError e_conv;
12713         e_conv.inner = (void*)(e & (~1));
12714         e_conv.is_owned = (e & 1) || (e == 0);
12715         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12716         e_conv = DecodeError_clone(&e_conv);
12717         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12718         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12719         return (uint64_t)ret_conv;
12720 }
12721
12722 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12723         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
12724         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12725         return ret_val;
12726 }
12727
12728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12729         if ((_res & 1) != 0) return;
12730         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12731         CHECK_ACCESS(_res_ptr);
12732         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12733         FREE((void*)_res);
12734         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12735 }
12736
12737 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12738         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12739         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12740         return (uint64_t)ret_conv;
12741 }
12742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12743         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
12744         int64_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12745         return ret_val;
12746 }
12747
12748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12749         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12750         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12751         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12752         return (uint64_t)ret_conv;
12753 }
12754
12755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12756         LDKCVec_RouteHintZ _res_constr;
12757         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12758         if (_res_constr.datalen > 0)
12759                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12760         else
12761                 _res_constr.data = NULL;
12762         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12763         for (size_t l = 0; l < _res_constr.datalen; l++) {
12764                 int64_t _res_conv_11 = _res_vals[l];
12765                 LDKRouteHint _res_conv_11_conv;
12766                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12767                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12768                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12769                 _res_constr.data[l] = _res_conv_11_conv;
12770         }
12771         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12772         CVec_RouteHintZ_free(_res_constr);
12773 }
12774
12775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
12776         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12777         *ret_copy = COption_u64Z_some(o);
12778         uint64_t ret_ref = (uint64_t)ret_copy;
12779         return ret_ref;
12780 }
12781
12782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
12783         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12784         *ret_copy = COption_u64Z_none();
12785         uint64_t ret_ref = (uint64_t)ret_copy;
12786         return ret_ref;
12787 }
12788
12789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12790         if ((_res & 1) != 0) return;
12791         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12792         CHECK_ACCESS(_res_ptr);
12793         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12794         FREE((void*)_res);
12795         COption_u64Z_free(_res_conv);
12796 }
12797
12798 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12799         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12800         *ret_copy = COption_u64Z_clone(arg);
12801 uint64_t ret_ref = (uint64_t)ret_copy;
12802         return ret_ref;
12803 }
12804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12805         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
12806         int64_t ret_val = COption_u64Z_clone_ptr(arg_conv);
12807         return ret_val;
12808 }
12809
12810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12811         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12812         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12813         *ret_copy = COption_u64Z_clone(orig_conv);
12814         uint64_t ret_ref = (uint64_t)ret_copy;
12815         return ret_ref;
12816 }
12817
12818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12819         LDKPayee o_conv;
12820         o_conv.inner = (void*)(o & (~1));
12821         o_conv.is_owned = (o & 1) || (o == 0);
12822         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12823         o_conv = Payee_clone(&o_conv);
12824         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12825         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
12826         return (uint64_t)ret_conv;
12827 }
12828
12829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12830         LDKDecodeError e_conv;
12831         e_conv.inner = (void*)(e & (~1));
12832         e_conv.is_owned = (e & 1) || (e == 0);
12833         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12834         e_conv = DecodeError_clone(&e_conv);
12835         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12836         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
12837         return (uint64_t)ret_conv;
12838 }
12839
12840 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12841         LDKCResult_PayeeDecodeErrorZ* o_conv = (LDKCResult_PayeeDecodeErrorZ*)(o & ~1);
12842         jboolean ret_val = CResult_PayeeDecodeErrorZ_is_ok(o_conv);
12843         return ret_val;
12844 }
12845
12846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12847         if ((_res & 1) != 0) return;
12848         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12849         CHECK_ACCESS(_res_ptr);
12850         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
12851         FREE((void*)_res);
12852         CResult_PayeeDecodeErrorZ_free(_res_conv);
12853 }
12854
12855 static inline uint64_t CResult_PayeeDecodeErrorZ_clone_ptr(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR arg) {
12856         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12857         *ret_conv = CResult_PayeeDecodeErrorZ_clone(arg);
12858         return (uint64_t)ret_conv;
12859 }
12860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12861         LDKCResult_PayeeDecodeErrorZ* arg_conv = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
12862         int64_t ret_val = CResult_PayeeDecodeErrorZ_clone_ptr(arg_conv);
12863         return ret_val;
12864 }
12865
12866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12867         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
12868         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12869         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
12870         return (uint64_t)ret_conv;
12871 }
12872
12873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12874         LDKCVec_RouteHintHopZ _res_constr;
12875         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12876         if (_res_constr.datalen > 0)
12877                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12878         else
12879                 _res_constr.data = NULL;
12880         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12881         for (size_t o = 0; o < _res_constr.datalen; o++) {
12882                 int64_t _res_conv_14 = _res_vals[o];
12883                 LDKRouteHintHop _res_conv_14_conv;
12884                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12885                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12886                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12887                 _res_constr.data[o] = _res_conv_14_conv;
12888         }
12889         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12890         CVec_RouteHintHopZ_free(_res_constr);
12891 }
12892
12893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12894         LDKRouteHint o_conv;
12895         o_conv.inner = (void*)(o & (~1));
12896         o_conv.is_owned = (o & 1) || (o == 0);
12897         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12898         o_conv = RouteHint_clone(&o_conv);
12899         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12900         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12901         return (uint64_t)ret_conv;
12902 }
12903
12904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12905         LDKDecodeError e_conv;
12906         e_conv.inner = (void*)(e & (~1));
12907         e_conv.is_owned = (e & 1) || (e == 0);
12908         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12909         e_conv = DecodeError_clone(&e_conv);
12910         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12911         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12912         return (uint64_t)ret_conv;
12913 }
12914
12915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12916         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12917         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12918         return ret_val;
12919 }
12920
12921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12922         if ((_res & 1) != 0) return;
12923         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12924         CHECK_ACCESS(_res_ptr);
12925         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12926         FREE((void*)_res);
12927         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12928 }
12929
12930 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12931         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12932         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12933         return (uint64_t)ret_conv;
12934 }
12935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12936         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12937         int64_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12938         return ret_val;
12939 }
12940
12941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12942         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12943         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12944         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12945         return (uint64_t)ret_conv;
12946 }
12947
12948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12949         LDKRouteHintHop o_conv;
12950         o_conv.inner = (void*)(o & (~1));
12951         o_conv.is_owned = (o & 1) || (o == 0);
12952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12953         o_conv = RouteHintHop_clone(&o_conv);
12954         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12955         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12956         return (uint64_t)ret_conv;
12957 }
12958
12959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12960         LDKDecodeError e_conv;
12961         e_conv.inner = (void*)(e & (~1));
12962         e_conv.is_owned = (e & 1) || (e == 0);
12963         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12964         e_conv = DecodeError_clone(&e_conv);
12965         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12966         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12967         return (uint64_t)ret_conv;
12968 }
12969
12970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12971         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12972         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12973         return ret_val;
12974 }
12975
12976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12977         if ((_res & 1) != 0) return;
12978         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12979         CHECK_ACCESS(_res_ptr);
12980         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12981         FREE((void*)_res);
12982         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12983 }
12984
12985 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12986         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12987         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12988         return (uint64_t)ret_conv;
12989 }
12990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12991         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12992         int64_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12993         return ret_val;
12994 }
12995
12996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12997         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12998         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12999         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
13000         return (uint64_t)ret_conv;
13001 }
13002
13003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13004         LDKCVec_ChannelDetailsZ _res_constr;
13005         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13006         if (_res_constr.datalen > 0)
13007                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13008         else
13009                 _res_constr.data = NULL;
13010         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13011         for (size_t q = 0; q < _res_constr.datalen; q++) {
13012                 int64_t _res_conv_16 = _res_vals[q];
13013                 LDKChannelDetails _res_conv_16_conv;
13014                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
13015                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
13016                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
13017                 _res_constr.data[q] = _res_conv_16_conv;
13018         }
13019         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13020         CVec_ChannelDetailsZ_free(_res_constr);
13021 }
13022
13023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13024         LDKRoute o_conv;
13025         o_conv.inner = (void*)(o & (~1));
13026         o_conv.is_owned = (o & 1) || (o == 0);
13027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13028         o_conv = Route_clone(&o_conv);
13029         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
13030         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
13031         return (uint64_t)ret_conv;
13032 }
13033
13034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13035         LDKLightningError e_conv;
13036         e_conv.inner = (void*)(e & (~1));
13037         e_conv.is_owned = (e & 1) || (e == 0);
13038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13039         e_conv = LightningError_clone(&e_conv);
13040         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
13041         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
13042         return (uint64_t)ret_conv;
13043 }
13044
13045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13046         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
13047         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
13048         return ret_val;
13049 }
13050
13051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13052         if ((_res & 1) != 0) return;
13053         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13054         CHECK_ACCESS(_res_ptr);
13055         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
13056         FREE((void*)_res);
13057         CResult_RouteLightningErrorZ_free(_res_conv);
13058 }
13059
13060 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
13061         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
13062         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
13063         return (uint64_t)ret_conv;
13064 }
13065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13066         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
13067         int64_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
13068         return ret_val;
13069 }
13070
13071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13072         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
13073         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
13074         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
13075         return (uint64_t)ret_conv;
13076 }
13077
13078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13079         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13080         CHECK_ACCESS(o_ptr);
13081         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
13082         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
13083         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13084         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
13085         return (uint64_t)ret_conv;
13086 }
13087
13088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13089         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
13090         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13091         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
13092         return (uint64_t)ret_conv;
13093 }
13094
13095 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13096         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
13097         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
13098         return ret_val;
13099 }
13100
13101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13102         if ((_res & 1) != 0) return;
13103         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13104         CHECK_ACCESS(_res_ptr);
13105         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
13106         FREE((void*)_res);
13107         CResult_TxOutAccessErrorZ_free(_res_conv);
13108 }
13109
13110 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
13111         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13112         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
13113         return (uint64_t)ret_conv;
13114 }
13115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13116         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
13117         int64_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
13118         return ret_val;
13119 }
13120
13121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13122         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
13123         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13124         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
13125         return (uint64_t)ret_conv;
13126 }
13127
13128 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
13129         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13130         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
13131         return ((uint64_t)ret_conv);
13132 }
13133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13134         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
13135         int64_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
13136         return ret_val;
13137 }
13138
13139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13140         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
13141         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13142         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
13143         return ((uint64_t)ret_conv);
13144 }
13145
13146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
13147         LDKTransaction b_ref;
13148         b_ref.datalen = (*env)->GetArrayLength(env, b);
13149         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
13150         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
13151         b_ref.data_is_owned = true;
13152         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13153         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
13154         return ((uint64_t)ret_conv);
13155 }
13156
13157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13158         if ((_res & 1) != 0) return;
13159         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13160         CHECK_ACCESS(_res_ptr);
13161         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
13162         FREE((void*)_res);
13163         C2Tuple_usizeTransactionZ_free(_res_conv);
13164 }
13165
13166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13167         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
13168         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13169         if (_res_constr.datalen > 0)
13170                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13171         else
13172                 _res_constr.data = NULL;
13173         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13174         for (size_t c = 0; c < _res_constr.datalen; c++) {
13175                 int64_t _res_conv_28 = _res_vals[c];
13176                 void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
13177                 CHECK_ACCESS(_res_conv_28_ptr);
13178                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
13179                 FREE((void*)_res_conv_28);
13180                 _res_constr.data[c] = _res_conv_28_conv;
13181         }
13182         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13183         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
13184 }
13185
13186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13187         LDKCVec_TxidZ _res_constr;
13188         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13189         if (_res_constr.datalen > 0)
13190                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
13191         else
13192                 _res_constr.data = NULL;
13193         for (size_t i = 0; i < _res_constr.datalen; i++) {
13194                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13195                 LDKThirtyTwoBytes _res_conv_8_ref;
13196                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
13197                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
13198                 _res_constr.data[i] = _res_conv_8_ref;
13199         }
13200         CVec_TxidZ_free(_res_constr);
13201 }
13202
13203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
13204         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13205         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
13206         return (uint64_t)ret_conv;
13207 }
13208
13209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
13210         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
13211         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13212         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
13213         return (uint64_t)ret_conv;
13214 }
13215
13216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13217         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
13218         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
13219         return ret_val;
13220 }
13221
13222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13223         if ((_res & 1) != 0) return;
13224         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13225         CHECK_ACCESS(_res_ptr);
13226         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
13227         FREE((void*)_res);
13228         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
13229 }
13230
13231 static inline uint64_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
13232         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13233         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
13234         return (uint64_t)ret_conv;
13235 }
13236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13237         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
13238         int64_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
13239         return ret_val;
13240 }
13241
13242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13243         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
13244         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13245         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
13246         return (uint64_t)ret_conv;
13247 }
13248
13249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13250         LDKCVec_MonitorEventZ _res_constr;
13251         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13252         if (_res_constr.datalen > 0)
13253                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13254         else
13255                 _res_constr.data = NULL;
13256         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13257         for (size_t o = 0; o < _res_constr.datalen; o++) {
13258                 int64_t _res_conv_14 = _res_vals[o];
13259                 void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
13260                 CHECK_ACCESS(_res_conv_14_ptr);
13261                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
13262                 FREE((void*)_res_conv_14);
13263                 _res_constr.data[o] = _res_conv_14_conv;
13264         }
13265         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13266         CVec_MonitorEventZ_free(_res_constr);
13267 }
13268
13269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
13270         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13271         CHECK_ACCESS(o_ptr);
13272         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
13273         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
13274         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13275         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
13276         uint64_t ret_ref = (uint64_t)ret_copy;
13277         return ret_ref;
13278 }
13279
13280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
13281         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13282         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
13283         uint64_t ret_ref = (uint64_t)ret_copy;
13284         return ret_ref;
13285 }
13286
13287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13288         if ((_res & 1) != 0) return;
13289         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13290         CHECK_ACCESS(_res_ptr);
13291         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
13292         FREE((void*)_res);
13293         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
13294 }
13295
13296 static inline uint64_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
13297         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13298         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
13299 uint64_t ret_ref = (uint64_t)ret_copy;
13300         return ret_ref;
13301 }
13302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13303         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
13304         int64_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
13305         return ret_val;
13306 }
13307
13308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13309         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
13310         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13311         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
13312         uint64_t ret_ref = (uint64_t)ret_copy;
13313         return ret_ref;
13314 }
13315
13316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
13317         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13318         CHECK_ACCESS(o_ptr);
13319         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
13320         o_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)o) & ~1));
13321         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13322         *ret_copy = COption_ClosureReasonZ_some(o_conv);
13323         uint64_t ret_ref = (uint64_t)ret_copy;
13324         return ret_ref;
13325 }
13326
13327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
13328         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13329         *ret_copy = COption_ClosureReasonZ_none();
13330         uint64_t ret_ref = (uint64_t)ret_copy;
13331         return ret_ref;
13332 }
13333
13334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13335         if ((_res & 1) != 0) return;
13336         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13337         CHECK_ACCESS(_res_ptr);
13338         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
13339         FREE((void*)_res);
13340         COption_ClosureReasonZ_free(_res_conv);
13341 }
13342
13343 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
13344         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13345         *ret_copy = COption_ClosureReasonZ_clone(arg);
13346 uint64_t ret_ref = (uint64_t)ret_copy;
13347         return ret_ref;
13348 }
13349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13350         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
13351         int64_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
13352         return ret_val;
13353 }
13354
13355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13356         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
13357         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13358         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
13359         uint64_t ret_ref = (uint64_t)ret_copy;
13360         return ret_ref;
13361 }
13362
13363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13364         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13365         CHECK_ACCESS(o_ptr);
13366         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
13367         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uint64_t)o) & ~1));
13368         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13369         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
13370         return (uint64_t)ret_conv;
13371 }
13372
13373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13374         LDKDecodeError e_conv;
13375         e_conv.inner = (void*)(e & (~1));
13376         e_conv.is_owned = (e & 1) || (e == 0);
13377         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13378         e_conv = DecodeError_clone(&e_conv);
13379         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13380         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
13381         return (uint64_t)ret_conv;
13382 }
13383
13384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13385         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
13386         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
13387         return ret_val;
13388 }
13389
13390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13391         if ((_res & 1) != 0) return;
13392         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13393         CHECK_ACCESS(_res_ptr);
13394         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
13395         FREE((void*)_res);
13396         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
13397 }
13398
13399 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
13400         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13401         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
13402         return (uint64_t)ret_conv;
13403 }
13404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13405         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
13406         int64_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
13407         return ret_val;
13408 }
13409
13410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13411         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
13412         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13413         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
13414         return (uint64_t)ret_conv;
13415 }
13416
13417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
13418         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13419         CHECK_ACCESS(o_ptr);
13420         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
13421         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
13422         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13423         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
13424         uint64_t ret_ref = (uint64_t)ret_copy;
13425         return ret_ref;
13426 }
13427
13428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
13429         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13430         *ret_copy = COption_NetworkUpdateZ_none();
13431         uint64_t ret_ref = (uint64_t)ret_copy;
13432         return ret_ref;
13433 }
13434
13435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13436         if ((_res & 1) != 0) return;
13437         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13438         CHECK_ACCESS(_res_ptr);
13439         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
13440         FREE((void*)_res);
13441         COption_NetworkUpdateZ_free(_res_conv);
13442 }
13443
13444 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
13445         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13446         *ret_copy = COption_NetworkUpdateZ_clone(arg);
13447 uint64_t ret_ref = (uint64_t)ret_copy;
13448         return ret_ref;
13449 }
13450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13451         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
13452         int64_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
13453         return ret_val;
13454 }
13455
13456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13457         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
13458         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13459         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
13460         uint64_t ret_ref = (uint64_t)ret_copy;
13461         return ret_ref;
13462 }
13463
13464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13465         LDKCVec_SpendableOutputDescriptorZ _res_constr;
13466         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13467         if (_res_constr.datalen > 0)
13468                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13469         else
13470                 _res_constr.data = NULL;
13471         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13472         for (size_t b = 0; b < _res_constr.datalen; b++) {
13473                 int64_t _res_conv_27 = _res_vals[b];
13474                 void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
13475                 CHECK_ACCESS(_res_conv_27_ptr);
13476                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
13477                 FREE((void*)_res_conv_27);
13478                 _res_constr.data[b] = _res_conv_27_conv;
13479         }
13480         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13481         CVec_SpendableOutputDescriptorZ_free(_res_constr);
13482 }
13483
13484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
13485         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13486         CHECK_ACCESS(o_ptr);
13487         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
13488         o_conv = Event_clone((LDKEvent*)(((uint64_t)o) & ~1));
13489         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13490         *ret_copy = COption_EventZ_some(o_conv);
13491         uint64_t ret_ref = (uint64_t)ret_copy;
13492         return ret_ref;
13493 }
13494
13495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
13496         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13497         *ret_copy = COption_EventZ_none();
13498         uint64_t ret_ref = (uint64_t)ret_copy;
13499         return ret_ref;
13500 }
13501
13502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13503         if ((_res & 1) != 0) return;
13504         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13505         CHECK_ACCESS(_res_ptr);
13506         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
13507         FREE((void*)_res);
13508         COption_EventZ_free(_res_conv);
13509 }
13510
13511 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
13512         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13513         *ret_copy = COption_EventZ_clone(arg);
13514 uint64_t ret_ref = (uint64_t)ret_copy;
13515         return ret_ref;
13516 }
13517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13518         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
13519         int64_t ret_val = COption_EventZ_clone_ptr(arg_conv);
13520         return ret_val;
13521 }
13522
13523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13524         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
13525         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13526         *ret_copy = COption_EventZ_clone(orig_conv);
13527         uint64_t ret_ref = (uint64_t)ret_copy;
13528         return ret_ref;
13529 }
13530
13531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13532         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13533         CHECK_ACCESS(o_ptr);
13534         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
13535         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uint64_t)o) & ~1));
13536         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13537         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
13538         return (uint64_t)ret_conv;
13539 }
13540
13541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13542         LDKDecodeError e_conv;
13543         e_conv.inner = (void*)(e & (~1));
13544         e_conv.is_owned = (e & 1) || (e == 0);
13545         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13546         e_conv = DecodeError_clone(&e_conv);
13547         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13548         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
13549         return (uint64_t)ret_conv;
13550 }
13551
13552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13553         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
13554         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
13555         return ret_val;
13556 }
13557
13558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13559         if ((_res & 1) != 0) return;
13560         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13561         CHECK_ACCESS(_res_ptr);
13562         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
13563         FREE((void*)_res);
13564         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
13565 }
13566
13567 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
13568         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13569         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
13570         return (uint64_t)ret_conv;
13571 }
13572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13573         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
13574         int64_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
13575         return ret_val;
13576 }
13577
13578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13579         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
13580         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13581         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
13582         return (uint64_t)ret_conv;
13583 }
13584
13585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13586         LDKCVec_MessageSendEventZ _res_constr;
13587         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13588         if (_res_constr.datalen > 0)
13589                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
13590         else
13591                 _res_constr.data = NULL;
13592         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13593         for (size_t s = 0; s < _res_constr.datalen; s++) {
13594                 int64_t _res_conv_18 = _res_vals[s];
13595                 void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
13596                 CHECK_ACCESS(_res_conv_18_ptr);
13597                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
13598                 FREE((void*)_res_conv_18);
13599                 _res_constr.data[s] = _res_conv_18_conv;
13600         }
13601         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13602         CVec_MessageSendEventZ_free(_res_constr);
13603 }
13604
13605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13606         LDKScoringParameters o_conv;
13607         o_conv.inner = (void*)(o & (~1));
13608         o_conv.is_owned = (o & 1) || (o == 0);
13609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13610         // Warning: we need a move here but no clone is available for LDKScoringParameters
13611         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
13612         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
13613         return (uint64_t)ret_conv;
13614 }
13615
13616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13617         LDKDecodeError e_conv;
13618         e_conv.inner = (void*)(e & (~1));
13619         e_conv.is_owned = (e & 1) || (e == 0);
13620         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13621         e_conv = DecodeError_clone(&e_conv);
13622         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
13623         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
13624         return (uint64_t)ret_conv;
13625 }
13626
13627 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13628         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
13629         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
13630         return ret_val;
13631 }
13632
13633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13634         if ((_res & 1) != 0) return;
13635         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13636         CHECK_ACCESS(_res_ptr);
13637         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
13638         FREE((void*)_res);
13639         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
13640 }
13641
13642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13643         LDKScorer o_conv;
13644         o_conv.inner = (void*)(o & (~1));
13645         o_conv.is_owned = (o & 1) || (o == 0);
13646         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13647         // Warning: we need a move here but no clone is available for LDKScorer
13648         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
13649         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
13650         return (uint64_t)ret_conv;
13651 }
13652
13653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13654         LDKDecodeError e_conv;
13655         e_conv.inner = (void*)(e & (~1));
13656         e_conv.is_owned = (e & 1) || (e == 0);
13657         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13658         e_conv = DecodeError_clone(&e_conv);
13659         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
13660         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
13661         return (uint64_t)ret_conv;
13662 }
13663
13664 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13665         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
13666         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
13667         return ret_val;
13668 }
13669
13670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13671         if ((_res & 1) != 0) return;
13672         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13673         CHECK_ACCESS(_res_ptr);
13674         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
13675         FREE((void*)_res);
13676         CResult_ScorerDecodeErrorZ_free(_res_conv);
13677 }
13678
13679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13680         LDKInitFeatures o_conv;
13681         o_conv.inner = (void*)(o & (~1));
13682         o_conv.is_owned = (o & 1) || (o == 0);
13683         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13684         o_conv = InitFeatures_clone(&o_conv);
13685         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13686         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13687         return (uint64_t)ret_conv;
13688 }
13689
13690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13691         LDKDecodeError e_conv;
13692         e_conv.inner = (void*)(e & (~1));
13693         e_conv.is_owned = (e & 1) || (e == 0);
13694         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13695         e_conv = DecodeError_clone(&e_conv);
13696         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13697         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13698         return (uint64_t)ret_conv;
13699 }
13700
13701 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13702         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
13703         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13704         return ret_val;
13705 }
13706
13707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13708         if ((_res & 1) != 0) return;
13709         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13710         CHECK_ACCESS(_res_ptr);
13711         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13712         FREE((void*)_res);
13713         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13714 }
13715
13716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13717         LDKChannelFeatures o_conv;
13718         o_conv.inner = (void*)(o & (~1));
13719         o_conv.is_owned = (o & 1) || (o == 0);
13720         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13721         o_conv = ChannelFeatures_clone(&o_conv);
13722         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13723         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13724         return (uint64_t)ret_conv;
13725 }
13726
13727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13728         LDKDecodeError e_conv;
13729         e_conv.inner = (void*)(e & (~1));
13730         e_conv.is_owned = (e & 1) || (e == 0);
13731         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13732         e_conv = DecodeError_clone(&e_conv);
13733         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13734         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13735         return (uint64_t)ret_conv;
13736 }
13737
13738 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13739         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
13740         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13741         return ret_val;
13742 }
13743
13744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13745         if ((_res & 1) != 0) return;
13746         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13747         CHECK_ACCESS(_res_ptr);
13748         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13749         FREE((void*)_res);
13750         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13751 }
13752
13753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13754         LDKNodeFeatures o_conv;
13755         o_conv.inner = (void*)(o & (~1));
13756         o_conv.is_owned = (o & 1) || (o == 0);
13757         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13758         o_conv = NodeFeatures_clone(&o_conv);
13759         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13760         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
13761         return (uint64_t)ret_conv;
13762 }
13763
13764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13765         LDKDecodeError e_conv;
13766         e_conv.inner = (void*)(e & (~1));
13767         e_conv.is_owned = (e & 1) || (e == 0);
13768         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13769         e_conv = DecodeError_clone(&e_conv);
13770         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13771         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
13772         return (uint64_t)ret_conv;
13773 }
13774
13775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13776         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
13777         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
13778         return ret_val;
13779 }
13780
13781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13782         if ((_res & 1) != 0) return;
13783         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13784         CHECK_ACCESS(_res_ptr);
13785         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
13786         FREE((void*)_res);
13787         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
13788 }
13789
13790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13791         LDKInvoiceFeatures o_conv;
13792         o_conv.inner = (void*)(o & (~1));
13793         o_conv.is_owned = (o & 1) || (o == 0);
13794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13795         o_conv = InvoiceFeatures_clone(&o_conv);
13796         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13797         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
13798         return (uint64_t)ret_conv;
13799 }
13800
13801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13802         LDKDecodeError e_conv;
13803         e_conv.inner = (void*)(e & (~1));
13804         e_conv.is_owned = (e & 1) || (e == 0);
13805         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13806         e_conv = DecodeError_clone(&e_conv);
13807         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13808         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
13809         return (uint64_t)ret_conv;
13810 }
13811
13812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13813         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
13814         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
13815         return ret_val;
13816 }
13817
13818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13819         if ((_res & 1) != 0) return;
13820         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13821         CHECK_ACCESS(_res_ptr);
13822         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
13823         FREE((void*)_res);
13824         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
13825 }
13826
13827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13828         LDKChannelTypeFeatures o_conv;
13829         o_conv.inner = (void*)(o & (~1));
13830         o_conv.is_owned = (o & 1) || (o == 0);
13831         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13832         o_conv = ChannelTypeFeatures_clone(&o_conv);
13833         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13834         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
13835         return (uint64_t)ret_conv;
13836 }
13837
13838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13839         LDKDecodeError e_conv;
13840         e_conv.inner = (void*)(e & (~1));
13841         e_conv.is_owned = (e & 1) || (e == 0);
13842         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13843         e_conv = DecodeError_clone(&e_conv);
13844         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13845         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13846         return (uint64_t)ret_conv;
13847 }
13848
13849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13850         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13851         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13852         return ret_val;
13853 }
13854
13855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13856         if ((_res & 1) != 0) return;
13857         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13858         CHECK_ACCESS(_res_ptr);
13859         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13860         FREE((void*)_res);
13861         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13862 }
13863
13864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13865         LDKDelayedPaymentOutputDescriptor o_conv;
13866         o_conv.inner = (void*)(o & (~1));
13867         o_conv.is_owned = (o & 1) || (o == 0);
13868         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13869         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
13870         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13871         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13872         return (uint64_t)ret_conv;
13873 }
13874
13875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13876         LDKDecodeError e_conv;
13877         e_conv.inner = (void*)(e & (~1));
13878         e_conv.is_owned = (e & 1) || (e == 0);
13879         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13880         e_conv = DecodeError_clone(&e_conv);
13881         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13882         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13883         return (uint64_t)ret_conv;
13884 }
13885
13886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13887         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13888         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13889         return ret_val;
13890 }
13891
13892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13893         if ((_res & 1) != 0) return;
13894         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13895         CHECK_ACCESS(_res_ptr);
13896         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13897         FREE((void*)_res);
13898         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13899 }
13900
13901 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13902         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13903         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13904         return (uint64_t)ret_conv;
13905 }
13906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13907         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13908         int64_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13909         return ret_val;
13910 }
13911
13912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13913         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13914         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13915         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13916         return (uint64_t)ret_conv;
13917 }
13918
13919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13920         LDKStaticPaymentOutputDescriptor o_conv;
13921         o_conv.inner = (void*)(o & (~1));
13922         o_conv.is_owned = (o & 1) || (o == 0);
13923         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13924         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
13925         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13926         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13927         return (uint64_t)ret_conv;
13928 }
13929
13930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13931         LDKDecodeError e_conv;
13932         e_conv.inner = (void*)(e & (~1));
13933         e_conv.is_owned = (e & 1) || (e == 0);
13934         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13935         e_conv = DecodeError_clone(&e_conv);
13936         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13937         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13938         return (uint64_t)ret_conv;
13939 }
13940
13941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13942         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13943         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13944         return ret_val;
13945 }
13946
13947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13948         if ((_res & 1) != 0) return;
13949         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13950         CHECK_ACCESS(_res_ptr);
13951         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13952         FREE((void*)_res);
13953         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13954 }
13955
13956 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13957         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13958         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13959         return (uint64_t)ret_conv;
13960 }
13961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13962         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13963         int64_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13964         return ret_val;
13965 }
13966
13967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13968         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13969         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13970         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13971         return (uint64_t)ret_conv;
13972 }
13973
13974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13975         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13976         CHECK_ACCESS(o_ptr);
13977         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
13978         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
13979         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13980         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
13981         return (uint64_t)ret_conv;
13982 }
13983
13984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13985         LDKDecodeError e_conv;
13986         e_conv.inner = (void*)(e & (~1));
13987         e_conv.is_owned = (e & 1) || (e == 0);
13988         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13989         e_conv = DecodeError_clone(&e_conv);
13990         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13991         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
13992         return (uint64_t)ret_conv;
13993 }
13994
13995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13996         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
13997         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13998         return ret_val;
13999 }
14000
14001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14002         if ((_res & 1) != 0) return;
14003         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14004         CHECK_ACCESS(_res_ptr);
14005         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
14006         FREE((void*)_res);
14007         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
14008 }
14009
14010 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14011         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14012         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
14013         return (uint64_t)ret_conv;
14014 }
14015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14016         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
14017         int64_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14018         return ret_val;
14019 }
14020
14021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14022         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
14023         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14024         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
14025         return (uint64_t)ret_conv;
14026 }
14027
14028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14029         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14030         *ret_conv = CResult_NoneNoneZ_ok();
14031         return (uint64_t)ret_conv;
14032 }
14033
14034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14035         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14036         *ret_conv = CResult_NoneNoneZ_err();
14037         return (uint64_t)ret_conv;
14038 }
14039
14040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14041         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14042         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
14043         return ret_val;
14044 }
14045
14046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14047         if ((_res & 1) != 0) return;
14048         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14049         CHECK_ACCESS(_res_ptr);
14050         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14051         FREE((void*)_res);
14052         CResult_NoneNoneZ_free(_res_conv);
14053 }
14054
14055 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14056         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14057         *ret_conv = CResult_NoneNoneZ_clone(arg);
14058         return (uint64_t)ret_conv;
14059 }
14060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14061         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14062         int64_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
14063         return ret_val;
14064 }
14065
14066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14067         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14068         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14069         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14070         return (uint64_t)ret_conv;
14071 }
14072
14073 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
14074         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14075         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
14076         return ((uint64_t)ret_conv);
14077 }
14078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14079         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
14080         int64_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
14081         return ret_val;
14082 }
14083
14084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14085         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
14086         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14087         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
14088         return ((uint64_t)ret_conv);
14089 }
14090
14091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
14092         LDKSignature a_ref;
14093         CHECK((*env)->GetArrayLength(env, a) == 64);
14094         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
14095         LDKCVec_SignatureZ b_constr;
14096         b_constr.datalen = (*env)->GetArrayLength(env, b);
14097         if (b_constr.datalen > 0)
14098                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14099         else
14100                 b_constr.data = NULL;
14101         for (size_t i = 0; i < b_constr.datalen; i++) {
14102                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
14103                 LDKSignature b_conv_8_ref;
14104                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
14105                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
14106                 b_constr.data[i] = b_conv_8_ref;
14107         }
14108         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14109         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
14110         return ((uint64_t)ret_conv);
14111 }
14112
14113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14114         if ((_res & 1) != 0) return;
14115         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14116         CHECK_ACCESS(_res_ptr);
14117         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
14118         FREE((void*)_res);
14119         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
14120 }
14121
14122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14123         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14124         CHECK_ACCESS(o_ptr);
14125         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
14126         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
14127         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14128         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
14129         return (uint64_t)ret_conv;
14130 }
14131
14132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
14133         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14134         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
14135         return (uint64_t)ret_conv;
14136 }
14137
14138 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14139         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
14140         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
14141         return ret_val;
14142 }
14143
14144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14145         if ((_res & 1) != 0) return;
14146         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14147         CHECK_ACCESS(_res_ptr);
14148         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
14149         FREE((void*)_res);
14150         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
14151 }
14152
14153 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
14154         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14155         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
14156         return (uint64_t)ret_conv;
14157 }
14158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14159         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
14160         int64_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
14161         return ret_val;
14162 }
14163
14164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14165         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
14166         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14167         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
14168         return (uint64_t)ret_conv;
14169 }
14170
14171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14172         LDKSignature o_ref;
14173         CHECK((*env)->GetArrayLength(env, o) == 64);
14174         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
14175         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14176         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
14177         return (uint64_t)ret_conv;
14178 }
14179
14180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
14181         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14182         *ret_conv = CResult_SignatureNoneZ_err();
14183         return (uint64_t)ret_conv;
14184 }
14185
14186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14187         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
14188         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
14189         return ret_val;
14190 }
14191
14192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14193         if ((_res & 1) != 0) return;
14194         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14195         CHECK_ACCESS(_res_ptr);
14196         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
14197         FREE((void*)_res);
14198         CResult_SignatureNoneZ_free(_res_conv);
14199 }
14200
14201 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
14202         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14203         *ret_conv = CResult_SignatureNoneZ_clone(arg);
14204         return (uint64_t)ret_conv;
14205 }
14206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14207         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
14208         int64_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
14209         return ret_val;
14210 }
14211
14212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14213         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
14214         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14215         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
14216         return (uint64_t)ret_conv;
14217 }
14218
14219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14220         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14221         CHECK_ACCESS(o_ptr);
14222         LDKSign o_conv = *(LDKSign*)(o_ptr);
14223         if (o_conv.free == LDKSign_JCalls_free) {
14224                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14225                 LDKSign_JCalls_cloned(&o_conv);
14226         }
14227         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
14228         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
14229         return (uint64_t)ret_conv;
14230 }
14231
14232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14233         LDKDecodeError e_conv;
14234         e_conv.inner = (void*)(e & (~1));
14235         e_conv.is_owned = (e & 1) || (e == 0);
14236         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14237         e_conv = DecodeError_clone(&e_conv);
14238         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
14239         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
14240         return (uint64_t)ret_conv;
14241 }
14242
14243 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14244         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
14245         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
14246         return ret_val;
14247 }
14248
14249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14250         if ((_res & 1) != 0) return;
14251         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14252         CHECK_ACCESS(_res_ptr);
14253         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
14254         FREE((void*)_res);
14255         CResult_SignDecodeErrorZ_free(_res_conv);
14256 }
14257
14258 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
14259         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
14260         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
14261         return (uint64_t)ret_conv;
14262 }
14263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14264         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
14265         int64_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
14266         return ret_val;
14267 }
14268
14269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14270         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
14271         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
14272         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
14273         return (uint64_t)ret_conv;
14274 }
14275
14276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14277         LDKCVec_u8Z _res_ref;
14278         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14279         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
14280         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14281         CVec_u8Z_free(_res_ref);
14282 }
14283
14284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
14285         LDKRecoverableSignature arg_ref;
14286         CHECK((*env)->GetArrayLength(env, arg) == 68);
14287         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
14288         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
14289         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
14290         return (uint64_t)ret_conv;
14291 }
14292
14293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
14294         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
14295         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
14296         return (uint64_t)ret_conv;
14297 }
14298
14299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14300         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
14301         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
14302         return ret_val;
14303 }
14304
14305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14306         if ((_res & 1) != 0) return;
14307         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14308         CHECK_ACCESS(_res_ptr);
14309         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
14310         FREE((void*)_res);
14311         CResult_RecoverableSignatureNoneZ_free(_res_conv);
14312 }
14313
14314 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
14315         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
14316         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
14317         return (uint64_t)ret_conv;
14318 }
14319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14320         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
14321         int64_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
14322         return ret_val;
14323 }
14324
14325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14326         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
14327         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
14328         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
14329         return (uint64_t)ret_conv;
14330 }
14331
14332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14333         LDKCVec_CVec_u8ZZ _res_constr;
14334         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14335         if (_res_constr.datalen > 0)
14336                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
14337         else
14338                 _res_constr.data = NULL;
14339         for (size_t i = 0; i < _res_constr.datalen; i++) {
14340                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
14341                 LDKCVec_u8Z _res_conv_8_ref;
14342                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
14343                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
14344                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
14345                 _res_constr.data[i] = _res_conv_8_ref;
14346         }
14347         CVec_CVec_u8ZZ_free(_res_constr);
14348 }
14349
14350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
14351         LDKCVec_CVec_u8ZZ o_constr;
14352         o_constr.datalen = (*env)->GetArrayLength(env, o);
14353         if (o_constr.datalen > 0)
14354                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
14355         else
14356                 o_constr.data = NULL;
14357         for (size_t i = 0; i < o_constr.datalen; i++) {
14358                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
14359                 LDKCVec_u8Z o_conv_8_ref;
14360                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
14361                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
14362                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
14363                 o_constr.data[i] = o_conv_8_ref;
14364         }
14365         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14366         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
14367         return (uint64_t)ret_conv;
14368 }
14369
14370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
14371         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14372         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
14373         return (uint64_t)ret_conv;
14374 }
14375
14376 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14377         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
14378         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
14379         return ret_val;
14380 }
14381
14382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14383         if ((_res & 1) != 0) return;
14384         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14385         CHECK_ACCESS(_res_ptr);
14386         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
14387         FREE((void*)_res);
14388         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
14389 }
14390
14391 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
14392         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14393         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
14394         return (uint64_t)ret_conv;
14395 }
14396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14397         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
14398         int64_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
14399         return ret_val;
14400 }
14401
14402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14403         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
14404         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14405         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
14406         return (uint64_t)ret_conv;
14407 }
14408
14409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14410         LDKInMemorySigner o_conv;
14411         o_conv.inner = (void*)(o & (~1));
14412         o_conv.is_owned = (o & 1) || (o == 0);
14413         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14414         o_conv = InMemorySigner_clone(&o_conv);
14415         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14416         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
14417         return (uint64_t)ret_conv;
14418 }
14419
14420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14421         LDKDecodeError e_conv;
14422         e_conv.inner = (void*)(e & (~1));
14423         e_conv.is_owned = (e & 1) || (e == 0);
14424         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14425         e_conv = DecodeError_clone(&e_conv);
14426         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14427         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
14428         return (uint64_t)ret_conv;
14429 }
14430
14431 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14432         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
14433         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
14434         return ret_val;
14435 }
14436
14437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14438         if ((_res & 1) != 0) return;
14439         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14440         CHECK_ACCESS(_res_ptr);
14441         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
14442         FREE((void*)_res);
14443         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
14444 }
14445
14446 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
14447         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14448         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
14449         return (uint64_t)ret_conv;
14450 }
14451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14452         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
14453         int64_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
14454         return ret_val;
14455 }
14456
14457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14458         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
14459         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14460         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
14461         return (uint64_t)ret_conv;
14462 }
14463
14464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14465         LDKCVec_TxOutZ _res_constr;
14466         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14467         if (_res_constr.datalen > 0)
14468                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
14469         else
14470                 _res_constr.data = NULL;
14471         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14472         for (size_t h = 0; h < _res_constr.datalen; h++) {
14473                 int64_t _res_conv_7 = _res_vals[h];
14474                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
14475                 CHECK_ACCESS(_res_conv_7_ptr);
14476                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
14477                 FREE((void*)_res_conv_7);
14478                 _res_constr.data[h] = _res_conv_7_conv;
14479         }
14480         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14481         CVec_TxOutZ_free(_res_constr);
14482 }
14483
14484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14485         LDKTransaction o_ref;
14486         o_ref.datalen = (*env)->GetArrayLength(env, o);
14487         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
14488         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
14489         o_ref.data_is_owned = true;
14490         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
14491         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
14492         return (uint64_t)ret_conv;
14493 }
14494
14495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14496         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
14497         *ret_conv = CResult_TransactionNoneZ_err();
14498         return (uint64_t)ret_conv;
14499 }
14500
14501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14502         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
14503         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
14504         return ret_val;
14505 }
14506
14507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14508         if ((_res & 1) != 0) return;
14509         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14510         CHECK_ACCESS(_res_ptr);
14511         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
14512         FREE((void*)_res);
14513         CResult_TransactionNoneZ_free(_res_conv);
14514 }
14515
14516 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
14517         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
14518         *ret_conv = CResult_TransactionNoneZ_clone(arg);
14519         return (uint64_t)ret_conv;
14520 }
14521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14522         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
14523         int64_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
14524         return ret_val;
14525 }
14526
14527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14528         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
14529         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
14530         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
14531         return (uint64_t)ret_conv;
14532 }
14533
14534 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
14535         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
14536         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
14537         return ((uint64_t)ret_conv);
14538 }
14539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14540         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
14541         int64_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
14542         return ret_val;
14543 }
14544
14545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14546         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
14547         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
14548         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
14549         return ((uint64_t)ret_conv);
14550 }
14551
14552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
14553         LDKThirtyTwoBytes a_ref;
14554         CHECK((*env)->GetArrayLength(env, a) == 32);
14555         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14556         LDKChannelMonitor b_conv;
14557         b_conv.inner = (void*)(b & (~1));
14558         b_conv.is_owned = (b & 1) || (b == 0);
14559         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14560         b_conv = ChannelMonitor_clone(&b_conv);
14561         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
14562         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
14563         return ((uint64_t)ret_conv);
14564 }
14565
14566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14567         if ((_res & 1) != 0) return;
14568         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14569         CHECK_ACCESS(_res_ptr);
14570         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
14571         FREE((void*)_res);
14572         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
14573 }
14574
14575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14576         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
14577         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14578         if (_res_constr.datalen > 0)
14579                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
14580         else
14581                 _res_constr.data = NULL;
14582         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14583         for (size_t j = 0; j < _res_constr.datalen; j++) {
14584                 int64_t _res_conv_35 = _res_vals[j];
14585                 void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
14586                 CHECK_ACCESS(_res_conv_35_ptr);
14587                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
14588                 FREE((void*)_res_conv_35);
14589                 _res_constr.data[j] = _res_conv_35_conv;
14590         }
14591         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14592         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
14593 }
14594
14595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
14596         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
14597         o_constr.datalen = (*env)->GetArrayLength(env, o);
14598         if (o_constr.datalen > 0)
14599                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
14600         else
14601                 o_constr.data = NULL;
14602         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
14603         for (size_t j = 0; j < o_constr.datalen; j++) {
14604                 int64_t o_conv_35 = o_vals[j];
14605                 void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
14606                 CHECK_ACCESS(o_conv_35_ptr);
14607                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
14608                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
14609                 o_constr.data[j] = o_conv_35_conv;
14610         }
14611         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
14612         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14613         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
14614         return (uint64_t)ret_conv;
14615 }
14616
14617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14618         LDKIOError e_conv = LDKIOError_from_java(env, e);
14619         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14620         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
14621         return (uint64_t)ret_conv;
14622 }
14623
14624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14625         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
14626         jboolean ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
14627         return ret_val;
14628 }
14629
14630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14631         if ((_res & 1) != 0) return;
14632         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14633         CHECK_ACCESS(_res_ptr);
14634         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
14635         FREE((void*)_res);
14636         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
14637 }
14638
14639 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
14640         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14641         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
14642         return (uint64_t)ret_conv;
14643 }
14644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14645         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
14646         int64_t ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
14647         return ret_val;
14648 }
14649
14650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14651         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
14652         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14653         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
14654         return (uint64_t)ret_conv;
14655 }
14656
14657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
14658         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14659         *ret_copy = COption_u16Z_some(o);
14660         uint64_t ret_ref = (uint64_t)ret_copy;
14661         return ret_ref;
14662 }
14663
14664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
14665         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14666         *ret_copy = COption_u16Z_none();
14667         uint64_t ret_ref = (uint64_t)ret_copy;
14668         return ret_ref;
14669 }
14670
14671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14672         if ((_res & 1) != 0) return;
14673         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14674         CHECK_ACCESS(_res_ptr);
14675         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
14676         FREE((void*)_res);
14677         COption_u16Z_free(_res_conv);
14678 }
14679
14680 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
14681         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14682         *ret_copy = COption_u16Z_clone(arg);
14683 uint64_t ret_ref = (uint64_t)ret_copy;
14684         return ret_ref;
14685 }
14686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14687         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
14688         int64_t ret_val = COption_u16Z_clone_ptr(arg_conv);
14689         return ret_val;
14690 }
14691
14692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14693         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
14694         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14695         *ret_copy = COption_u16Z_clone(orig_conv);
14696         uint64_t ret_ref = (uint64_t)ret_copy;
14697         return ret_ref;
14698 }
14699
14700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
14701         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14702         *ret_conv = CResult_NoneAPIErrorZ_ok();
14703         return (uint64_t)ret_conv;
14704 }
14705
14706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14707         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14708         CHECK_ACCESS(e_ptr);
14709         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14710         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
14711         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14712         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
14713         return (uint64_t)ret_conv;
14714 }
14715
14716 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14717         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
14718         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
14719         return ret_val;
14720 }
14721
14722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14723         if ((_res & 1) != 0) return;
14724         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14725         CHECK_ACCESS(_res_ptr);
14726         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
14727         FREE((void*)_res);
14728         CResult_NoneAPIErrorZ_free(_res_conv);
14729 }
14730
14731 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
14732         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14733         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
14734         return (uint64_t)ret_conv;
14735 }
14736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14737         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
14738         int64_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
14739         return ret_val;
14740 }
14741
14742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14743         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
14744         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14745         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
14746         return (uint64_t)ret_conv;
14747 }
14748
14749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14750         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
14751         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14752         if (_res_constr.datalen > 0)
14753                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
14754         else
14755                 _res_constr.data = NULL;
14756         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14757         for (size_t w = 0; w < _res_constr.datalen; w++) {
14758                 int64_t _res_conv_22 = _res_vals[w];
14759                 void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
14760                 CHECK_ACCESS(_res_conv_22_ptr);
14761                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
14762                 FREE((void*)_res_conv_22);
14763                 _res_constr.data[w] = _res_conv_22_conv;
14764         }
14765         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14766         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
14767 }
14768
14769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14770         LDKCVec_APIErrorZ _res_constr;
14771         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14772         if (_res_constr.datalen > 0)
14773                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
14774         else
14775                 _res_constr.data = NULL;
14776         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14777         for (size_t k = 0; k < _res_constr.datalen; k++) {
14778                 int64_t _res_conv_10 = _res_vals[k];
14779                 void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
14780                 CHECK_ACCESS(_res_conv_10_ptr);
14781                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
14782                 FREE((void*)_res_conv_10);
14783                 _res_constr.data[k] = _res_conv_10_conv;
14784         }
14785         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14786         CVec_APIErrorZ_free(_res_constr);
14787 }
14788
14789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14790         LDKThirtyTwoBytes o_ref;
14791         CHECK((*env)->GetArrayLength(env, o) == 32);
14792         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14793         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14794         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
14795         return (uint64_t)ret_conv;
14796 }
14797
14798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14799         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14800         CHECK_ACCESS(e_ptr);
14801         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14802         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
14803         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14804         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
14805         return (uint64_t)ret_conv;
14806 }
14807
14808 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14809         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
14810         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
14811         return ret_val;
14812 }
14813
14814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14815         if ((_res & 1) != 0) return;
14816         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14817         CHECK_ACCESS(_res_ptr);
14818         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
14819         FREE((void*)_res);
14820         CResult__u832APIErrorZ_free(_res_conv);
14821 }
14822
14823 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
14824         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14825         *ret_conv = CResult__u832APIErrorZ_clone(arg);
14826         return (uint64_t)ret_conv;
14827 }
14828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14829         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
14830         int64_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
14831         return ret_val;
14832 }
14833
14834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14835         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
14836         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14837         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
14838         return (uint64_t)ret_conv;
14839 }
14840
14841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14842         LDKThirtyTwoBytes o_ref;
14843         CHECK((*env)->GetArrayLength(env, o) == 32);
14844         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14845         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14846         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
14847         return (uint64_t)ret_conv;
14848 }
14849
14850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14851         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14852         CHECK_ACCESS(e_ptr);
14853         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14854         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
14855         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14856         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
14857         return (uint64_t)ret_conv;
14858 }
14859
14860 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14861         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
14862         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
14863         return ret_val;
14864 }
14865
14866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14867         if ((_res & 1) != 0) return;
14868         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14869         CHECK_ACCESS(_res_ptr);
14870         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
14871         FREE((void*)_res);
14872         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
14873 }
14874
14875 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
14876         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14877         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
14878         return (uint64_t)ret_conv;
14879 }
14880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14881         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
14882         int64_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
14883         return ret_val;
14884 }
14885
14886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14887         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
14888         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14889         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
14890         return (uint64_t)ret_conv;
14891 }
14892
14893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
14894         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14895         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
14896         return (uint64_t)ret_conv;
14897 }
14898
14899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14900         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14901         CHECK_ACCESS(e_ptr);
14902         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14903         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
14904         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14905         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
14906         return (uint64_t)ret_conv;
14907 }
14908
14909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14910         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
14911         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
14912         return ret_val;
14913 }
14914
14915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14916         if ((_res & 1) != 0) return;
14917         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14918         CHECK_ACCESS(_res_ptr);
14919         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
14920         FREE((void*)_res);
14921         CResult_NonePaymentSendFailureZ_free(_res_conv);
14922 }
14923
14924 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
14925         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14926         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
14927         return (uint64_t)ret_conv;
14928 }
14929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14930         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
14931         int64_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
14932         return ret_val;
14933 }
14934
14935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14936         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
14937         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14938         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
14939         return (uint64_t)ret_conv;
14940 }
14941
14942 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
14943         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14944         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
14945         return ((uint64_t)ret_conv);
14946 }
14947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14948         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
14949         int64_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
14950         return ret_val;
14951 }
14952
14953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14954         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
14955         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14956         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
14957         return ((uint64_t)ret_conv);
14958 }
14959
14960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
14961         LDKThirtyTwoBytes a_ref;
14962         CHECK((*env)->GetArrayLength(env, a) == 32);
14963         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14964         LDKThirtyTwoBytes b_ref;
14965         CHECK((*env)->GetArrayLength(env, b) == 32);
14966         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
14967         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14968         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
14969         return ((uint64_t)ret_conv);
14970 }
14971
14972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14973         if ((_res & 1) != 0) return;
14974         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14975         CHECK_ACCESS(_res_ptr);
14976         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
14977         FREE((void*)_res);
14978         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
14979 }
14980
14981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14982         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14983         CHECK_ACCESS(o_ptr);
14984         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
14985         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
14986         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14987         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
14988         return (uint64_t)ret_conv;
14989 }
14990
14991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14992         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14993         CHECK_ACCESS(e_ptr);
14994         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14995         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
14996         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14997         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
14998         return (uint64_t)ret_conv;
14999 }
15000
15001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15002         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
15003         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
15004         return ret_val;
15005 }
15006
15007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15008         if ((_res & 1) != 0) return;
15009         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15010         CHECK_ACCESS(_res_ptr);
15011         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
15012         FREE((void*)_res);
15013         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
15014 }
15015
15016 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
15017         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15018         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
15019         return (uint64_t)ret_conv;
15020 }
15021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15022         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
15023         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
15024         return ret_val;
15025 }
15026
15027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15028         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
15029         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15030         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
15031         return (uint64_t)ret_conv;
15032 }
15033
15034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15035         LDKCVec_NetAddressZ _res_constr;
15036         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15037         if (_res_constr.datalen > 0)
15038                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15039         else
15040                 _res_constr.data = NULL;
15041         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15042         for (size_t m = 0; m < _res_constr.datalen; m++) {
15043                 int64_t _res_conv_12 = _res_vals[m];
15044                 void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
15045                 CHECK_ACCESS(_res_conv_12_ptr);
15046                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
15047                 FREE((void*)_res_conv_12);
15048                 _res_constr.data[m] = _res_conv_12_conv;
15049         }
15050         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15051         CVec_NetAddressZ_free(_res_constr);
15052 }
15053
15054 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
15055         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15056         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
15057         return ((uint64_t)ret_conv);
15058 }
15059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15060         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
15061         int64_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
15062         return ret_val;
15063 }
15064
15065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15066         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
15067         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15068         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
15069         return ((uint64_t)ret_conv);
15070 }
15071
15072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
15073         LDKThirtyTwoBytes a_ref;
15074         CHECK((*env)->GetArrayLength(env, a) == 32);
15075         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
15076         LDKThirtyTwoBytes b_ref;
15077         CHECK((*env)->GetArrayLength(env, b) == 32);
15078         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
15079         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15080         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
15081         return ((uint64_t)ret_conv);
15082 }
15083
15084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15085         if ((_res & 1) != 0) return;
15086         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15087         CHECK_ACCESS(_res_ptr);
15088         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
15089         FREE((void*)_res);
15090         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
15091 }
15092
15093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15094         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15095         CHECK_ACCESS(o_ptr);
15096         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
15097         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)o) & ~1));
15098         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15099         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
15100         return (uint64_t)ret_conv;
15101 }
15102
15103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
15104         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15105         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
15106         return (uint64_t)ret_conv;
15107 }
15108
15109 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15110         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
15111         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
15112         return ret_val;
15113 }
15114
15115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15116         if ((_res & 1) != 0) return;
15117         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15118         CHECK_ACCESS(_res_ptr);
15119         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
15120         FREE((void*)_res);
15121         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
15122 }
15123
15124 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
15125         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15126         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
15127         return (uint64_t)ret_conv;
15128 }
15129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15130         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
15131         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
15132         return ret_val;
15133 }
15134
15135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15136         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
15137         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15138         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
15139         return (uint64_t)ret_conv;
15140 }
15141
15142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15143         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15144         CHECK_ACCESS(o_ptr);
15145         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
15146         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)o) & ~1));
15147         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15148         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
15149         return (uint64_t)ret_conv;
15150 }
15151
15152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15153         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15154         CHECK_ACCESS(e_ptr);
15155         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15156         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
15157         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15158         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
15159         return (uint64_t)ret_conv;
15160 }
15161
15162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15163         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
15164         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
15165         return ret_val;
15166 }
15167
15168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15169         if ((_res & 1) != 0) return;
15170         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15171         CHECK_ACCESS(_res_ptr);
15172         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
15173         FREE((void*)_res);
15174         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
15175 }
15176
15177 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
15178         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15179         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
15180         return (uint64_t)ret_conv;
15181 }
15182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15183         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
15184         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
15185         return ret_val;
15186 }
15187
15188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15189         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
15190         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15191         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
15192         return (uint64_t)ret_conv;
15193 }
15194
15195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15196         LDKThirtyTwoBytes o_ref;
15197         CHECK((*env)->GetArrayLength(env, o) == 32);
15198         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
15199         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15200         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
15201         return (uint64_t)ret_conv;
15202 }
15203
15204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
15205         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15206         *ret_conv = CResult_PaymentSecretNoneZ_err();
15207         return (uint64_t)ret_conv;
15208 }
15209
15210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15211         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
15212         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
15213         return ret_val;
15214 }
15215
15216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15217         if ((_res & 1) != 0) return;
15218         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15219         CHECK_ACCESS(_res_ptr);
15220         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
15221         FREE((void*)_res);
15222         CResult_PaymentSecretNoneZ_free(_res_conv);
15223 }
15224
15225 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
15226         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15227         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
15228         return (uint64_t)ret_conv;
15229 }
15230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15231         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
15232         int64_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
15233         return ret_val;
15234 }
15235
15236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15237         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
15238         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15239         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
15240         return (uint64_t)ret_conv;
15241 }
15242
15243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15244         LDKThirtyTwoBytes o_ref;
15245         CHECK((*env)->GetArrayLength(env, o) == 32);
15246         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
15247         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15248         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
15249         return (uint64_t)ret_conv;
15250 }
15251
15252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15253         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15254         CHECK_ACCESS(e_ptr);
15255         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15256         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
15257         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15258         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
15259         return (uint64_t)ret_conv;
15260 }
15261
15262 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15263         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
15264         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
15265         return ret_val;
15266 }
15267
15268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15269         if ((_res & 1) != 0) return;
15270         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15271         CHECK_ACCESS(_res_ptr);
15272         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
15273         FREE((void*)_res);
15274         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
15275 }
15276
15277 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
15278         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15279         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
15280         return (uint64_t)ret_conv;
15281 }
15282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15283         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
15284         int64_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
15285         return ret_val;
15286 }
15287
15288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15289         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
15290         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15291         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
15292         return (uint64_t)ret_conv;
15293 }
15294
15295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15296         LDKThirtyTwoBytes o_ref;
15297         CHECK((*env)->GetArrayLength(env, o) == 32);
15298         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
15299         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
15300         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
15301         return (uint64_t)ret_conv;
15302 }
15303
15304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15305         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15306         CHECK_ACCESS(e_ptr);
15307         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15308         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
15309         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
15310         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
15311         return (uint64_t)ret_conv;
15312 }
15313
15314 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15315         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
15316         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
15317         return ret_val;
15318 }
15319
15320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15321         if ((_res & 1) != 0) return;
15322         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15323         CHECK_ACCESS(_res_ptr);
15324         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
15325         FREE((void*)_res);
15326         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
15327 }
15328
15329 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
15330         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
15331         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
15332         return (uint64_t)ret_conv;
15333 }
15334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15335         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
15336         int64_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
15337         return ret_val;
15338 }
15339
15340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15341         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
15342         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
15343         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
15344         return (uint64_t)ret_conv;
15345 }
15346
15347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15348         LDKCVec_ChannelMonitorZ _res_constr;
15349         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15350         if (_res_constr.datalen > 0)
15351                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
15352         else
15353                 _res_constr.data = NULL;
15354         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15355         for (size_t q = 0; q < _res_constr.datalen; q++) {
15356                 int64_t _res_conv_16 = _res_vals[q];
15357                 LDKChannelMonitor _res_conv_16_conv;
15358                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
15359                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
15360                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
15361                 _res_constr.data[q] = _res_conv_16_conv;
15362         }
15363         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15364         CVec_ChannelMonitorZ_free(_res_constr);
15365 }
15366
15367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
15368         LDKThirtyTwoBytes a_ref;
15369         CHECK((*env)->GetArrayLength(env, a) == 32);
15370         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
15371         LDKChannelManager b_conv;
15372         b_conv.inner = (void*)(b & (~1));
15373         b_conv.is_owned = (b & 1) || (b == 0);
15374         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
15375         // Warning: we need a move here but no clone is available for LDKChannelManager
15376         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
15377         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
15378         return ((uint64_t)ret_conv);
15379 }
15380
15381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15382         if ((_res & 1) != 0) return;
15383         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15384         CHECK_ACCESS(_res_ptr);
15385         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
15386         FREE((void*)_res);
15387         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
15388 }
15389
15390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15391         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15392         CHECK_ACCESS(o_ptr);
15393         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
15394         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
15395         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
15396         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
15397         return (uint64_t)ret_conv;
15398 }
15399
15400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15401         LDKDecodeError e_conv;
15402         e_conv.inner = (void*)(e & (~1));
15403         e_conv.is_owned = (e & 1) || (e == 0);
15404         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15405         e_conv = DecodeError_clone(&e_conv);
15406         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
15407         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
15408         return (uint64_t)ret_conv;
15409 }
15410
15411 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15412         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
15413         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
15414         return ret_val;
15415 }
15416
15417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15418         if ((_res & 1) != 0) return;
15419         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15420         CHECK_ACCESS(_res_ptr);
15421         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
15422         FREE((void*)_res);
15423         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
15424 }
15425
15426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15427         LDKChannelConfig o_conv;
15428         o_conv.inner = (void*)(o & (~1));
15429         o_conv.is_owned = (o & 1) || (o == 0);
15430         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15431         o_conv = ChannelConfig_clone(&o_conv);
15432         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
15433         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
15434         return (uint64_t)ret_conv;
15435 }
15436
15437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15438         LDKDecodeError e_conv;
15439         e_conv.inner = (void*)(e & (~1));
15440         e_conv.is_owned = (e & 1) || (e == 0);
15441         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15442         e_conv = DecodeError_clone(&e_conv);
15443         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
15444         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
15445         return (uint64_t)ret_conv;
15446 }
15447
15448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15449         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
15450         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
15451         return ret_val;
15452 }
15453
15454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15455         if ((_res & 1) != 0) return;
15456         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15457         CHECK_ACCESS(_res_ptr);
15458         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
15459         FREE((void*)_res);
15460         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
15461 }
15462
15463 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
15464         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
15465         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
15466         return (uint64_t)ret_conv;
15467 }
15468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15469         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
15470         int64_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
15471         return ret_val;
15472 }
15473
15474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15475         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
15476         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
15477         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
15478         return (uint64_t)ret_conv;
15479 }
15480
15481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15482         LDKOutPoint o_conv;
15483         o_conv.inner = (void*)(o & (~1));
15484         o_conv.is_owned = (o & 1) || (o == 0);
15485         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15486         o_conv = OutPoint_clone(&o_conv);
15487         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15488         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
15489         return (uint64_t)ret_conv;
15490 }
15491
15492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15493         LDKDecodeError e_conv;
15494         e_conv.inner = (void*)(e & (~1));
15495         e_conv.is_owned = (e & 1) || (e == 0);
15496         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15497         e_conv = DecodeError_clone(&e_conv);
15498         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15499         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
15500         return (uint64_t)ret_conv;
15501 }
15502
15503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15504         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
15505         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
15506         return ret_val;
15507 }
15508
15509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15510         if ((_res & 1) != 0) return;
15511         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15512         CHECK_ACCESS(_res_ptr);
15513         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
15514         FREE((void*)_res);
15515         CResult_OutPointDecodeErrorZ_free(_res_conv);
15516 }
15517
15518 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
15519         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15520         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
15521         return (uint64_t)ret_conv;
15522 }
15523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15524         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
15525         int64_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
15526         return ret_val;
15527 }
15528
15529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15530         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
15531         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15532         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
15533         return (uint64_t)ret_conv;
15534 }
15535
15536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15537         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15538         CHECK_ACCESS(o_ptr);
15539         LDKType o_conv = *(LDKType*)(o_ptr);
15540         if (o_conv.free == LDKType_JCalls_free) {
15541                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15542                 LDKType_JCalls_cloned(&o_conv);
15543         }
15544         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
15545         *ret_copy = COption_TypeZ_some(o_conv);
15546         uint64_t ret_ref = (uint64_t)ret_copy;
15547         return ret_ref;
15548 }
15549
15550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
15551         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
15552         *ret_copy = COption_TypeZ_none();
15553         uint64_t ret_ref = (uint64_t)ret_copy;
15554         return ret_ref;
15555 }
15556
15557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15558         if ((_res & 1) != 0) return;
15559         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15560         CHECK_ACCESS(_res_ptr);
15561         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
15562         FREE((void*)_res);
15563         COption_TypeZ_free(_res_conv);
15564 }
15565
15566 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
15567         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
15568         *ret_copy = COption_TypeZ_clone(arg);
15569 uint64_t ret_ref = (uint64_t)ret_copy;
15570         return ret_ref;
15571 }
15572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15573         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
15574         int64_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
15575         return ret_val;
15576 }
15577
15578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15579         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
15580         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
15581         *ret_copy = COption_TypeZ_clone(orig_conv);
15582         uint64_t ret_ref = (uint64_t)ret_copy;
15583         return ret_ref;
15584 }
15585
15586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15587         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15588         CHECK_ACCESS(o_ptr);
15589         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
15590         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
15591         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15592         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
15593         return (uint64_t)ret_conv;
15594 }
15595
15596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15597         LDKDecodeError e_conv;
15598         e_conv.inner = (void*)(e & (~1));
15599         e_conv.is_owned = (e & 1) || (e == 0);
15600         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15601         e_conv = DecodeError_clone(&e_conv);
15602         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15603         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
15604         return (uint64_t)ret_conv;
15605 }
15606
15607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15608         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
15609         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
15610         return ret_val;
15611 }
15612
15613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15614         if ((_res & 1) != 0) return;
15615         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15616         CHECK_ACCESS(_res_ptr);
15617         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
15618         FREE((void*)_res);
15619         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
15620 }
15621
15622 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
15623         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15624         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
15625         return (uint64_t)ret_conv;
15626 }
15627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15628         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
15629         int64_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
15630         return ret_val;
15631 }
15632
15633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15634         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
15635         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15636         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
15637         return (uint64_t)ret_conv;
15638 }
15639
15640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15641         LDKThirtyTwoBytes o_ref;
15642         CHECK((*env)->GetArrayLength(env, o) == 32);
15643         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
15644         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15645         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
15646         return (uint64_t)ret_conv;
15647 }
15648
15649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15650         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15651         CHECK_ACCESS(e_ptr);
15652         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
15653         e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
15654         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15655         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
15656         return (uint64_t)ret_conv;
15657 }
15658
15659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15660         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
15661         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
15662         return ret_val;
15663 }
15664
15665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15666         if ((_res & 1) != 0) return;
15667         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15668         CHECK_ACCESS(_res_ptr);
15669         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
15670         FREE((void*)_res);
15671         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
15672 }
15673
15674 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
15675         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15676         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
15677         return (uint64_t)ret_conv;
15678 }
15679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15680         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
15681         int64_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
15682         return ret_val;
15683 }
15684
15685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15686         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
15687         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15688         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
15689         return (uint64_t)ret_conv;
15690 }
15691
15692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
15693         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
15694         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
15695         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
15696         return (uint64_t)ret_conv;
15697 }
15698
15699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
15700         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
15701         *ret_conv = CResult_SiPrefixNoneZ_err();
15702         return (uint64_t)ret_conv;
15703 }
15704
15705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15706         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
15707         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
15708         return ret_val;
15709 }
15710
15711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15712         if ((_res & 1) != 0) return;
15713         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15714         CHECK_ACCESS(_res_ptr);
15715         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
15716         FREE((void*)_res);
15717         CResult_SiPrefixNoneZ_free(_res_conv);
15718 }
15719
15720 static inline uint64_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
15721         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
15722         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
15723         return (uint64_t)ret_conv;
15724 }
15725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15726         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
15727         int64_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
15728         return ret_val;
15729 }
15730
15731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15732         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
15733         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
15734         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
15735         return (uint64_t)ret_conv;
15736 }
15737
15738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15739         LDKInvoice o_conv;
15740         o_conv.inner = (void*)(o & (~1));
15741         o_conv.is_owned = (o & 1) || (o == 0);
15742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15743         o_conv = Invoice_clone(&o_conv);
15744         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
15745         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
15746         return (uint64_t)ret_conv;
15747 }
15748
15749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
15750         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
15751         *ret_conv = CResult_InvoiceNoneZ_err();
15752         return (uint64_t)ret_conv;
15753 }
15754
15755 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15756         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
15757         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
15758         return ret_val;
15759 }
15760
15761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15762         if ((_res & 1) != 0) return;
15763         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15764         CHECK_ACCESS(_res_ptr);
15765         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
15766         FREE((void*)_res);
15767         CResult_InvoiceNoneZ_free(_res_conv);
15768 }
15769
15770 static inline uint64_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
15771         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
15772         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
15773         return (uint64_t)ret_conv;
15774 }
15775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15776         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
15777         int64_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
15778         return ret_val;
15779 }
15780
15781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15782         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
15783         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
15784         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
15785         return (uint64_t)ret_conv;
15786 }
15787
15788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15789         LDKSignedRawInvoice o_conv;
15790         o_conv.inner = (void*)(o & (~1));
15791         o_conv.is_owned = (o & 1) || (o == 0);
15792         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15793         o_conv = SignedRawInvoice_clone(&o_conv);
15794         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15795         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
15796         return (uint64_t)ret_conv;
15797 }
15798
15799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
15800         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15801         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
15802         return (uint64_t)ret_conv;
15803 }
15804
15805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15806         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
15807         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
15808         return ret_val;
15809 }
15810
15811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15812         if ((_res & 1) != 0) return;
15813         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15814         CHECK_ACCESS(_res_ptr);
15815         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
15816         FREE((void*)_res);
15817         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
15818 }
15819
15820 static inline uint64_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
15821         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15822         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
15823         return (uint64_t)ret_conv;
15824 }
15825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15826         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
15827         int64_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
15828         return ret_val;
15829 }
15830
15831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15832         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
15833         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15834         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
15835         return (uint64_t)ret_conv;
15836 }
15837
15838 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15839         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15840         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15841         return ((uint64_t)ret_conv);
15842 }
15843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15844         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15845         int64_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15846         return ret_val;
15847 }
15848
15849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15850         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15851         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15852         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15853         return ((uint64_t)ret_conv);
15854 }
15855
15856 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) {
15857         LDKRawInvoice a_conv;
15858         a_conv.inner = (void*)(a & (~1));
15859         a_conv.is_owned = (a & 1) || (a == 0);
15860         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15861         a_conv = RawInvoice_clone(&a_conv);
15862         LDKThirtyTwoBytes b_ref;
15863         CHECK((*env)->GetArrayLength(env, b) == 32);
15864         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
15865         LDKInvoiceSignature c_conv;
15866         c_conv.inner = (void*)(c & (~1));
15867         c_conv.is_owned = (c & 1) || (c == 0);
15868         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15869         c_conv = InvoiceSignature_clone(&c_conv);
15870         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15871         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15872         return ((uint64_t)ret_conv);
15873 }
15874
15875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15876         if ((_res & 1) != 0) return;
15877         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15878         CHECK_ACCESS(_res_ptr);
15879         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15880         FREE((void*)_res);
15881         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15882 }
15883
15884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15885         LDKPayeePubKey o_conv;
15886         o_conv.inner = (void*)(o & (~1));
15887         o_conv.is_owned = (o & 1) || (o == 0);
15888         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15889         o_conv = PayeePubKey_clone(&o_conv);
15890         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15891         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15892         return (uint64_t)ret_conv;
15893 }
15894
15895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15896         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15897         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15898         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15899         return (uint64_t)ret_conv;
15900 }
15901
15902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15903         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15904         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15905         return ret_val;
15906 }
15907
15908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15909         if ((_res & 1) != 0) return;
15910         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15911         CHECK_ACCESS(_res_ptr);
15912         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15913         FREE((void*)_res);
15914         CResult_PayeePubKeyErrorZ_free(_res_conv);
15915 }
15916
15917 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15918         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15919         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15920         return (uint64_t)ret_conv;
15921 }
15922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15923         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15924         int64_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15925         return ret_val;
15926 }
15927
15928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15929         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15930         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15931         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15932         return (uint64_t)ret_conv;
15933 }
15934
15935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15936         LDKCVec_PrivateRouteZ _res_constr;
15937         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15938         if (_res_constr.datalen > 0)
15939                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15940         else
15941                 _res_constr.data = NULL;
15942         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15943         for (size_t o = 0; o < _res_constr.datalen; o++) {
15944                 int64_t _res_conv_14 = _res_vals[o];
15945                 LDKPrivateRoute _res_conv_14_conv;
15946                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15947                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15948                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15949                 _res_constr.data[o] = _res_conv_14_conv;
15950         }
15951         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15952         CVec_PrivateRouteZ_free(_res_constr);
15953 }
15954
15955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15956         LDKPositiveTimestamp o_conv;
15957         o_conv.inner = (void*)(o & (~1));
15958         o_conv.is_owned = (o & 1) || (o == 0);
15959         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15960         o_conv = PositiveTimestamp_clone(&o_conv);
15961         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15962         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15963         return (uint64_t)ret_conv;
15964 }
15965
15966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15967         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
15968         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15969         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15970         return (uint64_t)ret_conv;
15971 }
15972
15973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15974         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15975         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15976         return ret_val;
15977 }
15978
15979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15980         if ((_res & 1) != 0) return;
15981         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15982         CHECK_ACCESS(_res_ptr);
15983         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15984         FREE((void*)_res);
15985         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15986 }
15987
15988 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15989         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15990         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15991         return (uint64_t)ret_conv;
15992 }
15993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15994         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15995         int64_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15996         return ret_val;
15997 }
15998
15999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16000         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
16001         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16002         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
16003         return (uint64_t)ret_conv;
16004 }
16005
16006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
16007         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16008         *ret_conv = CResult_NoneSemanticErrorZ_ok();
16009         return (uint64_t)ret_conv;
16010 }
16011
16012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16013         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
16014         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16015         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
16016         return (uint64_t)ret_conv;
16017 }
16018
16019 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16020         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
16021         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
16022         return ret_val;
16023 }
16024
16025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16026         if ((_res & 1) != 0) return;
16027         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16028         CHECK_ACCESS(_res_ptr);
16029         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
16030         FREE((void*)_res);
16031         CResult_NoneSemanticErrorZ_free(_res_conv);
16032 }
16033
16034 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
16035         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16036         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
16037         return (uint64_t)ret_conv;
16038 }
16039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16040         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
16041         int64_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
16042         return ret_val;
16043 }
16044
16045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16046         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
16047         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16048         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
16049         return (uint64_t)ret_conv;
16050 }
16051
16052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16053         LDKInvoice o_conv;
16054         o_conv.inner = (void*)(o & (~1));
16055         o_conv.is_owned = (o & 1) || (o == 0);
16056         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16057         o_conv = Invoice_clone(&o_conv);
16058         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16059         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
16060         return (uint64_t)ret_conv;
16061 }
16062
16063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16064         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
16065         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16066         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
16067         return (uint64_t)ret_conv;
16068 }
16069
16070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16071         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
16072         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
16073         return ret_val;
16074 }
16075
16076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16077         if ((_res & 1) != 0) return;
16078         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16079         CHECK_ACCESS(_res_ptr);
16080         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
16081         FREE((void*)_res);
16082         CResult_InvoiceSemanticErrorZ_free(_res_conv);
16083 }
16084
16085 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
16086         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16087         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
16088         return (uint64_t)ret_conv;
16089 }
16090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16091         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
16092         int64_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
16093         return ret_val;
16094 }
16095
16096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16097         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
16098         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16099         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
16100         return (uint64_t)ret_conv;
16101 }
16102
16103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16104         LDKDescription o_conv;
16105         o_conv.inner = (void*)(o & (~1));
16106         o_conv.is_owned = (o & 1) || (o == 0);
16107         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16108         o_conv = Description_clone(&o_conv);
16109         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
16110         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
16111         return (uint64_t)ret_conv;
16112 }
16113
16114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16115         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
16116         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
16117         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
16118         return (uint64_t)ret_conv;
16119 }
16120
16121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16122         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
16123         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
16124         return ret_val;
16125 }
16126
16127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16128         if ((_res & 1) != 0) return;
16129         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16130         CHECK_ACCESS(_res_ptr);
16131         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
16132         FREE((void*)_res);
16133         CResult_DescriptionCreationErrorZ_free(_res_conv);
16134 }
16135
16136 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
16137         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
16138         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
16139         return (uint64_t)ret_conv;
16140 }
16141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16142         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
16143         int64_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
16144         return ret_val;
16145 }
16146
16147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16148         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
16149         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
16150         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
16151         return (uint64_t)ret_conv;
16152 }
16153
16154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16155         LDKExpiryTime o_conv;
16156         o_conv.inner = (void*)(o & (~1));
16157         o_conv.is_owned = (o & 1) || (o == 0);
16158         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16159         o_conv = ExpiryTime_clone(&o_conv);
16160         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
16161         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
16162         return (uint64_t)ret_conv;
16163 }
16164
16165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16166         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
16167         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
16168         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
16169         return (uint64_t)ret_conv;
16170 }
16171
16172 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16173         LDKCResult_ExpiryTimeCreationErrorZ* o_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(o & ~1);
16174         jboolean ret_val = CResult_ExpiryTimeCreationErrorZ_is_ok(o_conv);
16175         return ret_val;
16176 }
16177
16178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16179         if ((_res & 1) != 0) return;
16180         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16181         CHECK_ACCESS(_res_ptr);
16182         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
16183         FREE((void*)_res);
16184         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
16185 }
16186
16187 static inline uint64_t CResult_ExpiryTimeCreationErrorZ_clone_ptr(LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR arg) {
16188         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
16189         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(arg);
16190         return (uint64_t)ret_conv;
16191 }
16192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16193         LDKCResult_ExpiryTimeCreationErrorZ* arg_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
16194         int64_t ret_val = CResult_ExpiryTimeCreationErrorZ_clone_ptr(arg_conv);
16195         return ret_val;
16196 }
16197
16198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16199         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
16200         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
16201         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
16202         return (uint64_t)ret_conv;
16203 }
16204
16205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16206         LDKPrivateRoute o_conv;
16207         o_conv.inner = (void*)(o & (~1));
16208         o_conv.is_owned = (o & 1) || (o == 0);
16209         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16210         o_conv = PrivateRoute_clone(&o_conv);
16211         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
16212         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
16213         return (uint64_t)ret_conv;
16214 }
16215
16216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16217         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
16218         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
16219         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
16220         return (uint64_t)ret_conv;
16221 }
16222
16223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16224         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
16225         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
16226         return ret_val;
16227 }
16228
16229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16230         if ((_res & 1) != 0) return;
16231         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16232         CHECK_ACCESS(_res_ptr);
16233         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
16234         FREE((void*)_res);
16235         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
16236 }
16237
16238 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
16239         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
16240         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
16241         return (uint64_t)ret_conv;
16242 }
16243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16244         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
16245         int64_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
16246         return ret_val;
16247 }
16248
16249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16250         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
16251         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
16252         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
16253         return (uint64_t)ret_conv;
16254 }
16255
16256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
16257         LDKStr o_conv = java_to_owned_str(env, o);
16258         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
16259         *ret_conv = CResult_StringErrorZ_ok(o_conv);
16260         return (uint64_t)ret_conv;
16261 }
16262
16263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16264         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
16265         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
16266         *ret_conv = CResult_StringErrorZ_err(e_conv);
16267         return (uint64_t)ret_conv;
16268 }
16269
16270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16271         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
16272         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
16273         return ret_val;
16274 }
16275
16276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16277         if ((_res & 1) != 0) return;
16278         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16279         CHECK_ACCESS(_res_ptr);
16280         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
16281         FREE((void*)_res);
16282         CResult_StringErrorZ_free(_res_conv);
16283 }
16284
16285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16286         LDKChannelMonitorUpdate o_conv;
16287         o_conv.inner = (void*)(o & (~1));
16288         o_conv.is_owned = (o & 1) || (o == 0);
16289         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16290         o_conv = ChannelMonitorUpdate_clone(&o_conv);
16291         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
16292         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
16293         return (uint64_t)ret_conv;
16294 }
16295
16296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16297         LDKDecodeError e_conv;
16298         e_conv.inner = (void*)(e & (~1));
16299         e_conv.is_owned = (e & 1) || (e == 0);
16300         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16301         e_conv = DecodeError_clone(&e_conv);
16302         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
16303         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
16304         return (uint64_t)ret_conv;
16305 }
16306
16307 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16308         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
16309         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
16310         return ret_val;
16311 }
16312
16313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16314         if ((_res & 1) != 0) return;
16315         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16316         CHECK_ACCESS(_res_ptr);
16317         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
16318         FREE((void*)_res);
16319         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
16320 }
16321
16322 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
16323         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
16324         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
16325         return (uint64_t)ret_conv;
16326 }
16327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16328         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
16329         int64_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
16330         return ret_val;
16331 }
16332
16333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16334         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
16335         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
16336         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
16337         return (uint64_t)ret_conv;
16338 }
16339
16340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16341         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16342         CHECK_ACCESS(o_ptr);
16343         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
16344         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)o) & ~1));
16345         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
16346         *ret_copy = COption_MonitorEventZ_some(o_conv);
16347         uint64_t ret_ref = (uint64_t)ret_copy;
16348         return ret_ref;
16349 }
16350
16351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
16352         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
16353         *ret_copy = COption_MonitorEventZ_none();
16354         uint64_t ret_ref = (uint64_t)ret_copy;
16355         return ret_ref;
16356 }
16357
16358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16359         if ((_res & 1) != 0) return;
16360         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16361         CHECK_ACCESS(_res_ptr);
16362         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
16363         FREE((void*)_res);
16364         COption_MonitorEventZ_free(_res_conv);
16365 }
16366
16367 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
16368         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
16369         *ret_copy = COption_MonitorEventZ_clone(arg);
16370 uint64_t ret_ref = (uint64_t)ret_copy;
16371         return ret_ref;
16372 }
16373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16374         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
16375         int64_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
16376         return ret_val;
16377 }
16378
16379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16380         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
16381         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
16382         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
16383         uint64_t ret_ref = (uint64_t)ret_copy;
16384         return ret_ref;
16385 }
16386
16387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16388         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16389         CHECK_ACCESS(o_ptr);
16390         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
16391         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uint64_t)o) & ~1));
16392         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
16393         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
16394         return (uint64_t)ret_conv;
16395 }
16396
16397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16398         LDKDecodeError e_conv;
16399         e_conv.inner = (void*)(e & (~1));
16400         e_conv.is_owned = (e & 1) || (e == 0);
16401         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16402         e_conv = DecodeError_clone(&e_conv);
16403         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
16404         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
16405         return (uint64_t)ret_conv;
16406 }
16407
16408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16409         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
16410         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
16411         return ret_val;
16412 }
16413
16414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16415         if ((_res & 1) != 0) return;
16416         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16417         CHECK_ACCESS(_res_ptr);
16418         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
16419         FREE((void*)_res);
16420         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
16421 }
16422
16423 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
16424         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
16425         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
16426         return (uint64_t)ret_conv;
16427 }
16428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16429         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
16430         int64_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
16431         return ret_val;
16432 }
16433
16434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16435         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
16436         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
16437         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
16438         return (uint64_t)ret_conv;
16439 }
16440
16441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16442         LDKHTLCUpdate o_conv;
16443         o_conv.inner = (void*)(o & (~1));
16444         o_conv.is_owned = (o & 1) || (o == 0);
16445         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16446         o_conv = HTLCUpdate_clone(&o_conv);
16447         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
16448         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
16449         return (uint64_t)ret_conv;
16450 }
16451
16452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16453         LDKDecodeError e_conv;
16454         e_conv.inner = (void*)(e & (~1));
16455         e_conv.is_owned = (e & 1) || (e == 0);
16456         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16457         e_conv = DecodeError_clone(&e_conv);
16458         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
16459         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
16460         return (uint64_t)ret_conv;
16461 }
16462
16463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16464         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
16465         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
16466         return ret_val;
16467 }
16468
16469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16470         if ((_res & 1) != 0) return;
16471         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16472         CHECK_ACCESS(_res_ptr);
16473         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
16474         FREE((void*)_res);
16475         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
16476 }
16477
16478 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
16479         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
16480         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
16481         return (uint64_t)ret_conv;
16482 }
16483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16484         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
16485         int64_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
16486         return ret_val;
16487 }
16488
16489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16490         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
16491         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
16492         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
16493         return (uint64_t)ret_conv;
16494 }
16495
16496 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
16497         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
16498         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
16499         return ((uint64_t)ret_conv);
16500 }
16501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16502         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
16503         int64_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
16504         return ret_val;
16505 }
16506
16507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16508         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
16509         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
16510         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
16511         return ((uint64_t)ret_conv);
16512 }
16513
16514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
16515         LDKOutPoint a_conv;
16516         a_conv.inner = (void*)(a & (~1));
16517         a_conv.is_owned = (a & 1) || (a == 0);
16518         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16519         a_conv = OutPoint_clone(&a_conv);
16520         LDKCVec_u8Z b_ref;
16521         b_ref.datalen = (*env)->GetArrayLength(env, b);
16522         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
16523         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
16524         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
16525         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
16526         return ((uint64_t)ret_conv);
16527 }
16528
16529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16530         if ((_res & 1) != 0) return;
16531         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16532         CHECK_ACCESS(_res_ptr);
16533         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
16534         FREE((void*)_res);
16535         C2Tuple_OutPointScriptZ_free(_res_conv);
16536 }
16537
16538 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
16539         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
16540         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
16541         return ((uint64_t)ret_conv);
16542 }
16543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16544         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
16545         int64_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
16546         return ret_val;
16547 }
16548
16549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16550         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
16551         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
16552         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
16553         return ((uint64_t)ret_conv);
16554 }
16555
16556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
16557         LDKCVec_u8Z b_ref;
16558         b_ref.datalen = (*env)->GetArrayLength(env, b);
16559         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
16560         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
16561         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
16562         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
16563         return ((uint64_t)ret_conv);
16564 }
16565
16566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16567         if ((_res & 1) != 0) return;
16568         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16569         CHECK_ACCESS(_res_ptr);
16570         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
16571         FREE((void*)_res);
16572         C2Tuple_u32ScriptZ_free(_res_conv);
16573 }
16574
16575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16576         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
16577         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16578         if (_res_constr.datalen > 0)
16579                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
16580         else
16581                 _res_constr.data = NULL;
16582         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16583         for (size_t v = 0; v < _res_constr.datalen; v++) {
16584                 int64_t _res_conv_21 = _res_vals[v];
16585                 void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
16586                 CHECK_ACCESS(_res_conv_21_ptr);
16587                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
16588                 FREE((void*)_res_conv_21);
16589                 _res_constr.data[v] = _res_conv_21_conv;
16590         }
16591         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16592         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
16593 }
16594
16595 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
16596         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16597         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
16598         return ((uint64_t)ret_conv);
16599 }
16600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16601         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
16602         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
16603         return ret_val;
16604 }
16605
16606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16607         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
16608         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16609         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
16610         return ((uint64_t)ret_conv);
16611 }
16612
16613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
16614         LDKThirtyTwoBytes a_ref;
16615         CHECK((*env)->GetArrayLength(env, a) == 32);
16616         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
16617         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
16618         b_constr.datalen = (*env)->GetArrayLength(env, b);
16619         if (b_constr.datalen > 0)
16620                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
16621         else
16622                 b_constr.data = NULL;
16623         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
16624         for (size_t v = 0; v < b_constr.datalen; v++) {
16625                 int64_t b_conv_21 = b_vals[v];
16626                 void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
16627                 CHECK_ACCESS(b_conv_21_ptr);
16628                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
16629                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
16630                 b_constr.data[v] = b_conv_21_conv;
16631         }
16632         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
16633         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16634         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
16635         return ((uint64_t)ret_conv);
16636 }
16637
16638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16639         if ((_res & 1) != 0) return;
16640         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16641         CHECK_ACCESS(_res_ptr);
16642         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
16643         FREE((void*)_res);
16644         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
16645 }
16646
16647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16648         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
16649         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16650         if (_res_constr.datalen > 0)
16651                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
16652         else
16653                 _res_constr.data = NULL;
16654         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16655         for (size_t o = 0; o < _res_constr.datalen; o++) {
16656                 int64_t _res_conv_40 = _res_vals[o];
16657                 void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
16658                 CHECK_ACCESS(_res_conv_40_ptr);
16659                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
16660                 FREE((void*)_res_conv_40);
16661                 _res_constr.data[o] = _res_conv_40_conv;
16662         }
16663         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16664         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
16665 }
16666
16667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16668         LDKCVec_EventZ _res_constr;
16669         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16670         if (_res_constr.datalen > 0)
16671                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
16672         else
16673                 _res_constr.data = NULL;
16674         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16675         for (size_t h = 0; h < _res_constr.datalen; h++) {
16676                 int64_t _res_conv_7 = _res_vals[h];
16677                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
16678                 CHECK_ACCESS(_res_conv_7_ptr);
16679                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
16680                 FREE((void*)_res_conv_7);
16681                 _res_constr.data[h] = _res_conv_7_conv;
16682         }
16683         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16684         CVec_EventZ_free(_res_constr);
16685 }
16686
16687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16688         LDKCVec_TransactionZ _res_constr;
16689         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16690         if (_res_constr.datalen > 0)
16691                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
16692         else
16693                 _res_constr.data = NULL;
16694         for (size_t i = 0; i < _res_constr.datalen; i++) {
16695                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16696                 LDKTransaction _res_conv_8_ref;
16697                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
16698                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
16699                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
16700                 _res_conv_8_ref.data_is_owned = true;
16701                 _res_constr.data[i] = _res_conv_8_ref;
16702         }
16703         CVec_TransactionZ_free(_res_constr);
16704 }
16705
16706 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
16707         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16708         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
16709         return ((uint64_t)ret_conv);
16710 }
16711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16712         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
16713         int64_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
16714         return ret_val;
16715 }
16716
16717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16718         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
16719         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16720         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
16721         return ((uint64_t)ret_conv);
16722 }
16723
16724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
16725         void* b_ptr = (void*)(((uint64_t)b) & ~1);
16726         CHECK_ACCESS(b_ptr);
16727         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
16728         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
16729         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16730         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
16731         return ((uint64_t)ret_conv);
16732 }
16733
16734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16735         if ((_res & 1) != 0) return;
16736         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16737         CHECK_ACCESS(_res_ptr);
16738         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
16739         FREE((void*)_res);
16740         C2Tuple_u32TxOutZ_free(_res_conv);
16741 }
16742
16743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16744         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
16745         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16746         if (_res_constr.datalen > 0)
16747                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16748         else
16749                 _res_constr.data = NULL;
16750         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16751         for (size_t u = 0; u < _res_constr.datalen; u++) {
16752                 int64_t _res_conv_20 = _res_vals[u];
16753                 void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
16754                 CHECK_ACCESS(_res_conv_20_ptr);
16755                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
16756                 FREE((void*)_res_conv_20);
16757                 _res_constr.data[u] = _res_conv_20_conv;
16758         }
16759         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16760         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
16761 }
16762
16763 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
16764         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16765         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
16766         return ((uint64_t)ret_conv);
16767 }
16768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16769         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
16770         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
16771         return ret_val;
16772 }
16773
16774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16775         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
16776         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16777         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
16778         return ((uint64_t)ret_conv);
16779 }
16780
16781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
16782         LDKThirtyTwoBytes a_ref;
16783         CHECK((*env)->GetArrayLength(env, a) == 32);
16784         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
16785         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
16786         b_constr.datalen = (*env)->GetArrayLength(env, b);
16787         if (b_constr.datalen > 0)
16788                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16789         else
16790                 b_constr.data = NULL;
16791         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
16792         for (size_t u = 0; u < b_constr.datalen; u++) {
16793                 int64_t b_conv_20 = b_vals[u];
16794                 void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
16795                 CHECK_ACCESS(b_conv_20_ptr);
16796                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
16797                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
16798                 b_constr.data[u] = b_conv_20_conv;
16799         }
16800         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
16801         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16802         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
16803         return ((uint64_t)ret_conv);
16804 }
16805
16806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16807         if ((_res & 1) != 0) return;
16808         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16809         CHECK_ACCESS(_res_ptr);
16810         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
16811         FREE((void*)_res);
16812         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
16813 }
16814
16815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16816         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
16817         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16818         if (_res_constr.datalen > 0)
16819                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
16820         else
16821                 _res_constr.data = NULL;
16822         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16823         for (size_t n = 0; n < _res_constr.datalen; n++) {
16824                 int64_t _res_conv_39 = _res_vals[n];
16825                 void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
16826                 CHECK_ACCESS(_res_conv_39_ptr);
16827                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
16828                 FREE((void*)_res_conv_39);
16829                 _res_constr.data[n] = _res_conv_39_conv;
16830         }
16831         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16832         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
16833 }
16834
16835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16836         LDKCVec_BalanceZ _res_constr;
16837         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16838         if (_res_constr.datalen > 0)
16839                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
16840         else
16841                 _res_constr.data = NULL;
16842         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16843         for (size_t j = 0; j < _res_constr.datalen; j++) {
16844                 int64_t _res_conv_9 = _res_vals[j];
16845                 void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
16846                 CHECK_ACCESS(_res_conv_9_ptr);
16847                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
16848                 FREE((void*)_res_conv_9);
16849                 _res_constr.data[j] = _res_conv_9_conv;
16850         }
16851         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16852         CVec_BalanceZ_free(_res_constr);
16853 }
16854
16855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16856         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16857         CHECK_ACCESS(o_ptr);
16858         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16859         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
16860         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16861         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16862         return (uint64_t)ret_conv;
16863 }
16864
16865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16866         LDKDecodeError e_conv;
16867         e_conv.inner = (void*)(e & (~1));
16868         e_conv.is_owned = (e & 1) || (e == 0);
16869         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16870         e_conv = DecodeError_clone(&e_conv);
16871         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16872         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16873         return (uint64_t)ret_conv;
16874 }
16875
16876 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16877         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16878         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16879         return ret_val;
16880 }
16881
16882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16883         if ((_res & 1) != 0) return;
16884         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16885         CHECK_ACCESS(_res_ptr);
16886         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16887         FREE((void*)_res);
16888         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16889 }
16890
16891 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16892         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16893         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16894         return (uint64_t)ret_conv;
16895 }
16896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16897         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16898         int64_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16899         return ret_val;
16900 }
16901
16902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16903         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16904         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16905         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16906         return (uint64_t)ret_conv;
16907 }
16908
16909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
16910         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16911         *ret_conv = CResult_NoneLightningErrorZ_ok();
16912         return (uint64_t)ret_conv;
16913 }
16914
16915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16916         LDKLightningError e_conv;
16917         e_conv.inner = (void*)(e & (~1));
16918         e_conv.is_owned = (e & 1) || (e == 0);
16919         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16920         e_conv = LightningError_clone(&e_conv);
16921         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16922         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16923         return (uint64_t)ret_conv;
16924 }
16925
16926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16927         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16928         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
16929         return ret_val;
16930 }
16931
16932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16933         if ((_res & 1) != 0) return;
16934         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16935         CHECK_ACCESS(_res_ptr);
16936         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16937         FREE((void*)_res);
16938         CResult_NoneLightningErrorZ_free(_res_conv);
16939 }
16940
16941 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16942         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16943         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16944         return (uint64_t)ret_conv;
16945 }
16946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16947         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16948         int64_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16949         return ret_val;
16950 }
16951
16952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16953         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16954         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16955         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16956         return (uint64_t)ret_conv;
16957 }
16958
16959 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16960         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16961         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16962         return ((uint64_t)ret_conv);
16963 }
16964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16965         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16966         int64_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16967         return ret_val;
16968 }
16969
16970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16971         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16972         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16973         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16974         return ((uint64_t)ret_conv);
16975 }
16976
16977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
16978         LDKPublicKey a_ref;
16979         CHECK((*env)->GetArrayLength(env, a) == 33);
16980         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
16981         void* b_ptr = (void*)(((uint64_t)b) & ~1);
16982         CHECK_ACCESS(b_ptr);
16983         LDKType b_conv = *(LDKType*)(b_ptr);
16984         if (b_conv.free == LDKType_JCalls_free) {
16985                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16986                 LDKType_JCalls_cloned(&b_conv);
16987         }
16988         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16989         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16990         return ((uint64_t)ret_conv);
16991 }
16992
16993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16994         if ((_res & 1) != 0) return;
16995         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16996         CHECK_ACCESS(_res_ptr);
16997         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16998         FREE((void*)_res);
16999         C2Tuple_PublicKeyTypeZ_free(_res_conv);
17000 }
17001
17002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17003         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
17004         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17005         if (_res_constr.datalen > 0)
17006                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
17007         else
17008                 _res_constr.data = NULL;
17009         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17010         for (size_t z = 0; z < _res_constr.datalen; z++) {
17011                 int64_t _res_conv_25 = _res_vals[z];
17012                 void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
17013                 CHECK_ACCESS(_res_conv_25_ptr);
17014                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
17015                 FREE((void*)_res_conv_25);
17016                 _res_constr.data[z] = _res_conv_25_conv;
17017         }
17018         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17019         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
17020 }
17021
17022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
17023         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17024         *ret_conv = CResult_boolLightningErrorZ_ok(o);
17025         return (uint64_t)ret_conv;
17026 }
17027
17028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17029         LDKLightningError e_conv;
17030         e_conv.inner = (void*)(e & (~1));
17031         e_conv.is_owned = (e & 1) || (e == 0);
17032         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17033         e_conv = LightningError_clone(&e_conv);
17034         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17035         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
17036         return (uint64_t)ret_conv;
17037 }
17038
17039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17040         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
17041         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
17042         return ret_val;
17043 }
17044
17045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17046         if ((_res & 1) != 0) return;
17047         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17048         CHECK_ACCESS(_res_ptr);
17049         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
17050         FREE((void*)_res);
17051         CResult_boolLightningErrorZ_free(_res_conv);
17052 }
17053
17054 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
17055         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17056         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
17057         return (uint64_t)ret_conv;
17058 }
17059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17060         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
17061         int64_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
17062         return ret_val;
17063 }
17064
17065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17066         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
17067         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17068         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
17069         return (uint64_t)ret_conv;
17070 }
17071
17072 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
17073         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17074         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
17075         return ((uint64_t)ret_conv);
17076 }
17077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17078         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
17079         int64_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
17080         return ret_val;
17081 }
17082
17083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17084         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
17085         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17086         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
17087         return ((uint64_t)ret_conv);
17088 }
17089
17090 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) {
17091         LDKChannelAnnouncement a_conv;
17092         a_conv.inner = (void*)(a & (~1));
17093         a_conv.is_owned = (a & 1) || (a == 0);
17094         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17095         a_conv = ChannelAnnouncement_clone(&a_conv);
17096         LDKChannelUpdate b_conv;
17097         b_conv.inner = (void*)(b & (~1));
17098         b_conv.is_owned = (b & 1) || (b == 0);
17099         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17100         b_conv = ChannelUpdate_clone(&b_conv);
17101         LDKChannelUpdate c_conv;
17102         c_conv.inner = (void*)(c & (~1));
17103         c_conv.is_owned = (c & 1) || (c == 0);
17104         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17105         c_conv = ChannelUpdate_clone(&c_conv);
17106         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17107         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
17108         return ((uint64_t)ret_conv);
17109 }
17110
17111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17112         if ((_res & 1) != 0) return;
17113         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17114         CHECK_ACCESS(_res_ptr);
17115         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
17116         FREE((void*)_res);
17117         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
17118 }
17119
17120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17121         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
17122         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17123         if (_res_constr.datalen > 0)
17124                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
17125         else
17126                 _res_constr.data = NULL;
17127         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17128         for (size_t h = 0; h < _res_constr.datalen; h++) {
17129                 int64_t _res_conv_59 = _res_vals[h];
17130                 void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
17131                 CHECK_ACCESS(_res_conv_59_ptr);
17132                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
17133                 FREE((void*)_res_conv_59);
17134                 _res_constr.data[h] = _res_conv_59_conv;
17135         }
17136         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17137         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
17138 }
17139
17140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17141         LDKCVec_NodeAnnouncementZ _res_constr;
17142         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17143         if (_res_constr.datalen > 0)
17144                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
17145         else
17146                 _res_constr.data = NULL;
17147         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17148         for (size_t s = 0; s < _res_constr.datalen; s++) {
17149                 int64_t _res_conv_18 = _res_vals[s];
17150                 LDKNodeAnnouncement _res_conv_18_conv;
17151                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
17152                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
17153                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
17154                 _res_constr.data[s] = _res_conv_18_conv;
17155         }
17156         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17157         CVec_NodeAnnouncementZ_free(_res_constr);
17158 }
17159
17160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17161         LDKCVec_PublicKeyZ _res_constr;
17162         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17163         if (_res_constr.datalen > 0)
17164                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
17165         else
17166                 _res_constr.data = NULL;
17167         for (size_t i = 0; i < _res_constr.datalen; i++) {
17168                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17169                 LDKPublicKey _res_conv_8_ref;
17170                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
17171                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
17172                 _res_constr.data[i] = _res_conv_8_ref;
17173         }
17174         CVec_PublicKeyZ_free(_res_constr);
17175 }
17176
17177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17178         LDKCVec_u8Z o_ref;
17179         o_ref.datalen = (*env)->GetArrayLength(env, o);
17180         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
17181         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
17182         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17183         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
17184         return (uint64_t)ret_conv;
17185 }
17186
17187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17188         LDKPeerHandleError e_conv;
17189         e_conv.inner = (void*)(e & (~1));
17190         e_conv.is_owned = (e & 1) || (e == 0);
17191         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17192         e_conv = PeerHandleError_clone(&e_conv);
17193         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17194         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
17195         return (uint64_t)ret_conv;
17196 }
17197
17198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17199         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
17200         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
17201         return ret_val;
17202 }
17203
17204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17205         if ((_res & 1) != 0) return;
17206         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17207         CHECK_ACCESS(_res_ptr);
17208         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
17209         FREE((void*)_res);
17210         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
17211 }
17212
17213 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
17214         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17215         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
17216         return (uint64_t)ret_conv;
17217 }
17218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17219         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
17220         int64_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
17221         return ret_val;
17222 }
17223
17224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17225         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
17226         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17227         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
17228         return (uint64_t)ret_conv;
17229 }
17230
17231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
17232         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17233         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
17234         return (uint64_t)ret_conv;
17235 }
17236
17237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17238         LDKPeerHandleError e_conv;
17239         e_conv.inner = (void*)(e & (~1));
17240         e_conv.is_owned = (e & 1) || (e == 0);
17241         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17242         e_conv = PeerHandleError_clone(&e_conv);
17243         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17244         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
17245         return (uint64_t)ret_conv;
17246 }
17247
17248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17249         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
17250         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
17251         return ret_val;
17252 }
17253
17254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17255         if ((_res & 1) != 0) return;
17256         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17257         CHECK_ACCESS(_res_ptr);
17258         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
17259         FREE((void*)_res);
17260         CResult_NonePeerHandleErrorZ_free(_res_conv);
17261 }
17262
17263 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
17264         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17265         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
17266         return (uint64_t)ret_conv;
17267 }
17268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17269         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
17270         int64_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
17271         return ret_val;
17272 }
17273
17274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17275         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
17276         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17277         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
17278         return (uint64_t)ret_conv;
17279 }
17280
17281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
17282         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17283         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
17284         return (uint64_t)ret_conv;
17285 }
17286
17287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17288         LDKPeerHandleError e_conv;
17289         e_conv.inner = (void*)(e & (~1));
17290         e_conv.is_owned = (e & 1) || (e == 0);
17291         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17292         e_conv = PeerHandleError_clone(&e_conv);
17293         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17294         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
17295         return (uint64_t)ret_conv;
17296 }
17297
17298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17299         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
17300         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
17301         return ret_val;
17302 }
17303
17304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17305         if ((_res & 1) != 0) return;
17306         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17307         CHECK_ACCESS(_res_ptr);
17308         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
17309         FREE((void*)_res);
17310         CResult_boolPeerHandleErrorZ_free(_res_conv);
17311 }
17312
17313 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
17314         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17315         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
17316         return (uint64_t)ret_conv;
17317 }
17318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17319         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
17320         int64_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
17321         return ret_val;
17322 }
17323
17324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17325         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
17326         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17327         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
17328         return (uint64_t)ret_conv;
17329 }
17330
17331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17332         LDKNodeId o_conv;
17333         o_conv.inner = (void*)(o & (~1));
17334         o_conv.is_owned = (o & 1) || (o == 0);
17335         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17336         o_conv = NodeId_clone(&o_conv);
17337         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17338         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
17339         return (uint64_t)ret_conv;
17340 }
17341
17342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17343         LDKDecodeError e_conv;
17344         e_conv.inner = (void*)(e & (~1));
17345         e_conv.is_owned = (e & 1) || (e == 0);
17346         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17347         e_conv = DecodeError_clone(&e_conv);
17348         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17349         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
17350         return (uint64_t)ret_conv;
17351 }
17352
17353 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17354         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
17355         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
17356         return ret_val;
17357 }
17358
17359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17360         if ((_res & 1) != 0) return;
17361         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17362         CHECK_ACCESS(_res_ptr);
17363         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
17364         FREE((void*)_res);
17365         CResult_NodeIdDecodeErrorZ_free(_res_conv);
17366 }
17367
17368 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
17369         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17370         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
17371         return (uint64_t)ret_conv;
17372 }
17373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17374         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
17375         int64_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
17376         return ret_val;
17377 }
17378
17379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17380         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
17381         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17382         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
17383         return (uint64_t)ret_conv;
17384 }
17385
17386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17387         void* o_ptr = (void*)(((uint64_t)o) & ~1);
17388         CHECK_ACCESS(o_ptr);
17389         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
17390         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)o) & ~1));
17391         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17392         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
17393         return (uint64_t)ret_conv;
17394 }
17395
17396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17397         LDKDecodeError e_conv;
17398         e_conv.inner = (void*)(e & (~1));
17399         e_conv.is_owned = (e & 1) || (e == 0);
17400         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17401         e_conv = DecodeError_clone(&e_conv);
17402         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17403         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
17404         return (uint64_t)ret_conv;
17405 }
17406
17407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17408         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
17409         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
17410         return ret_val;
17411 }
17412
17413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17414         if ((_res & 1) != 0) return;
17415         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17416         CHECK_ACCESS(_res_ptr);
17417         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
17418         FREE((void*)_res);
17419         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
17420 }
17421
17422 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
17423         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17424         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
17425         return (uint64_t)ret_conv;
17426 }
17427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17428         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
17429         int64_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
17430         return ret_val;
17431 }
17432
17433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17434         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
17435         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17436         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
17437         return (uint64_t)ret_conv;
17438 }
17439
17440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17441         void* o_ptr = (void*)(((uint64_t)o) & ~1);
17442         CHECK_ACCESS(o_ptr);
17443         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
17444         if (o_conv.free == LDKAccess_JCalls_free) {
17445                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17446                 LDKAccess_JCalls_cloned(&o_conv);
17447         }
17448         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17449         *ret_copy = COption_AccessZ_some(o_conv);
17450         uint64_t ret_ref = (uint64_t)ret_copy;
17451         return ret_ref;
17452 }
17453
17454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
17455         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17456         *ret_copy = COption_AccessZ_none();
17457         uint64_t ret_ref = (uint64_t)ret_copy;
17458         return ret_ref;
17459 }
17460
17461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17462         if ((_res & 1) != 0) return;
17463         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17464         CHECK_ACCESS(_res_ptr);
17465         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
17466         FREE((void*)_res);
17467         COption_AccessZ_free(_res_conv);
17468 }
17469
17470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17471         LDKDirectionalChannelInfo o_conv;
17472         o_conv.inner = (void*)(o & (~1));
17473         o_conv.is_owned = (o & 1) || (o == 0);
17474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17475         o_conv = DirectionalChannelInfo_clone(&o_conv);
17476         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
17477         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
17478         return (uint64_t)ret_conv;
17479 }
17480
17481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17482         LDKDecodeError e_conv;
17483         e_conv.inner = (void*)(e & (~1));
17484         e_conv.is_owned = (e & 1) || (e == 0);
17485         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17486         e_conv = DecodeError_clone(&e_conv);
17487         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
17488         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
17489         return (uint64_t)ret_conv;
17490 }
17491
17492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17493         LDKCResult_DirectionalChannelInfoDecodeErrorZ* o_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(o & ~1);
17494         jboolean ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o_conv);
17495         return ret_val;
17496 }
17497
17498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17499         if ((_res & 1) != 0) return;
17500         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17501         CHECK_ACCESS(_res_ptr);
17502         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
17503         FREE((void*)_res);
17504         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
17505 }
17506
17507 static inline uint64_t CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
17508         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
17509         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(arg);
17510         return (uint64_t)ret_conv;
17511 }
17512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17513         LDKCResult_DirectionalChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
17514         int64_t ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
17515         return ret_val;
17516 }
17517
17518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17519         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
17520         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
17521         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
17522         return (uint64_t)ret_conv;
17523 }
17524
17525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17526         LDKChannelInfo o_conv;
17527         o_conv.inner = (void*)(o & (~1));
17528         o_conv.is_owned = (o & 1) || (o == 0);
17529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17530         o_conv = ChannelInfo_clone(&o_conv);
17531         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17532         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
17533         return (uint64_t)ret_conv;
17534 }
17535
17536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17537         LDKDecodeError e_conv;
17538         e_conv.inner = (void*)(e & (~1));
17539         e_conv.is_owned = (e & 1) || (e == 0);
17540         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17541         e_conv = DecodeError_clone(&e_conv);
17542         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17543         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
17544         return (uint64_t)ret_conv;
17545 }
17546
17547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17548         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
17549         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
17550         return ret_val;
17551 }
17552
17553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17554         if ((_res & 1) != 0) return;
17555         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17556         CHECK_ACCESS(_res_ptr);
17557         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
17558         FREE((void*)_res);
17559         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
17560 }
17561
17562 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
17563         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17564         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
17565         return (uint64_t)ret_conv;
17566 }
17567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17568         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
17569         int64_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
17570         return ret_val;
17571 }
17572
17573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17574         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
17575         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17576         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
17577         return (uint64_t)ret_conv;
17578 }
17579
17580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17581         LDKRoutingFees o_conv;
17582         o_conv.inner = (void*)(o & (~1));
17583         o_conv.is_owned = (o & 1) || (o == 0);
17584         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17585         o_conv = RoutingFees_clone(&o_conv);
17586         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17587         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
17588         return (uint64_t)ret_conv;
17589 }
17590
17591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17592         LDKDecodeError e_conv;
17593         e_conv.inner = (void*)(e & (~1));
17594         e_conv.is_owned = (e & 1) || (e == 0);
17595         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17596         e_conv = DecodeError_clone(&e_conv);
17597         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17598         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
17599         return (uint64_t)ret_conv;
17600 }
17601
17602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17603         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
17604         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
17605         return ret_val;
17606 }
17607
17608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17609         if ((_res & 1) != 0) return;
17610         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17611         CHECK_ACCESS(_res_ptr);
17612         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
17613         FREE((void*)_res);
17614         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
17615 }
17616
17617 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
17618         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17619         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
17620         return (uint64_t)ret_conv;
17621 }
17622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17623         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
17624         int64_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
17625         return ret_val;
17626 }
17627
17628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17629         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
17630         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17631         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
17632         return (uint64_t)ret_conv;
17633 }
17634
17635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17636         LDKNodeAnnouncementInfo o_conv;
17637         o_conv.inner = (void*)(o & (~1));
17638         o_conv.is_owned = (o & 1) || (o == 0);
17639         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17640         o_conv = NodeAnnouncementInfo_clone(&o_conv);
17641         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17642         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
17643         return (uint64_t)ret_conv;
17644 }
17645
17646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17647         LDKDecodeError e_conv;
17648         e_conv.inner = (void*)(e & (~1));
17649         e_conv.is_owned = (e & 1) || (e == 0);
17650         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17651         e_conv = DecodeError_clone(&e_conv);
17652         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17653         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
17654         return (uint64_t)ret_conv;
17655 }
17656
17657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17658         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
17659         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
17660         return ret_val;
17661 }
17662
17663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17664         if ((_res & 1) != 0) return;
17665         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17666         CHECK_ACCESS(_res_ptr);
17667         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
17668         FREE((void*)_res);
17669         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
17670 }
17671
17672 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
17673         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17674         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
17675         return (uint64_t)ret_conv;
17676 }
17677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17678         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
17679         int64_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
17680         return ret_val;
17681 }
17682
17683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17684         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
17685         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17686         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17687         return (uint64_t)ret_conv;
17688 }
17689
17690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17691         LDKCVec_u64Z _res_constr;
17692         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17693         if (_res_constr.datalen > 0)
17694                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17695         else
17696                 _res_constr.data = NULL;
17697         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17698         for (size_t g = 0; g < _res_constr.datalen; g++) {
17699                 int64_t _res_conv_6 = _res_vals[g];
17700                 _res_constr.data[g] = _res_conv_6;
17701         }
17702         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17703         CVec_u64Z_free(_res_constr);
17704 }
17705
17706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17707         LDKNodeInfo o_conv;
17708         o_conv.inner = (void*)(o & (~1));
17709         o_conv.is_owned = (o & 1) || (o == 0);
17710         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17711         o_conv = NodeInfo_clone(&o_conv);
17712         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17713         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17714         return (uint64_t)ret_conv;
17715 }
17716
17717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17718         LDKDecodeError e_conv;
17719         e_conv.inner = (void*)(e & (~1));
17720         e_conv.is_owned = (e & 1) || (e == 0);
17721         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17722         e_conv = DecodeError_clone(&e_conv);
17723         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17724         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17725         return (uint64_t)ret_conv;
17726 }
17727
17728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17729         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
17730         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17731         return ret_val;
17732 }
17733
17734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17735         if ((_res & 1) != 0) return;
17736         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17737         CHECK_ACCESS(_res_ptr);
17738         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17739         FREE((void*)_res);
17740         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17741 }
17742
17743 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17744         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17745         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17746         return (uint64_t)ret_conv;
17747 }
17748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17749         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17750         int64_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17751         return ret_val;
17752 }
17753
17754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17755         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17756         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17757         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17758         return (uint64_t)ret_conv;
17759 }
17760
17761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17762         LDKNetworkGraph o_conv;
17763         o_conv.inner = (void*)(o & (~1));
17764         o_conv.is_owned = (o & 1) || (o == 0);
17765         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17766         o_conv = NetworkGraph_clone(&o_conv);
17767         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17768         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17769         return (uint64_t)ret_conv;
17770 }
17771
17772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17773         LDKDecodeError e_conv;
17774         e_conv.inner = (void*)(e & (~1));
17775         e_conv.is_owned = (e & 1) || (e == 0);
17776         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17777         e_conv = DecodeError_clone(&e_conv);
17778         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17779         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17780         return (uint64_t)ret_conv;
17781 }
17782
17783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17784         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
17785         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17786         return ret_val;
17787 }
17788
17789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17790         if ((_res & 1) != 0) return;
17791         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17792         CHECK_ACCESS(_res_ptr);
17793         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17794         FREE((void*)_res);
17795         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17796 }
17797
17798 static inline uint64_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
17799         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17800         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
17801         return (uint64_t)ret_conv;
17802 }
17803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17804         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
17805         int64_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
17806         return ret_val;
17807 }
17808
17809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17810         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
17811         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17812         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
17813         return (uint64_t)ret_conv;
17814 }
17815
17816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
17817         LDKCVec_NetAddressZ o_constr;
17818         o_constr.datalen = (*env)->GetArrayLength(env, o);
17819         if (o_constr.datalen > 0)
17820                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17821         else
17822                 o_constr.data = NULL;
17823         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17824         for (size_t m = 0; m < o_constr.datalen; m++) {
17825                 int64_t o_conv_12 = o_vals[m];
17826                 void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
17827                 CHECK_ACCESS(o_conv_12_ptr);
17828                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17829                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
17830                 o_constr.data[m] = o_conv_12_conv;
17831         }
17832         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17833         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17834         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17835         uint64_t ret_ref = (uint64_t)ret_copy;
17836         return ret_ref;
17837 }
17838
17839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
17840         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17841         *ret_copy = COption_CVec_NetAddressZZ_none();
17842         uint64_t ret_ref = (uint64_t)ret_copy;
17843         return ret_ref;
17844 }
17845
17846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17847         if ((_res & 1) != 0) return;
17848         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17849         CHECK_ACCESS(_res_ptr);
17850         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17851         FREE((void*)_res);
17852         COption_CVec_NetAddressZZ_free(_res_conv);
17853 }
17854
17855 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17856         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17857         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17858 uint64_t ret_ref = (uint64_t)ret_copy;
17859         return ret_ref;
17860 }
17861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17862         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17863         int64_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17864         return ret_val;
17865 }
17866
17867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17868         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17869         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17870         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17871         uint64_t ret_ref = (uint64_t)ret_copy;
17872         return ret_ref;
17873 }
17874
17875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17876         void* o_ptr = (void*)(((uint64_t)o) & ~1);
17877         CHECK_ACCESS(o_ptr);
17878         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17879         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
17880         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17881         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17882         return (uint64_t)ret_conv;
17883 }
17884
17885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17886         LDKDecodeError e_conv;
17887         e_conv.inner = (void*)(e & (~1));
17888         e_conv.is_owned = (e & 1) || (e == 0);
17889         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17890         e_conv = DecodeError_clone(&e_conv);
17891         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17892         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17893         return (uint64_t)ret_conv;
17894 }
17895
17896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17897         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17898         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17899         return ret_val;
17900 }
17901
17902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17903         if ((_res & 1) != 0) return;
17904         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17905         CHECK_ACCESS(_res_ptr);
17906         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17907         FREE((void*)_res);
17908         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17909 }
17910
17911 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17912         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17913         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17914         return (uint64_t)ret_conv;
17915 }
17916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17917         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17918         int64_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17919         return ret_val;
17920 }
17921
17922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17923         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17924         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17925         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17926         return (uint64_t)ret_conv;
17927 }
17928
17929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17930         LDKCVec_UpdateAddHTLCZ _res_constr;
17931         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17932         if (_res_constr.datalen > 0)
17933                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17934         else
17935                 _res_constr.data = NULL;
17936         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17937         for (size_t p = 0; p < _res_constr.datalen; p++) {
17938                 int64_t _res_conv_15 = _res_vals[p];
17939                 LDKUpdateAddHTLC _res_conv_15_conv;
17940                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17941                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17942                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17943                 _res_constr.data[p] = _res_conv_15_conv;
17944         }
17945         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17946         CVec_UpdateAddHTLCZ_free(_res_constr);
17947 }
17948
17949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17950         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17951         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17952         if (_res_constr.datalen > 0)
17953                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17954         else
17955                 _res_constr.data = NULL;
17956         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17957         for (size_t t = 0; t < _res_constr.datalen; t++) {
17958                 int64_t _res_conv_19 = _res_vals[t];
17959                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17960                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17961                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17962                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17963                 _res_constr.data[t] = _res_conv_19_conv;
17964         }
17965         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17966         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17967 }
17968
17969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17970         LDKCVec_UpdateFailHTLCZ _res_constr;
17971         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17972         if (_res_constr.datalen > 0)
17973                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17974         else
17975                 _res_constr.data = NULL;
17976         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17977         for (size_t q = 0; q < _res_constr.datalen; q++) {
17978                 int64_t _res_conv_16 = _res_vals[q];
17979                 LDKUpdateFailHTLC _res_conv_16_conv;
17980                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17981                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17982                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17983                 _res_constr.data[q] = _res_conv_16_conv;
17984         }
17985         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17986         CVec_UpdateFailHTLCZ_free(_res_constr);
17987 }
17988
17989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17990         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17991         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17992         if (_res_constr.datalen > 0)
17993                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17994         else
17995                 _res_constr.data = NULL;
17996         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17997         for (size_t z = 0; z < _res_constr.datalen; z++) {
17998                 int64_t _res_conv_25 = _res_vals[z];
17999                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
18000                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
18001                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
18002                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
18003                 _res_constr.data[z] = _res_conv_25_conv;
18004         }
18005         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18006         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
18007 }
18008
18009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18010         LDKAcceptChannel o_conv;
18011         o_conv.inner = (void*)(o & (~1));
18012         o_conv.is_owned = (o & 1) || (o == 0);
18013         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18014         o_conv = AcceptChannel_clone(&o_conv);
18015         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18016         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
18017         return (uint64_t)ret_conv;
18018 }
18019
18020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18021         LDKDecodeError e_conv;
18022         e_conv.inner = (void*)(e & (~1));
18023         e_conv.is_owned = (e & 1) || (e == 0);
18024         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18025         e_conv = DecodeError_clone(&e_conv);
18026         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18027         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
18028         return (uint64_t)ret_conv;
18029 }
18030
18031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18032         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
18033         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
18034         return ret_val;
18035 }
18036
18037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18038         if ((_res & 1) != 0) return;
18039         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18040         CHECK_ACCESS(_res_ptr);
18041         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
18042         FREE((void*)_res);
18043         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
18044 }
18045
18046 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
18047         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18048         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
18049         return (uint64_t)ret_conv;
18050 }
18051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18052         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
18053         int64_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
18054         return ret_val;
18055 }
18056
18057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18058         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
18059         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18060         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
18061         return (uint64_t)ret_conv;
18062 }
18063
18064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18065         LDKAnnouncementSignatures o_conv;
18066         o_conv.inner = (void*)(o & (~1));
18067         o_conv.is_owned = (o & 1) || (o == 0);
18068         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18069         o_conv = AnnouncementSignatures_clone(&o_conv);
18070         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18071         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
18072         return (uint64_t)ret_conv;
18073 }
18074
18075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18076         LDKDecodeError e_conv;
18077         e_conv.inner = (void*)(e & (~1));
18078         e_conv.is_owned = (e & 1) || (e == 0);
18079         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18080         e_conv = DecodeError_clone(&e_conv);
18081         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18082         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
18083         return (uint64_t)ret_conv;
18084 }
18085
18086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18087         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
18088         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
18089         return ret_val;
18090 }
18091
18092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18093         if ((_res & 1) != 0) return;
18094         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18095         CHECK_ACCESS(_res_ptr);
18096         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
18097         FREE((void*)_res);
18098         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
18099 }
18100
18101 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
18102         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18103         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
18104         return (uint64_t)ret_conv;
18105 }
18106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18107         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
18108         int64_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
18109         return ret_val;
18110 }
18111
18112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18113         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
18114         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18115         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
18116         return (uint64_t)ret_conv;
18117 }
18118
18119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18120         LDKChannelReestablish o_conv;
18121         o_conv.inner = (void*)(o & (~1));
18122         o_conv.is_owned = (o & 1) || (o == 0);
18123         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18124         o_conv = ChannelReestablish_clone(&o_conv);
18125         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18126         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
18127         return (uint64_t)ret_conv;
18128 }
18129
18130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18131         LDKDecodeError e_conv;
18132         e_conv.inner = (void*)(e & (~1));
18133         e_conv.is_owned = (e & 1) || (e == 0);
18134         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18135         e_conv = DecodeError_clone(&e_conv);
18136         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18137         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
18138         return (uint64_t)ret_conv;
18139 }
18140
18141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18142         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
18143         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
18144         return ret_val;
18145 }
18146
18147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18148         if ((_res & 1) != 0) return;
18149         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18150         CHECK_ACCESS(_res_ptr);
18151         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
18152         FREE((void*)_res);
18153         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
18154 }
18155
18156 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
18157         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18158         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
18159         return (uint64_t)ret_conv;
18160 }
18161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18162         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
18163         int64_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
18164         return ret_val;
18165 }
18166
18167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18168         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
18169         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18170         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
18171         return (uint64_t)ret_conv;
18172 }
18173
18174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18175         LDKClosingSigned o_conv;
18176         o_conv.inner = (void*)(o & (~1));
18177         o_conv.is_owned = (o & 1) || (o == 0);
18178         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18179         o_conv = ClosingSigned_clone(&o_conv);
18180         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18181         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
18182         return (uint64_t)ret_conv;
18183 }
18184
18185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18186         LDKDecodeError e_conv;
18187         e_conv.inner = (void*)(e & (~1));
18188         e_conv.is_owned = (e & 1) || (e == 0);
18189         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18190         e_conv = DecodeError_clone(&e_conv);
18191         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18192         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
18193         return (uint64_t)ret_conv;
18194 }
18195
18196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18197         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
18198         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
18199         return ret_val;
18200 }
18201
18202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18203         if ((_res & 1) != 0) return;
18204         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18205         CHECK_ACCESS(_res_ptr);
18206         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
18207         FREE((void*)_res);
18208         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
18209 }
18210
18211 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
18212         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18213         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
18214         return (uint64_t)ret_conv;
18215 }
18216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18217         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
18218         int64_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
18219         return ret_val;
18220 }
18221
18222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18223         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
18224         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18225         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
18226         return (uint64_t)ret_conv;
18227 }
18228
18229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18230         LDKClosingSignedFeeRange o_conv;
18231         o_conv.inner = (void*)(o & (~1));
18232         o_conv.is_owned = (o & 1) || (o == 0);
18233         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18234         o_conv = ClosingSignedFeeRange_clone(&o_conv);
18235         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18236         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
18237         return (uint64_t)ret_conv;
18238 }
18239
18240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18241         LDKDecodeError e_conv;
18242         e_conv.inner = (void*)(e & (~1));
18243         e_conv.is_owned = (e & 1) || (e == 0);
18244         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18245         e_conv = DecodeError_clone(&e_conv);
18246         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18247         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
18248         return (uint64_t)ret_conv;
18249 }
18250
18251 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18252         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
18253         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
18254         return ret_val;
18255 }
18256
18257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18258         if ((_res & 1) != 0) return;
18259         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18260         CHECK_ACCESS(_res_ptr);
18261         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
18262         FREE((void*)_res);
18263         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
18264 }
18265
18266 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
18267         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18268         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
18269         return (uint64_t)ret_conv;
18270 }
18271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18272         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
18273         int64_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
18274         return ret_val;
18275 }
18276
18277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18278         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
18279         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18280         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
18281         return (uint64_t)ret_conv;
18282 }
18283
18284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18285         LDKCommitmentSigned o_conv;
18286         o_conv.inner = (void*)(o & (~1));
18287         o_conv.is_owned = (o & 1) || (o == 0);
18288         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18289         o_conv = CommitmentSigned_clone(&o_conv);
18290         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18291         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
18292         return (uint64_t)ret_conv;
18293 }
18294
18295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18296         LDKDecodeError e_conv;
18297         e_conv.inner = (void*)(e & (~1));
18298         e_conv.is_owned = (e & 1) || (e == 0);
18299         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18300         e_conv = DecodeError_clone(&e_conv);
18301         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18302         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
18303         return (uint64_t)ret_conv;
18304 }
18305
18306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18307         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
18308         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
18309         return ret_val;
18310 }
18311
18312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18313         if ((_res & 1) != 0) return;
18314         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18315         CHECK_ACCESS(_res_ptr);
18316         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
18317         FREE((void*)_res);
18318         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
18319 }
18320
18321 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
18322         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18323         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
18324         return (uint64_t)ret_conv;
18325 }
18326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18327         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
18328         int64_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
18329         return ret_val;
18330 }
18331
18332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18333         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
18334         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18335         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
18336         return (uint64_t)ret_conv;
18337 }
18338
18339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18340         LDKFundingCreated o_conv;
18341         o_conv.inner = (void*)(o & (~1));
18342         o_conv.is_owned = (o & 1) || (o == 0);
18343         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18344         o_conv = FundingCreated_clone(&o_conv);
18345         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18346         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
18347         return (uint64_t)ret_conv;
18348 }
18349
18350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18351         LDKDecodeError e_conv;
18352         e_conv.inner = (void*)(e & (~1));
18353         e_conv.is_owned = (e & 1) || (e == 0);
18354         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18355         e_conv = DecodeError_clone(&e_conv);
18356         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18357         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
18358         return (uint64_t)ret_conv;
18359 }
18360
18361 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18362         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
18363         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
18364         return ret_val;
18365 }
18366
18367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18368         if ((_res & 1) != 0) return;
18369         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18370         CHECK_ACCESS(_res_ptr);
18371         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
18372         FREE((void*)_res);
18373         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
18374 }
18375
18376 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
18377         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18378         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
18379         return (uint64_t)ret_conv;
18380 }
18381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18382         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
18383         int64_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
18384         return ret_val;
18385 }
18386
18387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18388         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
18389         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18390         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
18391         return (uint64_t)ret_conv;
18392 }
18393
18394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18395         LDKFundingSigned o_conv;
18396         o_conv.inner = (void*)(o & (~1));
18397         o_conv.is_owned = (o & 1) || (o == 0);
18398         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18399         o_conv = FundingSigned_clone(&o_conv);
18400         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18401         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
18402         return (uint64_t)ret_conv;
18403 }
18404
18405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18406         LDKDecodeError e_conv;
18407         e_conv.inner = (void*)(e & (~1));
18408         e_conv.is_owned = (e & 1) || (e == 0);
18409         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18410         e_conv = DecodeError_clone(&e_conv);
18411         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18412         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
18413         return (uint64_t)ret_conv;
18414 }
18415
18416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18417         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
18418         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
18419         return ret_val;
18420 }
18421
18422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18423         if ((_res & 1) != 0) return;
18424         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18425         CHECK_ACCESS(_res_ptr);
18426         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
18427         FREE((void*)_res);
18428         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
18429 }
18430
18431 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
18432         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18433         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
18434         return (uint64_t)ret_conv;
18435 }
18436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18437         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
18438         int64_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
18439         return ret_val;
18440 }
18441
18442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18443         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
18444         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18445         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
18446         return (uint64_t)ret_conv;
18447 }
18448
18449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18450         LDKFundingLocked o_conv;
18451         o_conv.inner = (void*)(o & (~1));
18452         o_conv.is_owned = (o & 1) || (o == 0);
18453         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18454         o_conv = FundingLocked_clone(&o_conv);
18455         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
18456         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
18457         return (uint64_t)ret_conv;
18458 }
18459
18460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18461         LDKDecodeError e_conv;
18462         e_conv.inner = (void*)(e & (~1));
18463         e_conv.is_owned = (e & 1) || (e == 0);
18464         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18465         e_conv = DecodeError_clone(&e_conv);
18466         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
18467         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
18468         return (uint64_t)ret_conv;
18469 }
18470
18471 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18472         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
18473         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
18474         return ret_val;
18475 }
18476
18477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18478         if ((_res & 1) != 0) return;
18479         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18480         CHECK_ACCESS(_res_ptr);
18481         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
18482         FREE((void*)_res);
18483         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
18484 }
18485
18486 static inline uint64_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
18487         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
18488         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
18489         return (uint64_t)ret_conv;
18490 }
18491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18492         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
18493         int64_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
18494         return ret_val;
18495 }
18496
18497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18498         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
18499         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
18500         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
18501         return (uint64_t)ret_conv;
18502 }
18503
18504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18505         LDKInit o_conv;
18506         o_conv.inner = (void*)(o & (~1));
18507         o_conv.is_owned = (o & 1) || (o == 0);
18508         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18509         o_conv = Init_clone(&o_conv);
18510         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18511         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
18512         return (uint64_t)ret_conv;
18513 }
18514
18515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18516         LDKDecodeError e_conv;
18517         e_conv.inner = (void*)(e & (~1));
18518         e_conv.is_owned = (e & 1) || (e == 0);
18519         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18520         e_conv = DecodeError_clone(&e_conv);
18521         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18522         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
18523         return (uint64_t)ret_conv;
18524 }
18525
18526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18527         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
18528         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
18529         return ret_val;
18530 }
18531
18532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18533         if ((_res & 1) != 0) return;
18534         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18535         CHECK_ACCESS(_res_ptr);
18536         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
18537         FREE((void*)_res);
18538         CResult_InitDecodeErrorZ_free(_res_conv);
18539 }
18540
18541 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
18542         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18543         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
18544         return (uint64_t)ret_conv;
18545 }
18546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18547         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
18548         int64_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
18549         return ret_val;
18550 }
18551
18552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18553         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
18554         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18555         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
18556         return (uint64_t)ret_conv;
18557 }
18558
18559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18560         LDKOpenChannel o_conv;
18561         o_conv.inner = (void*)(o & (~1));
18562         o_conv.is_owned = (o & 1) || (o == 0);
18563         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18564         o_conv = OpenChannel_clone(&o_conv);
18565         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18566         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
18567         return (uint64_t)ret_conv;
18568 }
18569
18570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18571         LDKDecodeError e_conv;
18572         e_conv.inner = (void*)(e & (~1));
18573         e_conv.is_owned = (e & 1) || (e == 0);
18574         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18575         e_conv = DecodeError_clone(&e_conv);
18576         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18577         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
18578         return (uint64_t)ret_conv;
18579 }
18580
18581 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18582         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
18583         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
18584         return ret_val;
18585 }
18586
18587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18588         if ((_res & 1) != 0) return;
18589         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18590         CHECK_ACCESS(_res_ptr);
18591         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
18592         FREE((void*)_res);
18593         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
18594 }
18595
18596 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
18597         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18598         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
18599         return (uint64_t)ret_conv;
18600 }
18601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18602         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
18603         int64_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
18604         return ret_val;
18605 }
18606
18607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18608         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
18609         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18610         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
18611         return (uint64_t)ret_conv;
18612 }
18613
18614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18615         LDKRevokeAndACK o_conv;
18616         o_conv.inner = (void*)(o & (~1));
18617         o_conv.is_owned = (o & 1) || (o == 0);
18618         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18619         o_conv = RevokeAndACK_clone(&o_conv);
18620         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18621         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
18622         return (uint64_t)ret_conv;
18623 }
18624
18625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18626         LDKDecodeError e_conv;
18627         e_conv.inner = (void*)(e & (~1));
18628         e_conv.is_owned = (e & 1) || (e == 0);
18629         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18630         e_conv = DecodeError_clone(&e_conv);
18631         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18632         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
18633         return (uint64_t)ret_conv;
18634 }
18635
18636 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18637         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
18638         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
18639         return ret_val;
18640 }
18641
18642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18643         if ((_res & 1) != 0) return;
18644         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18645         CHECK_ACCESS(_res_ptr);
18646         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
18647         FREE((void*)_res);
18648         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
18649 }
18650
18651 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
18652         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18653         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
18654         return (uint64_t)ret_conv;
18655 }
18656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18657         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
18658         int64_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
18659         return ret_val;
18660 }
18661
18662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18663         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
18664         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18665         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
18666         return (uint64_t)ret_conv;
18667 }
18668
18669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18670         LDKShutdown o_conv;
18671         o_conv.inner = (void*)(o & (~1));
18672         o_conv.is_owned = (o & 1) || (o == 0);
18673         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18674         o_conv = Shutdown_clone(&o_conv);
18675         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18676         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
18677         return (uint64_t)ret_conv;
18678 }
18679
18680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18681         LDKDecodeError e_conv;
18682         e_conv.inner = (void*)(e & (~1));
18683         e_conv.is_owned = (e & 1) || (e == 0);
18684         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18685         e_conv = DecodeError_clone(&e_conv);
18686         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18687         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
18688         return (uint64_t)ret_conv;
18689 }
18690
18691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18692         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
18693         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
18694         return ret_val;
18695 }
18696
18697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18698         if ((_res & 1) != 0) return;
18699         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18700         CHECK_ACCESS(_res_ptr);
18701         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
18702         FREE((void*)_res);
18703         CResult_ShutdownDecodeErrorZ_free(_res_conv);
18704 }
18705
18706 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
18707         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18708         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
18709         return (uint64_t)ret_conv;
18710 }
18711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18712         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
18713         int64_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
18714         return ret_val;
18715 }
18716
18717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18718         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
18719         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18720         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
18721         return (uint64_t)ret_conv;
18722 }
18723
18724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18725         LDKUpdateFailHTLC o_conv;
18726         o_conv.inner = (void*)(o & (~1));
18727         o_conv.is_owned = (o & 1) || (o == 0);
18728         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18729         o_conv = UpdateFailHTLC_clone(&o_conv);
18730         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18731         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
18732         return (uint64_t)ret_conv;
18733 }
18734
18735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18736         LDKDecodeError e_conv;
18737         e_conv.inner = (void*)(e & (~1));
18738         e_conv.is_owned = (e & 1) || (e == 0);
18739         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18740         e_conv = DecodeError_clone(&e_conv);
18741         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18742         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
18743         return (uint64_t)ret_conv;
18744 }
18745
18746 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18747         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
18748         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
18749         return ret_val;
18750 }
18751
18752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18753         if ((_res & 1) != 0) return;
18754         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18755         CHECK_ACCESS(_res_ptr);
18756         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
18757         FREE((void*)_res);
18758         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
18759 }
18760
18761 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
18762         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18763         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
18764         return (uint64_t)ret_conv;
18765 }
18766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18767         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
18768         int64_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
18769         return ret_val;
18770 }
18771
18772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18773         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
18774         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18775         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
18776         return (uint64_t)ret_conv;
18777 }
18778
18779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18780         LDKUpdateFailMalformedHTLC o_conv;
18781         o_conv.inner = (void*)(o & (~1));
18782         o_conv.is_owned = (o & 1) || (o == 0);
18783         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18784         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
18785         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18786         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
18787         return (uint64_t)ret_conv;
18788 }
18789
18790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18791         LDKDecodeError e_conv;
18792         e_conv.inner = (void*)(e & (~1));
18793         e_conv.is_owned = (e & 1) || (e == 0);
18794         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18795         e_conv = DecodeError_clone(&e_conv);
18796         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18797         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
18798         return (uint64_t)ret_conv;
18799 }
18800
18801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18802         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
18803         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
18804         return ret_val;
18805 }
18806
18807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18808         if ((_res & 1) != 0) return;
18809         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18810         CHECK_ACCESS(_res_ptr);
18811         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
18812         FREE((void*)_res);
18813         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
18814 }
18815
18816 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
18817         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18818         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
18819         return (uint64_t)ret_conv;
18820 }
18821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18822         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
18823         int64_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
18824         return ret_val;
18825 }
18826
18827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18828         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
18829         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18830         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
18831         return (uint64_t)ret_conv;
18832 }
18833
18834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18835         LDKUpdateFee o_conv;
18836         o_conv.inner = (void*)(o & (~1));
18837         o_conv.is_owned = (o & 1) || (o == 0);
18838         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18839         o_conv = UpdateFee_clone(&o_conv);
18840         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18841         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18842         return (uint64_t)ret_conv;
18843 }
18844
18845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18846         LDKDecodeError e_conv;
18847         e_conv.inner = (void*)(e & (~1));
18848         e_conv.is_owned = (e & 1) || (e == 0);
18849         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18850         e_conv = DecodeError_clone(&e_conv);
18851         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18852         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18853         return (uint64_t)ret_conv;
18854 }
18855
18856 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18857         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18858         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18859         return ret_val;
18860 }
18861
18862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18863         if ((_res & 1) != 0) return;
18864         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18865         CHECK_ACCESS(_res_ptr);
18866         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18867         FREE((void*)_res);
18868         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18869 }
18870
18871 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18872         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18873         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18874         return (uint64_t)ret_conv;
18875 }
18876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18877         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18878         int64_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18879         return ret_val;
18880 }
18881
18882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18883         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18884         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18885         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18886         return (uint64_t)ret_conv;
18887 }
18888
18889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18890         LDKUpdateFulfillHTLC 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 = UpdateFulfillHTLC_clone(&o_conv);
18895         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18896         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18897         return (uint64_t)ret_conv;
18898 }
18899
18900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18901         LDKDecodeError e_conv;
18902         e_conv.inner = (void*)(e & (~1));
18903         e_conv.is_owned = (e & 1) || (e == 0);
18904         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18905         e_conv = DecodeError_clone(&e_conv);
18906         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18907         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18908         return (uint64_t)ret_conv;
18909 }
18910
18911 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18912         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18913         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18914         return ret_val;
18915 }
18916
18917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18918         if ((_res & 1) != 0) return;
18919         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18920         CHECK_ACCESS(_res_ptr);
18921         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18922         FREE((void*)_res);
18923         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18924 }
18925
18926 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18927         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18928         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18929         return (uint64_t)ret_conv;
18930 }
18931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18932         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18933         int64_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18934         return ret_val;
18935 }
18936
18937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18938         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18939         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18940         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18941         return (uint64_t)ret_conv;
18942 }
18943
18944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18945         LDKUpdateAddHTLC o_conv;
18946         o_conv.inner = (void*)(o & (~1));
18947         o_conv.is_owned = (o & 1) || (o == 0);
18948         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18949         o_conv = UpdateAddHTLC_clone(&o_conv);
18950         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18951         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18952         return (uint64_t)ret_conv;
18953 }
18954
18955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18956         LDKDecodeError e_conv;
18957         e_conv.inner = (void*)(e & (~1));
18958         e_conv.is_owned = (e & 1) || (e == 0);
18959         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18960         e_conv = DecodeError_clone(&e_conv);
18961         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18962         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18963         return (uint64_t)ret_conv;
18964 }
18965
18966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18967         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18968         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18969         return ret_val;
18970 }
18971
18972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18973         if ((_res & 1) != 0) return;
18974         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18975         CHECK_ACCESS(_res_ptr);
18976         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18977         FREE((void*)_res);
18978         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18979 }
18980
18981 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18982         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18983         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18984         return (uint64_t)ret_conv;
18985 }
18986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18987         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18988         int64_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18989         return ret_val;
18990 }
18991
18992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18993         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18994         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18995         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18996         return (uint64_t)ret_conv;
18997 }
18998
18999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19000         LDKPing o_conv;
19001         o_conv.inner = (void*)(o & (~1));
19002         o_conv.is_owned = (o & 1) || (o == 0);
19003         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19004         o_conv = Ping_clone(&o_conv);
19005         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19006         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
19007         return (uint64_t)ret_conv;
19008 }
19009
19010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19011         LDKDecodeError e_conv;
19012         e_conv.inner = (void*)(e & (~1));
19013         e_conv.is_owned = (e & 1) || (e == 0);
19014         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19015         e_conv = DecodeError_clone(&e_conv);
19016         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19017         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
19018         return (uint64_t)ret_conv;
19019 }
19020
19021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19022         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
19023         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
19024         return ret_val;
19025 }
19026
19027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19028         if ((_res & 1) != 0) return;
19029         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19030         CHECK_ACCESS(_res_ptr);
19031         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
19032         FREE((void*)_res);
19033         CResult_PingDecodeErrorZ_free(_res_conv);
19034 }
19035
19036 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
19037         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19038         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
19039         return (uint64_t)ret_conv;
19040 }
19041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19042         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
19043         int64_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
19044         return ret_val;
19045 }
19046
19047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19048         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
19049         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19050         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
19051         return (uint64_t)ret_conv;
19052 }
19053
19054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19055         LDKPong o_conv;
19056         o_conv.inner = (void*)(o & (~1));
19057         o_conv.is_owned = (o & 1) || (o == 0);
19058         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19059         o_conv = Pong_clone(&o_conv);
19060         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19061         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
19062         return (uint64_t)ret_conv;
19063 }
19064
19065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19066         LDKDecodeError e_conv;
19067         e_conv.inner = (void*)(e & (~1));
19068         e_conv.is_owned = (e & 1) || (e == 0);
19069         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19070         e_conv = DecodeError_clone(&e_conv);
19071         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19072         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
19073         return (uint64_t)ret_conv;
19074 }
19075
19076 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19077         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
19078         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
19079         return ret_val;
19080 }
19081
19082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19083         if ((_res & 1) != 0) return;
19084         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19085         CHECK_ACCESS(_res_ptr);
19086         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
19087         FREE((void*)_res);
19088         CResult_PongDecodeErrorZ_free(_res_conv);
19089 }
19090
19091 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
19092         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19093         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
19094         return (uint64_t)ret_conv;
19095 }
19096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19097         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
19098         int64_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
19099         return ret_val;
19100 }
19101
19102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19103         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
19104         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19105         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
19106         return (uint64_t)ret_conv;
19107 }
19108
19109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19110         LDKUnsignedChannelAnnouncement o_conv;
19111         o_conv.inner = (void*)(o & (~1));
19112         o_conv.is_owned = (o & 1) || (o == 0);
19113         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19114         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
19115         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19116         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
19117         return (uint64_t)ret_conv;
19118 }
19119
19120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19121         LDKDecodeError e_conv;
19122         e_conv.inner = (void*)(e & (~1));
19123         e_conv.is_owned = (e & 1) || (e == 0);
19124         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19125         e_conv = DecodeError_clone(&e_conv);
19126         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19127         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
19128         return (uint64_t)ret_conv;
19129 }
19130
19131 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19132         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
19133         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19134         return ret_val;
19135 }
19136
19137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19138         if ((_res & 1) != 0) return;
19139         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19140         CHECK_ACCESS(_res_ptr);
19141         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19142         FREE((void*)_res);
19143         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
19144 }
19145
19146 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19147         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19148         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
19149         return (uint64_t)ret_conv;
19150 }
19151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19152         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19153         int64_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19154         return ret_val;
19155 }
19156
19157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19158         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19159         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19160         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19161         return (uint64_t)ret_conv;
19162 }
19163
19164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19165         LDKChannelAnnouncement o_conv;
19166         o_conv.inner = (void*)(o & (~1));
19167         o_conv.is_owned = (o & 1) || (o == 0);
19168         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19169         o_conv = ChannelAnnouncement_clone(&o_conv);
19170         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19171         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
19172         return (uint64_t)ret_conv;
19173 }
19174
19175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19176         LDKDecodeError e_conv;
19177         e_conv.inner = (void*)(e & (~1));
19178         e_conv.is_owned = (e & 1) || (e == 0);
19179         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19180         e_conv = DecodeError_clone(&e_conv);
19181         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19182         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
19183         return (uint64_t)ret_conv;
19184 }
19185
19186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19187         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
19188         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19189         return ret_val;
19190 }
19191
19192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19193         if ((_res & 1) != 0) return;
19194         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19195         CHECK_ACCESS(_res_ptr);
19196         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19197         FREE((void*)_res);
19198         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
19199 }
19200
19201 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19202         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19203         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
19204         return (uint64_t)ret_conv;
19205 }
19206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19207         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19208         int64_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19209         return ret_val;
19210 }
19211
19212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19213         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19214         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19215         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19216         return (uint64_t)ret_conv;
19217 }
19218
19219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19220         LDKUnsignedChannelUpdate o_conv;
19221         o_conv.inner = (void*)(o & (~1));
19222         o_conv.is_owned = (o & 1) || (o == 0);
19223         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19224         o_conv = UnsignedChannelUpdate_clone(&o_conv);
19225         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19226         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
19227         return (uint64_t)ret_conv;
19228 }
19229
19230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19231         LDKDecodeError e_conv;
19232         e_conv.inner = (void*)(e & (~1));
19233         e_conv.is_owned = (e & 1) || (e == 0);
19234         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19235         e_conv = DecodeError_clone(&e_conv);
19236         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19237         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
19238         return (uint64_t)ret_conv;
19239 }
19240
19241 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19242         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
19243         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
19244         return ret_val;
19245 }
19246
19247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19248         if ((_res & 1) != 0) return;
19249         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19250         CHECK_ACCESS(_res_ptr);
19251         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
19252         FREE((void*)_res);
19253         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
19254 }
19255
19256 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19257         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19258         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
19259         return (uint64_t)ret_conv;
19260 }
19261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19262         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
19263         int64_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19264         return ret_val;
19265 }
19266
19267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19268         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
19269         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19270         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
19271         return (uint64_t)ret_conv;
19272 }
19273
19274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19275         LDKChannelUpdate o_conv;
19276         o_conv.inner = (void*)(o & (~1));
19277         o_conv.is_owned = (o & 1) || (o == 0);
19278         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19279         o_conv = ChannelUpdate_clone(&o_conv);
19280         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19281         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
19282         return (uint64_t)ret_conv;
19283 }
19284
19285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19286         LDKDecodeError e_conv;
19287         e_conv.inner = (void*)(e & (~1));
19288         e_conv.is_owned = (e & 1) || (e == 0);
19289         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19290         e_conv = DecodeError_clone(&e_conv);
19291         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19292         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
19293         return (uint64_t)ret_conv;
19294 }
19295
19296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19297         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
19298         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
19299         return ret_val;
19300 }
19301
19302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19303         if ((_res & 1) != 0) return;
19304         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19305         CHECK_ACCESS(_res_ptr);
19306         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
19307         FREE((void*)_res);
19308         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
19309 }
19310
19311 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19312         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19313         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
19314         return (uint64_t)ret_conv;
19315 }
19316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19317         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
19318         int64_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19319         return ret_val;
19320 }
19321
19322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19323         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
19324         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19325         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
19326         return (uint64_t)ret_conv;
19327 }
19328
19329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19330         LDKErrorMessage o_conv;
19331         o_conv.inner = (void*)(o & (~1));
19332         o_conv.is_owned = (o & 1) || (o == 0);
19333         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19334         o_conv = ErrorMessage_clone(&o_conv);
19335         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19336         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
19337         return (uint64_t)ret_conv;
19338 }
19339
19340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19341         LDKDecodeError e_conv;
19342         e_conv.inner = (void*)(e & (~1));
19343         e_conv.is_owned = (e & 1) || (e == 0);
19344         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19345         e_conv = DecodeError_clone(&e_conv);
19346         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19347         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
19348         return (uint64_t)ret_conv;
19349 }
19350
19351 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19352         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
19353         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
19354         return ret_val;
19355 }
19356
19357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19358         if ((_res & 1) != 0) return;
19359         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19360         CHECK_ACCESS(_res_ptr);
19361         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
19362         FREE((void*)_res);
19363         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
19364 }
19365
19366 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
19367         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19368         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
19369         return (uint64_t)ret_conv;
19370 }
19371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19372         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
19373         int64_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
19374         return ret_val;
19375 }
19376
19377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19378         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
19379         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19380         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
19381         return (uint64_t)ret_conv;
19382 }
19383
19384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19385         LDKUnsignedNodeAnnouncement o_conv;
19386         o_conv.inner = (void*)(o & (~1));
19387         o_conv.is_owned = (o & 1) || (o == 0);
19388         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19389         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
19390         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19391         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
19392         return (uint64_t)ret_conv;
19393 }
19394
19395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19396         LDKDecodeError e_conv;
19397         e_conv.inner = (void*)(e & (~1));
19398         e_conv.is_owned = (e & 1) || (e == 0);
19399         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19400         e_conv = DecodeError_clone(&e_conv);
19401         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19402         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
19403         return (uint64_t)ret_conv;
19404 }
19405
19406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19407         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
19408         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
19409         return ret_val;
19410 }
19411
19412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19413         if ((_res & 1) != 0) return;
19414         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19415         CHECK_ACCESS(_res_ptr);
19416         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
19417         FREE((void*)_res);
19418         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
19419 }
19420
19421 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19422         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19423         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
19424         return (uint64_t)ret_conv;
19425 }
19426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19427         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
19428         int64_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19429         return ret_val;
19430 }
19431
19432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19433         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
19434         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19435         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
19436         return (uint64_t)ret_conv;
19437 }
19438
19439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19440         LDKNodeAnnouncement o_conv;
19441         o_conv.inner = (void*)(o & (~1));
19442         o_conv.is_owned = (o & 1) || (o == 0);
19443         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19444         o_conv = NodeAnnouncement_clone(&o_conv);
19445         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19446         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
19447         return (uint64_t)ret_conv;
19448 }
19449
19450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19451         LDKDecodeError e_conv;
19452         e_conv.inner = (void*)(e & (~1));
19453         e_conv.is_owned = (e & 1) || (e == 0);
19454         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19455         e_conv = DecodeError_clone(&e_conv);
19456         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19457         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
19458         return (uint64_t)ret_conv;
19459 }
19460
19461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19462         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
19463         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
19464         return ret_val;
19465 }
19466
19467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19468         if ((_res & 1) != 0) return;
19469         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19470         CHECK_ACCESS(_res_ptr);
19471         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
19472         FREE((void*)_res);
19473         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
19474 }
19475
19476 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19477         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19478         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
19479         return (uint64_t)ret_conv;
19480 }
19481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19482         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
19483         int64_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19484         return ret_val;
19485 }
19486
19487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19488         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
19489         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19490         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
19491         return (uint64_t)ret_conv;
19492 }
19493
19494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19495         LDKQueryShortChannelIds o_conv;
19496         o_conv.inner = (void*)(o & (~1));
19497         o_conv.is_owned = (o & 1) || (o == 0);
19498         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19499         o_conv = QueryShortChannelIds_clone(&o_conv);
19500         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19501         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
19502         return (uint64_t)ret_conv;
19503 }
19504
19505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19506         LDKDecodeError e_conv;
19507         e_conv.inner = (void*)(e & (~1));
19508         e_conv.is_owned = (e & 1) || (e == 0);
19509         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19510         e_conv = DecodeError_clone(&e_conv);
19511         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19512         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
19513         return (uint64_t)ret_conv;
19514 }
19515
19516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19517         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
19518         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
19519         return ret_val;
19520 }
19521
19522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19523         if ((_res & 1) != 0) return;
19524         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19525         CHECK_ACCESS(_res_ptr);
19526         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
19527         FREE((void*)_res);
19528         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
19529 }
19530
19531 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
19532         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19533         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
19534         return (uint64_t)ret_conv;
19535 }
19536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19537         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
19538         int64_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
19539         return ret_val;
19540 }
19541
19542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19543         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
19544         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19545         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
19546         return (uint64_t)ret_conv;
19547 }
19548
19549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19550         LDKReplyShortChannelIdsEnd o_conv;
19551         o_conv.inner = (void*)(o & (~1));
19552         o_conv.is_owned = (o & 1) || (o == 0);
19553         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19554         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
19555         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19556         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
19557         return (uint64_t)ret_conv;
19558 }
19559
19560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19561         LDKDecodeError e_conv;
19562         e_conv.inner = (void*)(e & (~1));
19563         e_conv.is_owned = (e & 1) || (e == 0);
19564         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19565         e_conv = DecodeError_clone(&e_conv);
19566         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19567         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
19568         return (uint64_t)ret_conv;
19569 }
19570
19571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19572         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
19573         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
19574         return ret_val;
19575 }
19576
19577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19578         if ((_res & 1) != 0) return;
19579         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19580         CHECK_ACCESS(_res_ptr);
19581         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
19582         FREE((void*)_res);
19583         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
19584 }
19585
19586 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
19587         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19588         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
19589         return (uint64_t)ret_conv;
19590 }
19591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19592         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
19593         int64_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
19594         return ret_val;
19595 }
19596
19597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19598         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
19599         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19600         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
19601         return (uint64_t)ret_conv;
19602 }
19603
19604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19605         LDKQueryChannelRange o_conv;
19606         o_conv.inner = (void*)(o & (~1));
19607         o_conv.is_owned = (o & 1) || (o == 0);
19608         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19609         o_conv = QueryChannelRange_clone(&o_conv);
19610         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19611         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
19612         return (uint64_t)ret_conv;
19613 }
19614
19615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19616         LDKDecodeError e_conv;
19617         e_conv.inner = (void*)(e & (~1));
19618         e_conv.is_owned = (e & 1) || (e == 0);
19619         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19620         e_conv = DecodeError_clone(&e_conv);
19621         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19622         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
19623         return (uint64_t)ret_conv;
19624 }
19625
19626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19627         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
19628         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
19629         return ret_val;
19630 }
19631
19632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19633         if ((_res & 1) != 0) return;
19634         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19635         CHECK_ACCESS(_res_ptr);
19636         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
19637         FREE((void*)_res);
19638         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
19639 }
19640
19641 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19642         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19643         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
19644         return (uint64_t)ret_conv;
19645 }
19646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19647         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
19648         int64_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19649         return ret_val;
19650 }
19651
19652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19653         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
19654         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19655         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
19656         return (uint64_t)ret_conv;
19657 }
19658
19659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19660         LDKReplyChannelRange o_conv;
19661         o_conv.inner = (void*)(o & (~1));
19662         o_conv.is_owned = (o & 1) || (o == 0);
19663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19664         o_conv = ReplyChannelRange_clone(&o_conv);
19665         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19666         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
19667         return (uint64_t)ret_conv;
19668 }
19669
19670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19671         LDKDecodeError e_conv;
19672         e_conv.inner = (void*)(e & (~1));
19673         e_conv.is_owned = (e & 1) || (e == 0);
19674         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19675         e_conv = DecodeError_clone(&e_conv);
19676         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19677         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
19678         return (uint64_t)ret_conv;
19679 }
19680
19681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19682         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
19683         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
19684         return ret_val;
19685 }
19686
19687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19688         if ((_res & 1) != 0) return;
19689         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19690         CHECK_ACCESS(_res_ptr);
19691         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
19692         FREE((void*)_res);
19693         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
19694 }
19695
19696 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19697         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19698         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
19699         return (uint64_t)ret_conv;
19700 }
19701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19702         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
19703         int64_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19704         return ret_val;
19705 }
19706
19707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19708         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
19709         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19710         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
19711         return (uint64_t)ret_conv;
19712 }
19713
19714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19715         LDKGossipTimestampFilter o_conv;
19716         o_conv.inner = (void*)(o & (~1));
19717         o_conv.is_owned = (o & 1) || (o == 0);
19718         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19719         o_conv = GossipTimestampFilter_clone(&o_conv);
19720         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19721         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
19722         return (uint64_t)ret_conv;
19723 }
19724
19725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19726         LDKDecodeError e_conv;
19727         e_conv.inner = (void*)(e & (~1));
19728         e_conv.is_owned = (e & 1) || (e == 0);
19729         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19730         e_conv = DecodeError_clone(&e_conv);
19731         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19732         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
19733         return (uint64_t)ret_conv;
19734 }
19735
19736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19737         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
19738         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
19739         return ret_val;
19740 }
19741
19742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19743         if ((_res & 1) != 0) return;
19744         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19745         CHECK_ACCESS(_res_ptr);
19746         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
19747         FREE((void*)_res);
19748         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
19749 }
19750
19751 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
19752         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19753         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
19754         return (uint64_t)ret_conv;
19755 }
19756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19757         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
19758         int64_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
19759         return ret_val;
19760 }
19761
19762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19763         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
19764         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19765         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
19766         return (uint64_t)ret_conv;
19767 }
19768
19769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19770         LDKInvoice o_conv;
19771         o_conv.inner = (void*)(o & (~1));
19772         o_conv.is_owned = (o & 1) || (o == 0);
19773         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19774         o_conv = Invoice_clone(&o_conv);
19775         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19776         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
19777         return (uint64_t)ret_conv;
19778 }
19779
19780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19781         void* e_ptr = (void*)(((uint64_t)e) & ~1);
19782         CHECK_ACCESS(e_ptr);
19783         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19784         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
19785         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19786         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19787         return (uint64_t)ret_conv;
19788 }
19789
19790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19791         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19792         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19793         return ret_val;
19794 }
19795
19796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19797         if ((_res & 1) != 0) return;
19798         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19799         CHECK_ACCESS(_res_ptr);
19800         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19801         FREE((void*)_res);
19802         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19803 }
19804
19805 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19806         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19807         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19808         return (uint64_t)ret_conv;
19809 }
19810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19811         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19812         int64_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19813         return ret_val;
19814 }
19815
19816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19817         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19818         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19819         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19820         return (uint64_t)ret_conv;
19821 }
19822
19823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19824         void* o_ptr = (void*)(((uint64_t)o) & ~1);
19825         CHECK_ACCESS(o_ptr);
19826         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19827         if (o_conv.free == LDKFilter_JCalls_free) {
19828                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19829                 LDKFilter_JCalls_cloned(&o_conv);
19830         }
19831         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19832         *ret_copy = COption_FilterZ_some(o_conv);
19833         uint64_t ret_ref = (uint64_t)ret_copy;
19834         return ret_ref;
19835 }
19836
19837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
19838         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19839         *ret_copy = COption_FilterZ_none();
19840         uint64_t ret_ref = (uint64_t)ret_copy;
19841         return ret_ref;
19842 }
19843
19844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19845         if ((_res & 1) != 0) return;
19846         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19847         CHECK_ACCESS(_res_ptr);
19848         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19849         FREE((void*)_res);
19850         COption_FilterZ_free(_res_conv);
19851 }
19852
19853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19854         LDKLockedChannelMonitor o_conv;
19855         o_conv.inner = (void*)(o & (~1));
19856         o_conv.is_owned = (o & 1) || (o == 0);
19857         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19858         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
19859         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19860         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19861         return (uint64_t)ret_conv;
19862 }
19863
19864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
19865         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19866         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19867         return (uint64_t)ret_conv;
19868 }
19869
19870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19871         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19872         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19873         return ret_val;
19874 }
19875
19876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19877         if ((_res & 1) != 0) return;
19878         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19879         CHECK_ACCESS(_res_ptr);
19880         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19881         FREE((void*)_res);
19882         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19883 }
19884
19885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19886         LDKCVec_OutPointZ _res_constr;
19887         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19888         if (_res_constr.datalen > 0)
19889                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19890         else
19891                 _res_constr.data = NULL;
19892         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19893         for (size_t k = 0; k < _res_constr.datalen; k++) {
19894                 int64_t _res_conv_10 = _res_vals[k];
19895                 LDKOutPoint _res_conv_10_conv;
19896                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19897                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19898                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19899                 _res_constr.data[k] = _res_conv_10_conv;
19900         }
19901         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19902         CVec_OutPointZ_free(_res_constr);
19903 }
19904
19905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19906         if ((this_ptr & 1) != 0) return;
19907         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19908         CHECK_ACCESS(this_ptr_ptr);
19909         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19910         FREE((void*)this_ptr);
19911         PaymentPurpose_free(this_ptr_conv);
19912 }
19913
19914 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19915         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19916         *ret_copy = PaymentPurpose_clone(arg);
19917 uint64_t ret_ref = (uint64_t)ret_copy;
19918         return ret_ref;
19919 }
19920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19921         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19922         int64_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
19923         return ret_val;
19924 }
19925
19926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19927         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19928         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19929         *ret_copy = PaymentPurpose_clone(orig_conv);
19930         uint64_t ret_ref = (uint64_t)ret_copy;
19931         return ret_ref;
19932 }
19933
19934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
19935         LDKThirtyTwoBytes payment_preimage_ref;
19936         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
19937         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
19938         LDKThirtyTwoBytes payment_secret_ref;
19939         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
19940         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
19941         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19942         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
19943         uint64_t ret_ref = (uint64_t)ret_copy;
19944         return ret_ref;
19945 }
19946
19947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
19948         LDKThirtyTwoBytes a_ref;
19949         CHECK((*env)->GetArrayLength(env, a) == 32);
19950         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19951         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19952         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19953         uint64_t ret_ref = (uint64_t)ret_copy;
19954         return ret_ref;
19955 }
19956
19957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19958         if ((this_ptr & 1) != 0) return;
19959         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19960         CHECK_ACCESS(this_ptr_ptr);
19961         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19962         FREE((void*)this_ptr);
19963         ClosureReason_free(this_ptr_conv);
19964 }
19965
19966 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19967         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19968         *ret_copy = ClosureReason_clone(arg);
19969 uint64_t ret_ref = (uint64_t)ret_copy;
19970         return ret_ref;
19971 }
19972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19973         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19974         int64_t ret_val = ClosureReason_clone_ptr(arg_conv);
19975         return ret_val;
19976 }
19977
19978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19979         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19980         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19981         *ret_copy = ClosureReason_clone(orig_conv);
19982         uint64_t ret_ref = (uint64_t)ret_copy;
19983         return ret_ref;
19984 }
19985
19986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
19987         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
19988         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19989         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19990         uint64_t ret_ref = (uint64_t)ret_copy;
19991         return ret_ref;
19992 }
19993
19994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
19995         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19996         *ret_copy = ClosureReason_holder_force_closed();
19997         uint64_t ret_ref = (uint64_t)ret_copy;
19998         return ret_ref;
19999 }
20000
20001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
20002         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20003         *ret_copy = ClosureReason_cooperative_closure();
20004         uint64_t ret_ref = (uint64_t)ret_copy;
20005         return ret_ref;
20006 }
20007
20008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
20009         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20010         *ret_copy = ClosureReason_commitment_tx_confirmed();
20011         uint64_t ret_ref = (uint64_t)ret_copy;
20012         return ret_ref;
20013 }
20014
20015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
20016         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20017         *ret_copy = ClosureReason_funding_timed_out();
20018         uint64_t ret_ref = (uint64_t)ret_copy;
20019         return ret_ref;
20020 }
20021
20022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
20023         LDKStr err_conv = java_to_owned_str(env, err);
20024         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20025         *ret_copy = ClosureReason_processing_error(err_conv);
20026         uint64_t ret_ref = (uint64_t)ret_copy;
20027         return ret_ref;
20028 }
20029
20030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
20031         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20032         *ret_copy = ClosureReason_disconnected_peer();
20033         uint64_t ret_ref = (uint64_t)ret_copy;
20034         return ret_ref;
20035 }
20036
20037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
20038         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20039         *ret_copy = ClosureReason_outdated_channel_manager();
20040         uint64_t ret_ref = (uint64_t)ret_copy;
20041         return ret_ref;
20042 }
20043
20044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
20045         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
20046         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
20047         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20048         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20049         CVec_u8Z_free(ret_var);
20050         return ret_arr;
20051 }
20052
20053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20054         LDKu8slice ser_ref;
20055         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20056         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20057         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
20058         *ret_conv = ClosureReason_read(ser_ref);
20059         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20060         return (uint64_t)ret_conv;
20061 }
20062
20063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20064         if ((this_ptr & 1) != 0) return;
20065         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20066         CHECK_ACCESS(this_ptr_ptr);
20067         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
20068         FREE((void*)this_ptr);
20069         Event_free(this_ptr_conv);
20070 }
20071
20072 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
20073         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20074         *ret_copy = Event_clone(arg);
20075 uint64_t ret_ref = (uint64_t)ret_copy;
20076         return ret_ref;
20077 }
20078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20079         LDKEvent* arg_conv = (LDKEvent*)arg;
20080         int64_t ret_val = Event_clone_ptr(arg_conv);
20081         return ret_val;
20082 }
20083
20084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20085         LDKEvent* orig_conv = (LDKEvent*)orig;
20086         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20087         *ret_copy = Event_clone(orig_conv);
20088         uint64_t ret_ref = (uint64_t)ret_copy;
20089         return ret_ref;
20090 }
20091
20092 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) {
20093         LDKThirtyTwoBytes temporary_channel_id_ref;
20094         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
20095         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
20096         LDKCVec_u8Z output_script_ref;
20097         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
20098         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
20099         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
20100         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20101         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
20102         uint64_t ret_ref = (uint64_t)ret_copy;
20103         return ret_ref;
20104 }
20105
20106 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) {
20107         LDKThirtyTwoBytes payment_hash_ref;
20108         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
20109         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
20110         void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
20111         CHECK_ACCESS(purpose_ptr);
20112         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20113         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
20114         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20115         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
20116         uint64_t ret_ref = (uint64_t)ret_copy;
20117         return ret_ref;
20118 }
20119
20120 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) {
20121         LDKThirtyTwoBytes payment_id_ref;
20122         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
20123         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
20124         LDKThirtyTwoBytes payment_preimage_ref;
20125         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
20126         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
20127         LDKThirtyTwoBytes payment_hash_ref;
20128         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
20129         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
20130         void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
20131         CHECK_ACCESS(fee_paid_msat_ptr);
20132         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
20133         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
20134         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20135         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
20136         uint64_t ret_ref = (uint64_t)ret_copy;
20137         return ret_ref;
20138 }
20139
20140 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) {
20141         LDKThirtyTwoBytes payment_id_ref;
20142         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
20143         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
20144         LDKThirtyTwoBytes payment_hash_ref;
20145         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
20146         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
20147         void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
20148         CHECK_ACCESS(network_update_ptr);
20149         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
20150         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
20151         LDKCVec_RouteHopZ path_constr;
20152         path_constr.datalen = (*env)->GetArrayLength(env, path);
20153         if (path_constr.datalen > 0)
20154                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20155         else
20156                 path_constr.data = NULL;
20157         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
20158         for (size_t k = 0; k < path_constr.datalen; k++) {
20159                 int64_t path_conv_10 = path_vals[k];
20160                 LDKRouteHop path_conv_10_conv;
20161                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
20162                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
20163                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
20164                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
20165                 path_constr.data[k] = path_conv_10_conv;
20166         }
20167         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
20168         void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
20169         CHECK_ACCESS(short_channel_id_ptr);
20170         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
20171         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
20172         LDKRouteParameters retry_conv;
20173         retry_conv.inner = (void*)(retry & (~1));
20174         retry_conv.is_owned = (retry & 1) || (retry == 0);
20175         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
20176         retry_conv = RouteParameters_clone(&retry_conv);
20177         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20178         *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);
20179         uint64_t ret_ref = (uint64_t)ret_copy;
20180         return ret_ref;
20181 }
20182
20183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
20184         LDKThirtyTwoBytes payment_id_ref;
20185         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
20186         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
20187         LDKThirtyTwoBytes payment_hash_ref;
20188         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
20189         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
20190         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20191         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
20192         uint64_t ret_ref = (uint64_t)ret_copy;
20193         return ret_ref;
20194 }
20195
20196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
20197         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20198         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
20199         uint64_t ret_ref = (uint64_t)ret_copy;
20200         return ret_ref;
20201 }
20202
20203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
20204         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
20205         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
20206         if (outputs_constr.datalen > 0)
20207                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20208         else
20209                 outputs_constr.data = NULL;
20210         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
20211         for (size_t b = 0; b < outputs_constr.datalen; b++) {
20212                 int64_t outputs_conv_27 = outputs_vals[b];
20213                 void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
20214                 CHECK_ACCESS(outputs_conv_27_ptr);
20215                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
20216                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
20217                 outputs_constr.data[b] = outputs_conv_27_conv;
20218         }
20219         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
20220         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20221         *ret_copy = Event_spendable_outputs(outputs_constr);
20222         uint64_t ret_ref = (uint64_t)ret_copy;
20223         return ret_ref;
20224 }
20225
20226 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) {
20227         void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
20228         CHECK_ACCESS(fee_earned_msat_ptr);
20229         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
20230         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
20231         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20232         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
20233         uint64_t ret_ref = (uint64_t)ret_copy;
20234         return ret_ref;
20235 }
20236
20237 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) {
20238         LDKThirtyTwoBytes channel_id_ref;
20239         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
20240         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
20241         void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
20242         CHECK_ACCESS(reason_ptr);
20243         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
20244         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
20245         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20246         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
20247         uint64_t ret_ref = (uint64_t)ret_copy;
20248         return ret_ref;
20249 }
20250
20251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
20252         LDKThirtyTwoBytes channel_id_ref;
20253         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
20254         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
20255         LDKTransaction transaction_ref;
20256         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
20257         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
20258         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
20259         transaction_ref.data_is_owned = true;
20260         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20261         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
20262         uint64_t ret_ref = (uint64_t)ret_copy;
20263         return ret_ref;
20264 }
20265
20266 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) {
20267         LDKThirtyTwoBytes payment_id_ref;
20268         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
20269         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
20270         LDKThirtyTwoBytes payment_hash_ref;
20271         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
20272         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
20273         LDKCVec_RouteHopZ path_constr;
20274         path_constr.datalen = (*env)->GetArrayLength(env, path);
20275         if (path_constr.datalen > 0)
20276                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20277         else
20278                 path_constr.data = NULL;
20279         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
20280         for (size_t k = 0; k < path_constr.datalen; k++) {
20281                 int64_t path_conv_10 = path_vals[k];
20282                 LDKRouteHop path_conv_10_conv;
20283                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
20284                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
20285                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
20286                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
20287                 path_constr.data[k] = path_conv_10_conv;
20288         }
20289         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
20290         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20291         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
20292         uint64_t ret_ref = (uint64_t)ret_copy;
20293         return ret_ref;
20294 }
20295
20296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
20297         LDKEvent* obj_conv = (LDKEvent*)obj;
20298         LDKCVec_u8Z ret_var = Event_write(obj_conv);
20299         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20300         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20301         CVec_u8Z_free(ret_var);
20302         return ret_arr;
20303 }
20304
20305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20306         LDKu8slice ser_ref;
20307         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20308         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20309         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
20310         *ret_conv = Event_read(ser_ref);
20311         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20312         return (uint64_t)ret_conv;
20313 }
20314
20315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20316         if ((this_ptr & 1) != 0) return;
20317         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20318         CHECK_ACCESS(this_ptr_ptr);
20319         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
20320         FREE((void*)this_ptr);
20321         MessageSendEvent_free(this_ptr_conv);
20322 }
20323
20324 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
20325         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20326         *ret_copy = MessageSendEvent_clone(arg);
20327 uint64_t ret_ref = (uint64_t)ret_copy;
20328         return ret_ref;
20329 }
20330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20331         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
20332         int64_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
20333         return ret_val;
20334 }
20335
20336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20337         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
20338         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20339         *ret_copy = MessageSendEvent_clone(orig_conv);
20340         uint64_t ret_ref = (uint64_t)ret_copy;
20341         return ret_ref;
20342 }
20343
20344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20345         LDKPublicKey node_id_ref;
20346         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20347         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20348         LDKAcceptChannel msg_conv;
20349         msg_conv.inner = (void*)(msg & (~1));
20350         msg_conv.is_owned = (msg & 1) || (msg == 0);
20351         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20352         msg_conv = AcceptChannel_clone(&msg_conv);
20353         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20354         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
20355         uint64_t ret_ref = (uint64_t)ret_copy;
20356         return ret_ref;
20357 }
20358
20359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20360         LDKPublicKey node_id_ref;
20361         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20362         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20363         LDKOpenChannel msg_conv;
20364         msg_conv.inner = (void*)(msg & (~1));
20365         msg_conv.is_owned = (msg & 1) || (msg == 0);
20366         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20367         msg_conv = OpenChannel_clone(&msg_conv);
20368         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20369         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
20370         uint64_t ret_ref = (uint64_t)ret_copy;
20371         return ret_ref;
20372 }
20373
20374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20375         LDKPublicKey node_id_ref;
20376         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20377         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20378         LDKFundingCreated msg_conv;
20379         msg_conv.inner = (void*)(msg & (~1));
20380         msg_conv.is_owned = (msg & 1) || (msg == 0);
20381         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20382         msg_conv = FundingCreated_clone(&msg_conv);
20383         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20384         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
20385         uint64_t ret_ref = (uint64_t)ret_copy;
20386         return ret_ref;
20387 }
20388
20389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20390         LDKPublicKey node_id_ref;
20391         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20392         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20393         LDKFundingSigned msg_conv;
20394         msg_conv.inner = (void*)(msg & (~1));
20395         msg_conv.is_owned = (msg & 1) || (msg == 0);
20396         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20397         msg_conv = FundingSigned_clone(&msg_conv);
20398         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20399         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
20400         uint64_t ret_ref = (uint64_t)ret_copy;
20401         return ret_ref;
20402 }
20403
20404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20405         LDKPublicKey node_id_ref;
20406         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20407         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20408         LDKFundingLocked msg_conv;
20409         msg_conv.inner = (void*)(msg & (~1));
20410         msg_conv.is_owned = (msg & 1) || (msg == 0);
20411         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20412         msg_conv = FundingLocked_clone(&msg_conv);
20413         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20414         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
20415         uint64_t ret_ref = (uint64_t)ret_copy;
20416         return ret_ref;
20417 }
20418
20419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20420         LDKPublicKey node_id_ref;
20421         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20422         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20423         LDKAnnouncementSignatures msg_conv;
20424         msg_conv.inner = (void*)(msg & (~1));
20425         msg_conv.is_owned = (msg & 1) || (msg == 0);
20426         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20427         msg_conv = AnnouncementSignatures_clone(&msg_conv);
20428         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20429         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
20430         uint64_t ret_ref = (uint64_t)ret_copy;
20431         return ret_ref;
20432 }
20433
20434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
20435         LDKPublicKey node_id_ref;
20436         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20437         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20438         LDKCommitmentUpdate updates_conv;
20439         updates_conv.inner = (void*)(updates & (~1));
20440         updates_conv.is_owned = (updates & 1) || (updates == 0);
20441         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
20442         updates_conv = CommitmentUpdate_clone(&updates_conv);
20443         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20444         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
20445         uint64_t ret_ref = (uint64_t)ret_copy;
20446         return ret_ref;
20447 }
20448
20449 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) {
20450         LDKPublicKey node_id_ref;
20451         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20452         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20453         LDKRevokeAndACK msg_conv;
20454         msg_conv.inner = (void*)(msg & (~1));
20455         msg_conv.is_owned = (msg & 1) || (msg == 0);
20456         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20457         msg_conv = RevokeAndACK_clone(&msg_conv);
20458         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20459         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
20460         uint64_t ret_ref = (uint64_t)ret_copy;
20461         return ret_ref;
20462 }
20463
20464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20465         LDKPublicKey node_id_ref;
20466         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20467         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20468         LDKClosingSigned msg_conv;
20469         msg_conv.inner = (void*)(msg & (~1));
20470         msg_conv.is_owned = (msg & 1) || (msg == 0);
20471         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20472         msg_conv = ClosingSigned_clone(&msg_conv);
20473         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20474         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
20475         uint64_t ret_ref = (uint64_t)ret_copy;
20476         return ret_ref;
20477 }
20478
20479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20480         LDKPublicKey node_id_ref;
20481         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20482         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20483         LDKShutdown msg_conv;
20484         msg_conv.inner = (void*)(msg & (~1));
20485         msg_conv.is_owned = (msg & 1) || (msg == 0);
20486         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20487         msg_conv = Shutdown_clone(&msg_conv);
20488         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20489         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
20490         uint64_t ret_ref = (uint64_t)ret_copy;
20491         return ret_ref;
20492 }
20493
20494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20495         LDKPublicKey node_id_ref;
20496         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20497         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20498         LDKChannelReestablish msg_conv;
20499         msg_conv.inner = (void*)(msg & (~1));
20500         msg_conv.is_owned = (msg & 1) || (msg == 0);
20501         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20502         msg_conv = ChannelReestablish_clone(&msg_conv);
20503         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20504         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
20505         uint64_t ret_ref = (uint64_t)ret_copy;
20506         return ret_ref;
20507 }
20508
20509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
20510         LDKChannelAnnouncement msg_conv;
20511         msg_conv.inner = (void*)(msg & (~1));
20512         msg_conv.is_owned = (msg & 1) || (msg == 0);
20513         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20514         msg_conv = ChannelAnnouncement_clone(&msg_conv);
20515         LDKChannelUpdate update_msg_conv;
20516         update_msg_conv.inner = (void*)(update_msg & (~1));
20517         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
20518         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
20519         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
20520         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20521         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
20522         uint64_t ret_ref = (uint64_t)ret_copy;
20523         return ret_ref;
20524 }
20525
20526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
20527         LDKNodeAnnouncement msg_conv;
20528         msg_conv.inner = (void*)(msg & (~1));
20529         msg_conv.is_owned = (msg & 1) || (msg == 0);
20530         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20531         msg_conv = NodeAnnouncement_clone(&msg_conv);
20532         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20533         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
20534         uint64_t ret_ref = (uint64_t)ret_copy;
20535         return ret_ref;
20536 }
20537
20538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
20539         LDKChannelUpdate msg_conv;
20540         msg_conv.inner = (void*)(msg & (~1));
20541         msg_conv.is_owned = (msg & 1) || (msg == 0);
20542         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20543         msg_conv = ChannelUpdate_clone(&msg_conv);
20544         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20545         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
20546         uint64_t ret_ref = (uint64_t)ret_copy;
20547         return ret_ref;
20548 }
20549
20550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
20551         LDKPublicKey node_id_ref;
20552         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20553         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20554         LDKChannelUpdate msg_conv;
20555         msg_conv.inner = (void*)(msg & (~1));
20556         msg_conv.is_owned = (msg & 1) || (msg == 0);
20557         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20558         msg_conv = ChannelUpdate_clone(&msg_conv);
20559         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20560         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
20561         uint64_t ret_ref = (uint64_t)ret_copy;
20562         return ret_ref;
20563 }
20564
20565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
20566         LDKPublicKey node_id_ref;
20567         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20568         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20569         void* action_ptr = (void*)(((uint64_t)action) & ~1);
20570         CHECK_ACCESS(action_ptr);
20571         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
20572         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
20573         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20574         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
20575         uint64_t ret_ref = (uint64_t)ret_copy;
20576         return ret_ref;
20577 }
20578
20579 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) {
20580         LDKPublicKey node_id_ref;
20581         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20582         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20583         LDKQueryChannelRange msg_conv;
20584         msg_conv.inner = (void*)(msg & (~1));
20585         msg_conv.is_owned = (msg & 1) || (msg == 0);
20586         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20587         msg_conv = QueryChannelRange_clone(&msg_conv);
20588         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20589         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
20590         uint64_t ret_ref = (uint64_t)ret_copy;
20591         return ret_ref;
20592 }
20593
20594 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) {
20595         LDKPublicKey node_id_ref;
20596         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20597         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20598         LDKQueryShortChannelIds msg_conv;
20599         msg_conv.inner = (void*)(msg & (~1));
20600         msg_conv.is_owned = (msg & 1) || (msg == 0);
20601         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20602         msg_conv = QueryShortChannelIds_clone(&msg_conv);
20603         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20604         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
20605         uint64_t ret_ref = (uint64_t)ret_copy;
20606         return ret_ref;
20607 }
20608
20609 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) {
20610         LDKPublicKey node_id_ref;
20611         CHECK((*env)->GetArrayLength(env, node_id) == 33);
20612         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
20613         LDKReplyChannelRange msg_conv;
20614         msg_conv.inner = (void*)(msg & (~1));
20615         msg_conv.is_owned = (msg & 1) || (msg == 0);
20616         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20617         msg_conv = ReplyChannelRange_clone(&msg_conv);
20618         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20619         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
20620         uint64_t ret_ref = (uint64_t)ret_copy;
20621         return ret_ref;
20622 }
20623
20624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20625         if ((this_ptr & 1) != 0) return;
20626         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20627         CHECK_ACCESS(this_ptr_ptr);
20628         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
20629         FREE((void*)this_ptr);
20630         MessageSendEventsProvider_free(this_ptr_conv);
20631 }
20632
20633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20634         if ((this_ptr & 1) != 0) return;
20635         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20636         CHECK_ACCESS(this_ptr_ptr);
20637         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
20638         FREE((void*)this_ptr);
20639         EventsProvider_free(this_ptr_conv);
20640 }
20641
20642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20643         if ((this_ptr & 1) != 0) return;
20644         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20645         CHECK_ACCESS(this_ptr_ptr);
20646         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
20647         FREE((void*)this_ptr);
20648         EventHandler_free(this_ptr_conv);
20649 }
20650
20651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20652         if ((this_ptr & 1) != 0) return;
20653         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20654         CHECK_ACCESS(this_ptr_ptr);
20655         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
20656         FREE((void*)this_ptr);
20657         APIError_free(this_ptr_conv);
20658 }
20659
20660 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
20661         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20662         *ret_copy = APIError_clone(arg);
20663 uint64_t ret_ref = (uint64_t)ret_copy;
20664         return ret_ref;
20665 }
20666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20667         LDKAPIError* arg_conv = (LDKAPIError*)arg;
20668         int64_t ret_val = APIError_clone_ptr(arg_conv);
20669         return ret_val;
20670 }
20671
20672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20673         LDKAPIError* orig_conv = (LDKAPIError*)orig;
20674         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20675         *ret_copy = APIError_clone(orig_conv);
20676         uint64_t ret_ref = (uint64_t)ret_copy;
20677         return ret_ref;
20678 }
20679
20680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
20681         LDKStr err_conv = java_to_owned_str(env, err);
20682         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20683         *ret_copy = APIError_apimisuse_error(err_conv);
20684         uint64_t ret_ref = (uint64_t)ret_copy;
20685         return ret_ref;
20686 }
20687
20688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
20689         LDKStr err_conv = java_to_owned_str(env, err);
20690         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20691         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
20692         uint64_t ret_ref = (uint64_t)ret_copy;
20693         return ret_ref;
20694 }
20695
20696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
20697         LDKStr err_conv = java_to_owned_str(env, err);
20698         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20699         *ret_copy = APIError_route_error(err_conv);
20700         uint64_t ret_ref = (uint64_t)ret_copy;
20701         return ret_ref;
20702 }
20703
20704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
20705         LDKStr err_conv = java_to_owned_str(env, err);
20706         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20707         *ret_copy = APIError_channel_unavailable(err_conv);
20708         uint64_t ret_ref = (uint64_t)ret_copy;
20709         return ret_ref;
20710 }
20711
20712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
20713         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20714         *ret_copy = APIError_monitor_update_failed();
20715         uint64_t ret_ref = (uint64_t)ret_copy;
20716         return ret_ref;
20717 }
20718
20719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
20720         LDKShutdownScript script_conv;
20721         script_conv.inner = (void*)(script & (~1));
20722         script_conv.is_owned = (script & 1) || (script == 0);
20723         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
20724         script_conv = ShutdownScript_clone(&script_conv);
20725         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20726         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
20727         uint64_t ret_ref = (uint64_t)ret_copy;
20728         return ret_ref;
20729 }
20730
20731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
20732         LDKu8slice msg_ref;
20733         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
20734         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
20735         unsigned char sk_arr[32];
20736         CHECK((*env)->GetArrayLength(env, sk) == 32);
20737         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
20738         unsigned char (*sk_ref)[32] = &sk_arr;
20739         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20740         *ret_conv = sign(msg_ref, sk_ref);
20741         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
20742         return (uint64_t)ret_conv;
20743 }
20744
20745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
20746         LDKu8slice msg_ref;
20747         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
20748         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
20749         LDKStr sig_conv = java_to_owned_str(env, sig);
20750         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20751         *ret_conv = recover_pk(msg_ref, sig_conv);
20752         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
20753         return (uint64_t)ret_conv;
20754 }
20755
20756 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
20757         LDKu8slice msg_ref;
20758         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
20759         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
20760         LDKStr sig_conv = java_to_owned_str(env, sig);
20761         LDKPublicKey pk_ref;
20762         CHECK((*env)->GetArrayLength(env, pk) == 33);
20763         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
20764         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
20765         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
20766         return ret_val;
20767 }
20768
20769 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20770         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
20771         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
20772         return ret_conv;
20773 }
20774
20775 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
20776         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
20777         return ret_conv;
20778 }
20779
20780 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
20781         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
20782         return ret_conv;
20783 }
20784
20785 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
20786         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
20787         return ret_conv;
20788 }
20789
20790 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
20791         jclass ret_conv = LDKLevel_to_java(env, Level_info());
20792         return ret_conv;
20793 }
20794
20795 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
20796         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
20797         return ret_conv;
20798 }
20799
20800 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
20801         jclass ret_conv = LDKLevel_to_java(env, Level_error());
20802         return ret_conv;
20803 }
20804
20805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
20806         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20807         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20808         jboolean ret_val = Level_eq(a_conv, b_conv);
20809         return ret_val;
20810 }
20811
20812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
20813         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20814         int64_t ret_val = Level_hash(o_conv);
20815         return ret_val;
20816 }
20817
20818 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
20819         jclass ret_conv = LDKLevel_to_java(env, Level_max());
20820         return ret_conv;
20821 }
20822
20823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20824         LDKRecord this_obj_conv;
20825         this_obj_conv.inner = (void*)(this_obj & (~1));
20826         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20828         Record_free(this_obj_conv);
20829 }
20830
20831 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
20832         LDKRecord this_ptr_conv;
20833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20834         this_ptr_conv.is_owned = false;
20835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20836         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
20837         return ret_conv;
20838 }
20839
20840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
20841         LDKRecord this_ptr_conv;
20842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20843         this_ptr_conv.is_owned = false;
20844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20845         LDKLevel val_conv = LDKLevel_from_java(env, val);
20846         Record_set_level(&this_ptr_conv, val_conv);
20847 }
20848
20849 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
20850         LDKRecord this_ptr_conv;
20851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20852         this_ptr_conv.is_owned = false;
20853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20854         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20855         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20856         Str_free(ret_str);
20857         return ret_conv;
20858 }
20859
20860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20861         LDKRecord this_ptr_conv;
20862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20863         this_ptr_conv.is_owned = false;
20864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20865         LDKStr val_conv = java_to_owned_str(env, val);
20866         Record_set_args(&this_ptr_conv, val_conv);
20867 }
20868
20869 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
20870         LDKRecord this_ptr_conv;
20871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20872         this_ptr_conv.is_owned = false;
20873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20874         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20875         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20876         Str_free(ret_str);
20877         return ret_conv;
20878 }
20879
20880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20881         LDKRecord this_ptr_conv;
20882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20883         this_ptr_conv.is_owned = false;
20884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20885         LDKStr val_conv = java_to_owned_str(env, val);
20886         Record_set_module_path(&this_ptr_conv, val_conv);
20887 }
20888
20889 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
20890         LDKRecord this_ptr_conv;
20891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20892         this_ptr_conv.is_owned = false;
20893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20894         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20895         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20896         Str_free(ret_str);
20897         return ret_conv;
20898 }
20899
20900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20901         LDKRecord this_ptr_conv;
20902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20903         this_ptr_conv.is_owned = false;
20904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20905         LDKStr val_conv = java_to_owned_str(env, val);
20906         Record_set_file(&this_ptr_conv, val_conv);
20907 }
20908
20909 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
20910         LDKRecord this_ptr_conv;
20911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20912         this_ptr_conv.is_owned = false;
20913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20914         int32_t ret_val = Record_get_line(&this_ptr_conv);
20915         return ret_val;
20916 }
20917
20918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20919         LDKRecord this_ptr_conv;
20920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20921         this_ptr_conv.is_owned = false;
20922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20923         Record_set_line(&this_ptr_conv, val);
20924 }
20925
20926 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20927         LDKRecord ret_var = Record_clone(arg);
20928 uint64_t ret_ref = 0;
20929 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20930 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20931 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20932 ret_ref = (uint64_t)ret_var.inner;
20933 if (ret_var.is_owned) {
20934         ret_ref |= 1;
20935 }
20936         return ret_ref;
20937 }
20938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20939         LDKRecord arg_conv;
20940         arg_conv.inner = (void*)(arg & (~1));
20941         arg_conv.is_owned = false;
20942         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20943         int64_t ret_val = Record_clone_ptr(&arg_conv);
20944         return ret_val;
20945 }
20946
20947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20948         LDKRecord orig_conv;
20949         orig_conv.inner = (void*)(orig & (~1));
20950         orig_conv.is_owned = false;
20951         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20952         LDKRecord ret_var = Record_clone(&orig_conv);
20953         uint64_t ret_ref = 0;
20954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20957         ret_ref = (uint64_t)ret_var.inner;
20958         if (ret_var.is_owned) {
20959                 ret_ref |= 1;
20960         }
20961         return ret_ref;
20962 }
20963
20964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20965         if ((this_ptr & 1) != 0) return;
20966         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20967         CHECK_ACCESS(this_ptr_ptr);
20968         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20969         FREE((void*)this_ptr);
20970         Logger_free(this_ptr_conv);
20971 }
20972
20973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20974         LDKChannelHandshakeConfig this_obj_conv;
20975         this_obj_conv.inner = (void*)(this_obj & (~1));
20976         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20978         ChannelHandshakeConfig_free(this_obj_conv);
20979 }
20980
20981 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
20982         LDKChannelHandshakeConfig this_ptr_conv;
20983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20984         this_ptr_conv.is_owned = false;
20985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20986         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20987         return ret_val;
20988 }
20989
20990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20991         LDKChannelHandshakeConfig this_ptr_conv;
20992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20993         this_ptr_conv.is_owned = false;
20994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20995         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20996 }
20997
20998 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
20999         LDKChannelHandshakeConfig this_ptr_conv;
21000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21001         this_ptr_conv.is_owned = false;
21002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21003         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
21004         return ret_val;
21005 }
21006
21007 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) {
21008         LDKChannelHandshakeConfig this_ptr_conv;
21009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21010         this_ptr_conv.is_owned = false;
21011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21012         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
21013 }
21014
21015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21016         LDKChannelHandshakeConfig this_ptr_conv;
21017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21018         this_ptr_conv.is_owned = false;
21019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21020         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
21021         return ret_val;
21022 }
21023
21024 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) {
21025         LDKChannelHandshakeConfig this_ptr_conv;
21026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21027         this_ptr_conv.is_owned = false;
21028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21029         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
21030 }
21031
21032 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) {
21033         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
21034         uint64_t ret_ref = 0;
21035         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21036         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21038         ret_ref = (uint64_t)ret_var.inner;
21039         if (ret_var.is_owned) {
21040                 ret_ref |= 1;
21041         }
21042         return ret_ref;
21043 }
21044
21045 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
21046         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
21047 uint64_t ret_ref = 0;
21048 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21049 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21050 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21051 ret_ref = (uint64_t)ret_var.inner;
21052 if (ret_var.is_owned) {
21053         ret_ref |= 1;
21054 }
21055         return ret_ref;
21056 }
21057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21058         LDKChannelHandshakeConfig arg_conv;
21059         arg_conv.inner = (void*)(arg & (~1));
21060         arg_conv.is_owned = false;
21061         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21062         int64_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
21063         return ret_val;
21064 }
21065
21066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21067         LDKChannelHandshakeConfig orig_conv;
21068         orig_conv.inner = (void*)(orig & (~1));
21069         orig_conv.is_owned = false;
21070         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21071         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
21072         uint64_t ret_ref = 0;
21073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21076         ret_ref = (uint64_t)ret_var.inner;
21077         if (ret_var.is_owned) {
21078                 ret_ref |= 1;
21079         }
21080         return ret_ref;
21081 }
21082
21083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
21084         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
21085         uint64_t ret_ref = 0;
21086         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21087         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21089         ret_ref = (uint64_t)ret_var.inner;
21090         if (ret_var.is_owned) {
21091                 ret_ref |= 1;
21092         }
21093         return ret_ref;
21094 }
21095
21096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21097         LDKChannelHandshakeLimits this_obj_conv;
21098         this_obj_conv.inner = (void*)(this_obj & (~1));
21099         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21101         ChannelHandshakeLimits_free(this_obj_conv);
21102 }
21103
21104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21105         LDKChannelHandshakeLimits this_ptr_conv;
21106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21107         this_ptr_conv.is_owned = false;
21108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21109         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
21110         return ret_val;
21111 }
21112
21113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21114         LDKChannelHandshakeLimits this_ptr_conv;
21115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21116         this_ptr_conv.is_owned = false;
21117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21118         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
21119 }
21120
21121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21122         LDKChannelHandshakeLimits this_ptr_conv;
21123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21124         this_ptr_conv.is_owned = false;
21125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21126         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
21127         return ret_val;
21128 }
21129
21130 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) {
21131         LDKChannelHandshakeLimits this_ptr_conv;
21132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21133         this_ptr_conv.is_owned = false;
21134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21135         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
21136 }
21137
21138 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) {
21139         LDKChannelHandshakeLimits this_ptr_conv;
21140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21141         this_ptr_conv.is_owned = false;
21142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21143         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
21144         return ret_val;
21145 }
21146
21147 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) {
21148         LDKChannelHandshakeLimits this_ptr_conv;
21149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21150         this_ptr_conv.is_owned = false;
21151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21152         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
21153 }
21154
21155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
21156         LDKChannelHandshakeLimits this_ptr_conv;
21157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21158         this_ptr_conv.is_owned = false;
21159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21160         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
21161         return ret_val;
21162 }
21163
21164 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) {
21165         LDKChannelHandshakeLimits this_ptr_conv;
21166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21167         this_ptr_conv.is_owned = false;
21168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21169         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
21170 }
21171
21172 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
21173         LDKChannelHandshakeLimits this_ptr_conv;
21174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21175         this_ptr_conv.is_owned = false;
21176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21177         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
21178         return ret_val;
21179 }
21180
21181 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) {
21182         LDKChannelHandshakeLimits this_ptr_conv;
21183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21184         this_ptr_conv.is_owned = false;
21185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21186         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
21187 }
21188
21189 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
21190         LDKChannelHandshakeLimits this_ptr_conv;
21191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21192         this_ptr_conv.is_owned = false;
21193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21194         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
21195         return ret_val;
21196 }
21197
21198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
21199         LDKChannelHandshakeLimits this_ptr_conv;
21200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21201         this_ptr_conv.is_owned = false;
21202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21203         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
21204 }
21205
21206 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
21207         LDKChannelHandshakeLimits this_ptr_conv;
21208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21209         this_ptr_conv.is_owned = false;
21210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21211         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
21212         return ret_val;
21213 }
21214
21215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21216         LDKChannelHandshakeLimits this_ptr_conv;
21217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21218         this_ptr_conv.is_owned = false;
21219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21220         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
21221 }
21222
21223 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
21224         LDKChannelHandshakeLimits this_ptr_conv;
21225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21226         this_ptr_conv.is_owned = false;
21227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21228         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
21229         return ret_val;
21230 }
21231
21232 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) {
21233         LDKChannelHandshakeLimits this_ptr_conv;
21234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21235         this_ptr_conv.is_owned = false;
21236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21237         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
21238 }
21239
21240 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) {
21241         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);
21242         uint64_t ret_ref = 0;
21243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21246         ret_ref = (uint64_t)ret_var.inner;
21247         if (ret_var.is_owned) {
21248                 ret_ref |= 1;
21249         }
21250         return ret_ref;
21251 }
21252
21253 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
21254         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
21255 uint64_t ret_ref = 0;
21256 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21257 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21258 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21259 ret_ref = (uint64_t)ret_var.inner;
21260 if (ret_var.is_owned) {
21261         ret_ref |= 1;
21262 }
21263         return ret_ref;
21264 }
21265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21266         LDKChannelHandshakeLimits arg_conv;
21267         arg_conv.inner = (void*)(arg & (~1));
21268         arg_conv.is_owned = false;
21269         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21270         int64_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
21271         return ret_val;
21272 }
21273
21274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21275         LDKChannelHandshakeLimits orig_conv;
21276         orig_conv.inner = (void*)(orig & (~1));
21277         orig_conv.is_owned = false;
21278         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21279         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
21280         uint64_t ret_ref = 0;
21281         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21282         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21284         ret_ref = (uint64_t)ret_var.inner;
21285         if (ret_var.is_owned) {
21286                 ret_ref |= 1;
21287         }
21288         return ret_ref;
21289 }
21290
21291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
21292         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
21293         uint64_t ret_ref = 0;
21294         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21295         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21297         ret_ref = (uint64_t)ret_var.inner;
21298         if (ret_var.is_owned) {
21299                 ret_ref |= 1;
21300         }
21301         return ret_ref;
21302 }
21303
21304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21305         LDKChannelConfig this_obj_conv;
21306         this_obj_conv.inner = (void*)(this_obj & (~1));
21307         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21309         ChannelConfig_free(this_obj_conv);
21310 }
21311
21312 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
21313         LDKChannelConfig this_ptr_conv;
21314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21315         this_ptr_conv.is_owned = false;
21316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21317         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
21318         return ret_val;
21319 }
21320
21321 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) {
21322         LDKChannelConfig this_ptr_conv;
21323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21324         this_ptr_conv.is_owned = false;
21325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21326         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
21327 }
21328
21329 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21330         LDKChannelConfig this_ptr_conv;
21331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21332         this_ptr_conv.is_owned = false;
21333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21334         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
21335         return ret_val;
21336 }
21337
21338 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) {
21339         LDKChannelConfig this_ptr_conv;
21340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21341         this_ptr_conv.is_owned = false;
21342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21343         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
21344 }
21345
21346 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
21347         LDKChannelConfig this_ptr_conv;
21348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21349         this_ptr_conv.is_owned = false;
21350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21351         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
21352         return ret_val;
21353 }
21354
21355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
21356         LDKChannelConfig this_ptr_conv;
21357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21358         this_ptr_conv.is_owned = false;
21359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21360         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
21361 }
21362
21363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
21364         LDKChannelConfig this_ptr_conv;
21365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21366         this_ptr_conv.is_owned = false;
21367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21368         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
21369         return ret_val;
21370 }
21371
21372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21373         LDKChannelConfig this_ptr_conv;
21374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21375         this_ptr_conv.is_owned = false;
21376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21377         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
21378 }
21379
21380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21381         LDKChannelConfig this_ptr_conv;
21382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21383         this_ptr_conv.is_owned = false;
21384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21385         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
21386         return ret_val;
21387 }
21388
21389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21390         LDKChannelConfig this_ptr_conv;
21391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21392         this_ptr_conv.is_owned = false;
21393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21394         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
21395 }
21396
21397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
21398         LDKChannelConfig this_ptr_conv;
21399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21400         this_ptr_conv.is_owned = false;
21401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21402         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
21403         return ret_val;
21404 }
21405
21406 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) {
21407         LDKChannelConfig this_ptr_conv;
21408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21409         this_ptr_conv.is_owned = false;
21410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21411         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
21412 }
21413
21414 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) {
21415         LDKChannelConfig this_ptr_conv;
21416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21417         this_ptr_conv.is_owned = false;
21418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21419         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
21420         return ret_val;
21421 }
21422
21423 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) {
21424         LDKChannelConfig this_ptr_conv;
21425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21426         this_ptr_conv.is_owned = false;
21427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21428         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
21429 }
21430
21431 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) {
21432         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);
21433         uint64_t ret_ref = 0;
21434         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21435         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21437         ret_ref = (uint64_t)ret_var.inner;
21438         if (ret_var.is_owned) {
21439                 ret_ref |= 1;
21440         }
21441         return ret_ref;
21442 }
21443
21444 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
21445         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
21446 uint64_t ret_ref = 0;
21447 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21448 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21449 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21450 ret_ref = (uint64_t)ret_var.inner;
21451 if (ret_var.is_owned) {
21452         ret_ref |= 1;
21453 }
21454         return ret_ref;
21455 }
21456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21457         LDKChannelConfig arg_conv;
21458         arg_conv.inner = (void*)(arg & (~1));
21459         arg_conv.is_owned = false;
21460         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21461         int64_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
21462         return ret_val;
21463 }
21464
21465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21466         LDKChannelConfig orig_conv;
21467         orig_conv.inner = (void*)(orig & (~1));
21468         orig_conv.is_owned = false;
21469         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21470         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
21471         uint64_t ret_ref = 0;
21472         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21473         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21475         ret_ref = (uint64_t)ret_var.inner;
21476         if (ret_var.is_owned) {
21477                 ret_ref |= 1;
21478         }
21479         return ret_ref;
21480 }
21481
21482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
21483         LDKChannelConfig ret_var = ChannelConfig_default();
21484         uint64_t ret_ref = 0;
21485         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21486         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21488         ret_ref = (uint64_t)ret_var.inner;
21489         if (ret_var.is_owned) {
21490                 ret_ref |= 1;
21491         }
21492         return ret_ref;
21493 }
21494
21495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
21496         LDKChannelConfig obj_conv;
21497         obj_conv.inner = (void*)(obj & (~1));
21498         obj_conv.is_owned = false;
21499         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21500         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
21501         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21502         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21503         CVec_u8Z_free(ret_var);
21504         return ret_arr;
21505 }
21506
21507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21508         LDKu8slice ser_ref;
21509         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21510         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21511         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21512         *ret_conv = ChannelConfig_read(ser_ref);
21513         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21514         return (uint64_t)ret_conv;
21515 }
21516
21517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21518         LDKUserConfig this_obj_conv;
21519         this_obj_conv.inner = (void*)(this_obj & (~1));
21520         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21522         UserConfig_free(this_obj_conv);
21523 }
21524
21525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
21526         LDKUserConfig this_ptr_conv;
21527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21528         this_ptr_conv.is_owned = false;
21529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21530         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
21531         uint64_t ret_ref = 0;
21532         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21533         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21535         ret_ref = (uint64_t)ret_var.inner;
21536         if (ret_var.is_owned) {
21537                 ret_ref |= 1;
21538         }
21539         return ret_ref;
21540 }
21541
21542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21543         LDKUserConfig this_ptr_conv;
21544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21545         this_ptr_conv.is_owned = false;
21546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21547         LDKChannelHandshakeConfig val_conv;
21548         val_conv.inner = (void*)(val & (~1));
21549         val_conv.is_owned = (val & 1) || (val == 0);
21550         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21551         val_conv = ChannelHandshakeConfig_clone(&val_conv);
21552         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
21553 }
21554
21555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
21556         LDKUserConfig this_ptr_conv;
21557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21558         this_ptr_conv.is_owned = false;
21559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21560         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
21561         uint64_t ret_ref = 0;
21562         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21563         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21565         ret_ref = (uint64_t)ret_var.inner;
21566         if (ret_var.is_owned) {
21567                 ret_ref |= 1;
21568         }
21569         return ret_ref;
21570 }
21571
21572 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) {
21573         LDKUserConfig this_ptr_conv;
21574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21575         this_ptr_conv.is_owned = false;
21576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21577         LDKChannelHandshakeLimits val_conv;
21578         val_conv.inner = (void*)(val & (~1));
21579         val_conv.is_owned = (val & 1) || (val == 0);
21580         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21581         val_conv = ChannelHandshakeLimits_clone(&val_conv);
21582         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
21583 }
21584
21585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
21586         LDKUserConfig this_ptr_conv;
21587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21588         this_ptr_conv.is_owned = false;
21589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21590         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
21591         uint64_t ret_ref = 0;
21592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21595         ret_ref = (uint64_t)ret_var.inner;
21596         if (ret_var.is_owned) {
21597                 ret_ref |= 1;
21598         }
21599         return ret_ref;
21600 }
21601
21602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21603         LDKUserConfig this_ptr_conv;
21604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21605         this_ptr_conv.is_owned = false;
21606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21607         LDKChannelConfig val_conv;
21608         val_conv.inner = (void*)(val & (~1));
21609         val_conv.is_owned = (val & 1) || (val == 0);
21610         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21611         val_conv = ChannelConfig_clone(&val_conv);
21612         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
21613 }
21614
21615 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
21616         LDKUserConfig this_ptr_conv;
21617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21618         this_ptr_conv.is_owned = false;
21619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21620         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
21621         return ret_val;
21622 }
21623
21624 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) {
21625         LDKUserConfig this_ptr_conv;
21626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21627         this_ptr_conv.is_owned = false;
21628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21629         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
21630 }
21631
21632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
21633         LDKUserConfig this_ptr_conv;
21634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21635         this_ptr_conv.is_owned = false;
21636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21637         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
21638         return ret_val;
21639 }
21640
21641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
21642         LDKUserConfig this_ptr_conv;
21643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21644         this_ptr_conv.is_owned = false;
21645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21646         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
21647 }
21648
21649 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) {
21650         LDKChannelHandshakeConfig own_channel_config_arg_conv;
21651         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
21652         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
21653         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
21654         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
21655         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
21656         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
21657         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
21658         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
21659         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
21660         LDKChannelConfig channel_options_arg_conv;
21661         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
21662         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
21663         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
21664         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
21665         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);
21666         uint64_t ret_ref = 0;
21667         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21668         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21670         ret_ref = (uint64_t)ret_var.inner;
21671         if (ret_var.is_owned) {
21672                 ret_ref |= 1;
21673         }
21674         return ret_ref;
21675 }
21676
21677 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
21678         LDKUserConfig ret_var = UserConfig_clone(arg);
21679 uint64_t ret_ref = 0;
21680 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21681 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21682 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21683 ret_ref = (uint64_t)ret_var.inner;
21684 if (ret_var.is_owned) {
21685         ret_ref |= 1;
21686 }
21687         return ret_ref;
21688 }
21689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21690         LDKUserConfig arg_conv;
21691         arg_conv.inner = (void*)(arg & (~1));
21692         arg_conv.is_owned = false;
21693         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21694         int64_t ret_val = UserConfig_clone_ptr(&arg_conv);
21695         return ret_val;
21696 }
21697
21698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21699         LDKUserConfig orig_conv;
21700         orig_conv.inner = (void*)(orig & (~1));
21701         orig_conv.is_owned = false;
21702         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21703         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
21704         uint64_t ret_ref = 0;
21705         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21706         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21708         ret_ref = (uint64_t)ret_var.inner;
21709         if (ret_var.is_owned) {
21710                 ret_ref |= 1;
21711         }
21712         return ret_ref;
21713 }
21714
21715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
21716         LDKUserConfig ret_var = UserConfig_default();
21717         uint64_t ret_ref = 0;
21718         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21719         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21721         ret_ref = (uint64_t)ret_var.inner;
21722         if (ret_var.is_owned) {
21723                 ret_ref |= 1;
21724         }
21725         return ret_ref;
21726 }
21727
21728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21729         LDKBestBlock this_obj_conv;
21730         this_obj_conv.inner = (void*)(this_obj & (~1));
21731         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21733         BestBlock_free(this_obj_conv);
21734 }
21735
21736 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
21737         LDKBestBlock ret_var = BestBlock_clone(arg);
21738 uint64_t ret_ref = 0;
21739 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21740 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21741 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21742 ret_ref = (uint64_t)ret_var.inner;
21743 if (ret_var.is_owned) {
21744         ret_ref |= 1;
21745 }
21746         return ret_ref;
21747 }
21748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21749         LDKBestBlock arg_conv;
21750         arg_conv.inner = (void*)(arg & (~1));
21751         arg_conv.is_owned = false;
21752         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21753         int64_t ret_val = BestBlock_clone_ptr(&arg_conv);
21754         return ret_val;
21755 }
21756
21757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21758         LDKBestBlock orig_conv;
21759         orig_conv.inner = (void*)(orig & (~1));
21760         orig_conv.is_owned = false;
21761         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21762         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
21763         uint64_t ret_ref = 0;
21764         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21765         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21767         ret_ref = (uint64_t)ret_var.inner;
21768         if (ret_var.is_owned) {
21769                 ret_ref |= 1;
21770         }
21771         return ret_ref;
21772 }
21773
21774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
21775         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
21776         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
21777         uint64_t ret_ref = 0;
21778         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21779         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21781         ret_ref = (uint64_t)ret_var.inner;
21782         if (ret_var.is_owned) {
21783                 ret_ref |= 1;
21784         }
21785         return ret_ref;
21786 }
21787
21788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
21789         LDKThirtyTwoBytes block_hash_ref;
21790         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
21791         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
21792         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
21793         uint64_t ret_ref = 0;
21794         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21795         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21797         ret_ref = (uint64_t)ret_var.inner;
21798         if (ret_var.is_owned) {
21799                 ret_ref |= 1;
21800         }
21801         return ret_ref;
21802 }
21803
21804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
21805         LDKBestBlock this_arg_conv;
21806         this_arg_conv.inner = (void*)(this_arg & (~1));
21807         this_arg_conv.is_owned = false;
21808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21809         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
21811         return ret_arr;
21812 }
21813
21814 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
21815         LDKBestBlock this_arg_conv;
21816         this_arg_conv.inner = (void*)(this_arg & (~1));
21817         this_arg_conv.is_owned = false;
21818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21819         int32_t ret_val = BestBlock_height(&this_arg_conv);
21820         return ret_val;
21821 }
21822
21823 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21824         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21825         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
21826         return ret_conv;
21827 }
21828
21829 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
21830         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
21831         return ret_conv;
21832 }
21833
21834 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
21835         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
21836         return ret_conv;
21837 }
21838
21839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21840         if ((this_ptr & 1) != 0) return;
21841         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21842         CHECK_ACCESS(this_ptr_ptr);
21843         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21844         FREE((void*)this_ptr);
21845         Access_free(this_ptr_conv);
21846 }
21847
21848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21849         if ((this_ptr & 1) != 0) return;
21850         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21851         CHECK_ACCESS(this_ptr_ptr);
21852         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21853         FREE((void*)this_ptr);
21854         Listen_free(this_ptr_conv);
21855 }
21856
21857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21858         if ((this_ptr & 1) != 0) return;
21859         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21860         CHECK_ACCESS(this_ptr_ptr);
21861         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21862         FREE((void*)this_ptr);
21863         Confirm_free(this_ptr_conv);
21864 }
21865
21866 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21867         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21868         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
21869         return ret_conv;
21870 }
21871
21872 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
21873         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
21874         return ret_conv;
21875 }
21876
21877 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
21878         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
21879         return ret_conv;
21880 }
21881
21882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21883         if ((this_ptr & 1) != 0) return;
21884         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21885         CHECK_ACCESS(this_ptr_ptr);
21886         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21887         FREE((void*)this_ptr);
21888         Watch_free(this_ptr_conv);
21889 }
21890
21891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21892         if ((this_ptr & 1) != 0) return;
21893         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21894         CHECK_ACCESS(this_ptr_ptr);
21895         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21896         FREE((void*)this_ptr);
21897         Filter_free(this_ptr_conv);
21898 }
21899
21900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21901         LDKWatchedOutput this_obj_conv;
21902         this_obj_conv.inner = (void*)(this_obj & (~1));
21903         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21905         WatchedOutput_free(this_obj_conv);
21906 }
21907
21908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21909         LDKWatchedOutput this_ptr_conv;
21910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21911         this_ptr_conv.is_owned = false;
21912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21913         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
21915         return ret_arr;
21916 }
21917
21918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21919         LDKWatchedOutput this_ptr_conv;
21920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21921         this_ptr_conv.is_owned = false;
21922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21923         LDKThirtyTwoBytes val_ref;
21924         CHECK((*env)->GetArrayLength(env, val) == 32);
21925         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21926         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21927 }
21928
21929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21930         LDKWatchedOutput this_ptr_conv;
21931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21932         this_ptr_conv.is_owned = false;
21933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21934         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21935         uint64_t ret_ref = 0;
21936         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21937         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21939         ret_ref = (uint64_t)ret_var.inner;
21940         if (ret_var.is_owned) {
21941                 ret_ref |= 1;
21942         }
21943         return ret_ref;
21944 }
21945
21946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21947         LDKWatchedOutput this_ptr_conv;
21948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21949         this_ptr_conv.is_owned = false;
21950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21951         LDKOutPoint val_conv;
21952         val_conv.inner = (void*)(val & (~1));
21953         val_conv.is_owned = (val & 1) || (val == 0);
21954         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21955         val_conv = OutPoint_clone(&val_conv);
21956         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21957 }
21958
21959 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21960         LDKWatchedOutput this_ptr_conv;
21961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21962         this_ptr_conv.is_owned = false;
21963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21964         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21965         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21966         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21967         return ret_arr;
21968 }
21969
21970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21971         LDKWatchedOutput this_ptr_conv;
21972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21973         this_ptr_conv.is_owned = false;
21974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21975         LDKCVec_u8Z val_ref;
21976         val_ref.datalen = (*env)->GetArrayLength(env, val);
21977         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21978         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
21979         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21980 }
21981
21982 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) {
21983         LDKThirtyTwoBytes block_hash_arg_ref;
21984         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
21985         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
21986         LDKOutPoint outpoint_arg_conv;
21987         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21988         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21989         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21990         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21991         LDKCVec_u8Z script_pubkey_arg_ref;
21992         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
21993         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21994         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
21995         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21996         uint64_t ret_ref = 0;
21997         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21998         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22000         ret_ref = (uint64_t)ret_var.inner;
22001         if (ret_var.is_owned) {
22002                 ret_ref |= 1;
22003         }
22004         return ret_ref;
22005 }
22006
22007 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
22008         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
22009 uint64_t ret_ref = 0;
22010 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22011 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22012 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22013 ret_ref = (uint64_t)ret_var.inner;
22014 if (ret_var.is_owned) {
22015         ret_ref |= 1;
22016 }
22017         return ret_ref;
22018 }
22019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22020         LDKWatchedOutput arg_conv;
22021         arg_conv.inner = (void*)(arg & (~1));
22022         arg_conv.is_owned = false;
22023         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22024         int64_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
22025         return ret_val;
22026 }
22027
22028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22029         LDKWatchedOutput orig_conv;
22030         orig_conv.inner = (void*)(orig & (~1));
22031         orig_conv.is_owned = false;
22032         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22033         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
22034         uint64_t ret_ref = 0;
22035         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22036         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22038         ret_ref = (uint64_t)ret_var.inner;
22039         if (ret_var.is_owned) {
22040                 ret_ref |= 1;
22041         }
22042         return ret_ref;
22043 }
22044
22045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
22046         LDKWatchedOutput o_conv;
22047         o_conv.inner = (void*)(o & (~1));
22048         o_conv.is_owned = false;
22049         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22050         int64_t ret_val = WatchedOutput_hash(&o_conv);
22051         return ret_val;
22052 }
22053
22054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22055         if ((this_ptr & 1) != 0) return;
22056         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
22057         CHECK_ACCESS(this_ptr_ptr);
22058         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
22059         FREE((void*)this_ptr);
22060         BroadcasterInterface_free(this_ptr_conv);
22061 }
22062
22063 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22064         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
22065         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
22066         return ret_conv;
22067 }
22068
22069 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
22070         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
22071         return ret_conv;
22072 }
22073
22074 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
22075         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
22076         return ret_conv;
22077 }
22078
22079 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
22080         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
22081         return ret_conv;
22082 }
22083
22084 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22085         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
22086         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
22087         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
22088         return ret_val;
22089 }
22090
22091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22092         if ((this_ptr & 1) != 0) return;
22093         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
22094         CHECK_ACCESS(this_ptr_ptr);
22095         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
22096         FREE((void*)this_ptr);
22097         FeeEstimator_free(this_ptr_conv);
22098 }
22099
22100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22101         LDKMonitorUpdateId this_obj_conv;
22102         this_obj_conv.inner = (void*)(this_obj & (~1));
22103         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22105         MonitorUpdateId_free(this_obj_conv);
22106 }
22107
22108 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
22109         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
22110 uint64_t ret_ref = 0;
22111 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22112 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22113 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22114 ret_ref = (uint64_t)ret_var.inner;
22115 if (ret_var.is_owned) {
22116         ret_ref |= 1;
22117 }
22118         return ret_ref;
22119 }
22120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22121         LDKMonitorUpdateId arg_conv;
22122         arg_conv.inner = (void*)(arg & (~1));
22123         arg_conv.is_owned = false;
22124         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22125         int64_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
22126         return ret_val;
22127 }
22128
22129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22130         LDKMonitorUpdateId orig_conv;
22131         orig_conv.inner = (void*)(orig & (~1));
22132         orig_conv.is_owned = false;
22133         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22134         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
22135         uint64_t ret_ref = 0;
22136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22139         ret_ref = (uint64_t)ret_var.inner;
22140         if (ret_var.is_owned) {
22141                 ret_ref |= 1;
22142         }
22143         return ret_ref;
22144 }
22145
22146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
22147         LDKMonitorUpdateId o_conv;
22148         o_conv.inner = (void*)(o & (~1));
22149         o_conv.is_owned = false;
22150         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22151         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
22152         return ret_val;
22153 }
22154
22155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22156         LDKMonitorUpdateId a_conv;
22157         a_conv.inner = (void*)(a & (~1));
22158         a_conv.is_owned = false;
22159         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22160         LDKMonitorUpdateId b_conv;
22161         b_conv.inner = (void*)(b & (~1));
22162         b_conv.is_owned = false;
22163         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22164         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
22165         return ret_val;
22166 }
22167
22168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22169         if ((this_ptr & 1) != 0) return;
22170         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
22171         CHECK_ACCESS(this_ptr_ptr);
22172         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
22173         FREE((void*)this_ptr);
22174         Persist_free(this_ptr_conv);
22175 }
22176
22177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22178         LDKLockedChannelMonitor this_obj_conv;
22179         this_obj_conv.inner = (void*)(this_obj & (~1));
22180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22182         LockedChannelMonitor_free(this_obj_conv);
22183 }
22184
22185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22186         LDKChainMonitor this_obj_conv;
22187         this_obj_conv.inner = (void*)(this_obj & (~1));
22188         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22190         ChainMonitor_free(this_obj_conv);
22191 }
22192
22193 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) {
22194         void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
22195         CHECK_ACCESS(chain_source_ptr);
22196         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
22197         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
22198         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
22199                 // Manually implement clone for Java trait instances
22200                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
22201                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22202                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
22203                 }
22204         }
22205         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22206         CHECK_ACCESS(broadcaster_ptr);
22207         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22208         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22209                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22210                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22211         }
22212         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22213         CHECK_ACCESS(logger_ptr);
22214         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22215         if (logger_conv.free == LDKLogger_JCalls_free) {
22216                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22217                 LDKLogger_JCalls_cloned(&logger_conv);
22218         }
22219         void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
22220         CHECK_ACCESS(feeest_ptr);
22221         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
22222         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
22223                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22224                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
22225         }
22226         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
22227         CHECK_ACCESS(persister_ptr);
22228         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
22229         if (persister_conv.free == LDKPersist_JCalls_free) {
22230                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22231                 LDKPersist_JCalls_cloned(&persister_conv);
22232         }
22233         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
22234         uint64_t ret_ref = 0;
22235         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22236         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22238         ret_ref = (uint64_t)ret_var.inner;
22239         if (ret_var.is_owned) {
22240                 ret_ref |= 1;
22241         }
22242         return ret_ref;
22243 }
22244
22245 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) {
22246         LDKChainMonitor this_arg_conv;
22247         this_arg_conv.inner = (void*)(this_arg & (~1));
22248         this_arg_conv.is_owned = false;
22249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22250         LDKCVec_ChannelDetailsZ ignored_channels_constr;
22251         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
22252         if (ignored_channels_constr.datalen > 0)
22253                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
22254         else
22255                 ignored_channels_constr.data = NULL;
22256         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
22257         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
22258                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
22259                 LDKChannelDetails ignored_channels_conv_16_conv;
22260                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
22261                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
22262                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
22263                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
22264                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
22265         }
22266         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
22267         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
22268         int64_tArray ret_arr = NULL;
22269         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22270         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22271         for (size_t j = 0; j < ret_var.datalen; j++) {
22272                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22273                 *ret_conv_9_copy = ret_var.data[j];
22274                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
22275                 ret_arr_ptr[j] = ret_conv_9_ref;
22276         }
22277         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22278         FREE(ret_var.data);
22279         return ret_arr;
22280 }
22281
22282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
22283         LDKChainMonitor this_arg_conv;
22284         this_arg_conv.inner = (void*)(this_arg & (~1));
22285         this_arg_conv.is_owned = false;
22286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22287         LDKOutPoint funding_txo_conv;
22288         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22289         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22290         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22291         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22292         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22293         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
22294         return (uint64_t)ret_conv;
22295 }
22296
22297 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
22298         LDKChainMonitor this_arg_conv;
22299         this_arg_conv.inner = (void*)(this_arg & (~1));
22300         this_arg_conv.is_owned = false;
22301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22302         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
22303         int64_tArray ret_arr = NULL;
22304         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22305         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22306         for (size_t k = 0; k < ret_var.datalen; k++) {
22307                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
22308                 uint64_t ret_conv_10_ref = 0;
22309                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22310                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22311                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
22312                 ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
22313                 if (ret_conv_10_var.is_owned) {
22314                         ret_conv_10_ref |= 1;
22315                 }
22316                 ret_arr_ptr[k] = ret_conv_10_ref;
22317         }
22318         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22319         FREE(ret_var.data);
22320         return ret_arr;
22321 }
22322
22323 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) {
22324         LDKChainMonitor this_arg_conv;
22325         this_arg_conv.inner = (void*)(this_arg & (~1));
22326         this_arg_conv.is_owned = false;
22327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22328         LDKOutPoint funding_txo_conv;
22329         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22330         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22331         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22332         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22333         LDKMonitorUpdateId completed_update_id_conv;
22334         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
22335         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
22336         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
22337         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
22338         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
22339         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
22340         return (uint64_t)ret_conv;
22341 }
22342
22343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
22344         LDKChainMonitor this_arg_conv;
22345         this_arg_conv.inner = (void*)(this_arg & (~1));
22346         this_arg_conv.is_owned = false;
22347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22348         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
22349         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
22350         return (uint64_t)ret_ret;
22351 }
22352
22353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
22354         LDKChainMonitor this_arg_conv;
22355         this_arg_conv.inner = (void*)(this_arg & (~1));
22356         this_arg_conv.is_owned = false;
22357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22358         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
22359         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
22360         return (uint64_t)ret_ret;
22361 }
22362
22363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
22364         LDKChainMonitor this_arg_conv;
22365         this_arg_conv.inner = (void*)(this_arg & (~1));
22366         this_arg_conv.is_owned = false;
22367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22368         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
22369         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
22370         return (uint64_t)ret_ret;
22371 }
22372
22373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
22374         LDKChainMonitor this_arg_conv;
22375         this_arg_conv.inner = (void*)(this_arg & (~1));
22376         this_arg_conv.is_owned = false;
22377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22378         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
22379         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
22380         return (uint64_t)ret_ret;
22381 }
22382
22383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22384         LDKChannelMonitorUpdate this_obj_conv;
22385         this_obj_conv.inner = (void*)(this_obj & (~1));
22386         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22388         ChannelMonitorUpdate_free(this_obj_conv);
22389 }
22390
22391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22392         LDKChannelMonitorUpdate this_ptr_conv;
22393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22394         this_ptr_conv.is_owned = false;
22395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22396         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
22397         return ret_val;
22398 }
22399
22400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22401         LDKChannelMonitorUpdate this_ptr_conv;
22402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22403         this_ptr_conv.is_owned = false;
22404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22405         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
22406 }
22407
22408 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
22409         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
22410 uint64_t ret_ref = 0;
22411 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22412 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22413 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22414 ret_ref = (uint64_t)ret_var.inner;
22415 if (ret_var.is_owned) {
22416         ret_ref |= 1;
22417 }
22418         return ret_ref;
22419 }
22420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22421         LDKChannelMonitorUpdate arg_conv;
22422         arg_conv.inner = (void*)(arg & (~1));
22423         arg_conv.is_owned = false;
22424         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22425         int64_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
22426         return ret_val;
22427 }
22428
22429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22430         LDKChannelMonitorUpdate orig_conv;
22431         orig_conv.inner = (void*)(orig & (~1));
22432         orig_conv.is_owned = false;
22433         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22434         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
22435         uint64_t ret_ref = 0;
22436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22439         ret_ref = (uint64_t)ret_var.inner;
22440         if (ret_var.is_owned) {
22441                 ret_ref |= 1;
22442         }
22443         return ret_ref;
22444 }
22445
22446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
22447         LDKChannelMonitorUpdate obj_conv;
22448         obj_conv.inner = (void*)(obj & (~1));
22449         obj_conv.is_owned = false;
22450         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22451         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
22452         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22453         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22454         CVec_u8Z_free(ret_var);
22455         return ret_arr;
22456 }
22457
22458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22459         LDKu8slice ser_ref;
22460         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22461         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22462         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22463         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
22464         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22465         return (uint64_t)ret_conv;
22466 }
22467
22468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22469         if ((this_ptr & 1) != 0) return;
22470         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
22471         CHECK_ACCESS(this_ptr_ptr);
22472         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
22473         FREE((void*)this_ptr);
22474         MonitorEvent_free(this_ptr_conv);
22475 }
22476
22477 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
22478         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22479         *ret_copy = MonitorEvent_clone(arg);
22480 uint64_t ret_ref = (uint64_t)ret_copy;
22481         return ret_ref;
22482 }
22483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22484         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
22485         int64_t ret_val = MonitorEvent_clone_ptr(arg_conv);
22486         return ret_val;
22487 }
22488
22489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22490         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
22491         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22492         *ret_copy = MonitorEvent_clone(orig_conv);
22493         uint64_t ret_ref = (uint64_t)ret_copy;
22494         return ret_ref;
22495 }
22496
22497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
22498         LDKHTLCUpdate a_conv;
22499         a_conv.inner = (void*)(a & (~1));
22500         a_conv.is_owned = (a & 1) || (a == 0);
22501         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22502         a_conv = HTLCUpdate_clone(&a_conv);
22503         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22504         *ret_copy = MonitorEvent_htlcevent(a_conv);
22505         uint64_t ret_ref = (uint64_t)ret_copy;
22506         return ret_ref;
22507 }
22508
22509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
22510         LDKOutPoint a_conv;
22511         a_conv.inner = (void*)(a & (~1));
22512         a_conv.is_owned = (a & 1) || (a == 0);
22513         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22514         a_conv = OutPoint_clone(&a_conv);
22515         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22516         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
22517         uint64_t ret_ref = (uint64_t)ret_copy;
22518         return ret_ref;
22519 }
22520
22521 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) {
22522         LDKOutPoint funding_txo_conv;
22523         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22524         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22525         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22526         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22527         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22528         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
22529         uint64_t ret_ref = (uint64_t)ret_copy;
22530         return ret_ref;
22531 }
22532
22533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
22534         LDKOutPoint a_conv;
22535         a_conv.inner = (void*)(a & (~1));
22536         a_conv.is_owned = (a & 1) || (a == 0);
22537         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22538         a_conv = OutPoint_clone(&a_conv);
22539         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22540         *ret_copy = MonitorEvent_update_failed(a_conv);
22541         uint64_t ret_ref = (uint64_t)ret_copy;
22542         return ret_ref;
22543 }
22544
22545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
22546         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
22547         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
22548         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22549         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22550         CVec_u8Z_free(ret_var);
22551         return ret_arr;
22552 }
22553
22554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22555         LDKu8slice ser_ref;
22556         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22557         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22558         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22559         *ret_conv = MonitorEvent_read(ser_ref);
22560         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22561         return (uint64_t)ret_conv;
22562 }
22563
22564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22565         LDKHTLCUpdate this_obj_conv;
22566         this_obj_conv.inner = (void*)(this_obj & (~1));
22567         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22569         HTLCUpdate_free(this_obj_conv);
22570 }
22571
22572 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
22573         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
22574 uint64_t ret_ref = 0;
22575 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22576 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22577 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22578 ret_ref = (uint64_t)ret_var.inner;
22579 if (ret_var.is_owned) {
22580         ret_ref |= 1;
22581 }
22582         return ret_ref;
22583 }
22584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22585         LDKHTLCUpdate arg_conv;
22586         arg_conv.inner = (void*)(arg & (~1));
22587         arg_conv.is_owned = false;
22588         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22589         int64_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
22590         return ret_val;
22591 }
22592
22593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22594         LDKHTLCUpdate orig_conv;
22595         orig_conv.inner = (void*)(orig & (~1));
22596         orig_conv.is_owned = false;
22597         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22598         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
22599         uint64_t ret_ref = 0;
22600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22603         ret_ref = (uint64_t)ret_var.inner;
22604         if (ret_var.is_owned) {
22605                 ret_ref |= 1;
22606         }
22607         return ret_ref;
22608 }
22609
22610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
22611         LDKHTLCUpdate obj_conv;
22612         obj_conv.inner = (void*)(obj & (~1));
22613         obj_conv.is_owned = false;
22614         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22615         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
22616         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22617         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22618         CVec_u8Z_free(ret_var);
22619         return ret_arr;
22620 }
22621
22622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22623         LDKu8slice ser_ref;
22624         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22625         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22626         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22627         *ret_conv = HTLCUpdate_read(ser_ref);
22628         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22629         return (uint64_t)ret_conv;
22630 }
22631
22632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22633         if ((this_ptr & 1) != 0) return;
22634         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
22635         CHECK_ACCESS(this_ptr_ptr);
22636         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
22637         FREE((void*)this_ptr);
22638         Balance_free(this_ptr_conv);
22639 }
22640
22641 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
22642         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22643         *ret_copy = Balance_clone(arg);
22644 uint64_t ret_ref = (uint64_t)ret_copy;
22645         return ret_ref;
22646 }
22647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22648         LDKBalance* arg_conv = (LDKBalance*)arg;
22649         int64_t ret_val = Balance_clone_ptr(arg_conv);
22650         return ret_val;
22651 }
22652
22653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22654         LDKBalance* orig_conv = (LDKBalance*)orig;
22655         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22656         *ret_copy = Balance_clone(orig_conv);
22657         uint64_t ret_ref = (uint64_t)ret_copy;
22658         return ret_ref;
22659 }
22660
22661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
22662         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22663         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
22664         uint64_t ret_ref = (uint64_t)ret_copy;
22665         return ret_ref;
22666 }
22667
22668 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) {
22669         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22670         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
22671         uint64_t ret_ref = (uint64_t)ret_copy;
22672         return ret_ref;
22673 }
22674
22675 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) {
22676         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22677         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
22678         uint64_t ret_ref = (uint64_t)ret_copy;
22679         return ret_ref;
22680 }
22681
22682 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) {
22683         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22684         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
22685         uint64_t ret_ref = (uint64_t)ret_copy;
22686         return ret_ref;
22687 }
22688
22689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22690         LDKBalance* a_conv = (LDKBalance*)a;
22691         LDKBalance* b_conv = (LDKBalance*)b;
22692         jboolean ret_val = Balance_eq(a_conv, b_conv);
22693         return ret_val;
22694 }
22695
22696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22697         LDKChannelMonitor this_obj_conv;
22698         this_obj_conv.inner = (void*)(this_obj & (~1));
22699         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22701         ChannelMonitor_free(this_obj_conv);
22702 }
22703
22704 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
22705         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
22706 uint64_t ret_ref = 0;
22707 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22708 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22709 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22710 ret_ref = (uint64_t)ret_var.inner;
22711 if (ret_var.is_owned) {
22712         ret_ref |= 1;
22713 }
22714         return ret_ref;
22715 }
22716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22717         LDKChannelMonitor arg_conv;
22718         arg_conv.inner = (void*)(arg & (~1));
22719         arg_conv.is_owned = false;
22720         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22721         int64_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
22722         return ret_val;
22723 }
22724
22725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22726         LDKChannelMonitor orig_conv;
22727         orig_conv.inner = (void*)(orig & (~1));
22728         orig_conv.is_owned = false;
22729         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22730         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
22731         uint64_t ret_ref = 0;
22732         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22733         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22735         ret_ref = (uint64_t)ret_var.inner;
22736         if (ret_var.is_owned) {
22737                 ret_ref |= 1;
22738         }
22739         return ret_ref;
22740 }
22741
22742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
22743         LDKChannelMonitor obj_conv;
22744         obj_conv.inner = (void*)(obj & (~1));
22745         obj_conv.is_owned = false;
22746         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22747         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
22748         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22749         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22750         CVec_u8Z_free(ret_var);
22751         return ret_arr;
22752 }
22753
22754 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) {
22755         LDKChannelMonitor this_arg_conv;
22756         this_arg_conv.inner = (void*)(this_arg & (~1));
22757         this_arg_conv.is_owned = false;
22758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22759         LDKChannelMonitorUpdate updates_conv;
22760         updates_conv.inner = (void*)(updates & (~1));
22761         updates_conv.is_owned = false;
22762         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
22763         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22764         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22765         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22766         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22767         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22768         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22769         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22770         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22771         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22772         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
22773         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22774         return (uint64_t)ret_conv;
22775 }
22776
22777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
22778         LDKChannelMonitor this_arg_conv;
22779         this_arg_conv.inner = (void*)(this_arg & (~1));
22780         this_arg_conv.is_owned = false;
22781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22782         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22783         return ret_val;
22784 }
22785
22786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
22787         LDKChannelMonitor this_arg_conv;
22788         this_arg_conv.inner = (void*)(this_arg & (~1));
22789         this_arg_conv.is_owned = false;
22790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22791         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22792         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22793         return ((uint64_t)ret_conv);
22794 }
22795
22796 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
22797         LDKChannelMonitor this_arg_conv;
22798         this_arg_conv.inner = (void*)(this_arg & (~1));
22799         this_arg_conv.is_owned = false;
22800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22801         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22802         int64_tArray ret_arr = NULL;
22803         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22804         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22805         for (size_t o = 0; o < ret_var.datalen; o++) {
22806                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22807                 *ret_conv_40_conv = ret_var.data[o];
22808                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
22809         }
22810         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22811         FREE(ret_var.data);
22812         return ret_arr;
22813 }
22814
22815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
22816         LDKChannelMonitor this_arg_conv;
22817         this_arg_conv.inner = (void*)(this_arg & (~1));
22818         this_arg_conv.is_owned = false;
22819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22820         void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
22821         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22822         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22823         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22824 }
22825
22826 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22827         LDKChannelMonitor this_arg_conv;
22828         this_arg_conv.inner = (void*)(this_arg & (~1));
22829         this_arg_conv.is_owned = false;
22830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22831         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22832         int64_tArray ret_arr = NULL;
22833         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22834         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22835         for (size_t o = 0; o < ret_var.datalen; o++) {
22836                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22837                 *ret_conv_14_copy = ret_var.data[o];
22838                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
22839                 ret_arr_ptr[o] = ret_conv_14_ref;
22840         }
22841         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22842         FREE(ret_var.data);
22843         return ret_arr;
22844 }
22845
22846 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22847         LDKChannelMonitor this_arg_conv;
22848         this_arg_conv.inner = (void*)(this_arg & (~1));
22849         this_arg_conv.is_owned = false;
22850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22851         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22852         int64_tArray ret_arr = NULL;
22853         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22854         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22855         for (size_t h = 0; h < ret_var.datalen; h++) {
22856                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22857                 *ret_conv_7_copy = ret_var.data[h];
22858                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
22859                 ret_arr_ptr[h] = ret_conv_7_ref;
22860         }
22861         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22862         FREE(ret_var.data);
22863         return ret_arr;
22864 }
22865
22866 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) {
22867         LDKChannelMonitor this_arg_conv;
22868         this_arg_conv.inner = (void*)(this_arg & (~1));
22869         this_arg_conv.is_owned = false;
22870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22871         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22872         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22873         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22874         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22875         jobjectArray ret_arr = NULL;
22876         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
22877         ;
22878         for (size_t i = 0; i < ret_var.datalen; i++) {
22879                 LDKTransaction ret_conv_8_var = ret_var.data[i];
22880                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
22881                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
22882                 Transaction_free(ret_conv_8_var);
22883                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
22884         }
22885         
22886         FREE(ret_var.data);
22887         return ret_arr;
22888 }
22889
22890 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) {
22891         LDKChannelMonitor this_arg_conv;
22892         this_arg_conv.inner = (void*)(this_arg & (~1));
22893         this_arg_conv.is_owned = false;
22894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22895         unsigned char header_arr[80];
22896         CHECK((*env)->GetArrayLength(env, header) == 80);
22897         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22898         unsigned char (*header_ref)[80] = &header_arr;
22899         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22900         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
22901         if (txdata_constr.datalen > 0)
22902                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22903         else
22904                 txdata_constr.data = NULL;
22905         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
22906         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22907                 int64_t txdata_conv_28 = txdata_vals[c];
22908                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
22909                 CHECK_ACCESS(txdata_conv_28_ptr);
22910                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22911                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
22912                 txdata_constr.data[c] = txdata_conv_28_conv;
22913         }
22914         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
22915         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22916         CHECK_ACCESS(broadcaster_ptr);
22917         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22918         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22919                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22920                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22921         }
22922         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22923         CHECK_ACCESS(fee_estimator_ptr);
22924         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22925         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22926                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22927                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22928         }
22929         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22930         CHECK_ACCESS(logger_ptr);
22931         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22932         if (logger_conv.free == LDKLogger_JCalls_free) {
22933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22934                 LDKLogger_JCalls_cloned(&logger_conv);
22935         }
22936         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);
22937         int64_tArray ret_arr = NULL;
22938         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22939         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22940         for (size_t n = 0; n < ret_var.datalen; n++) {
22941                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22942                 *ret_conv_39_conv = ret_var.data[n];
22943                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
22944         }
22945         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22946         FREE(ret_var.data);
22947         return ret_arr;
22948 }
22949
22950 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) {
22951         LDKChannelMonitor this_arg_conv;
22952         this_arg_conv.inner = (void*)(this_arg & (~1));
22953         this_arg_conv.is_owned = false;
22954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22955         unsigned char header_arr[80];
22956         CHECK((*env)->GetArrayLength(env, header) == 80);
22957         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22958         unsigned char (*header_ref)[80] = &header_arr;
22959         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22960         CHECK_ACCESS(broadcaster_ptr);
22961         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22962         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22963                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22964                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22965         }
22966         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22967         CHECK_ACCESS(fee_estimator_ptr);
22968         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22969         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22970                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22971                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22972         }
22973         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22974         CHECK_ACCESS(logger_ptr);
22975         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22976         if (logger_conv.free == LDKLogger_JCalls_free) {
22977                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22978                 LDKLogger_JCalls_cloned(&logger_conv);
22979         }
22980         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22981 }
22982
22983 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) {
22984         LDKChannelMonitor this_arg_conv;
22985         this_arg_conv.inner = (void*)(this_arg & (~1));
22986         this_arg_conv.is_owned = false;
22987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22988         unsigned char header_arr[80];
22989         CHECK((*env)->GetArrayLength(env, header) == 80);
22990         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22991         unsigned char (*header_ref)[80] = &header_arr;
22992         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22993         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
22994         if (txdata_constr.datalen > 0)
22995                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22996         else
22997                 txdata_constr.data = NULL;
22998         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
22999         for (size_t c = 0; c < txdata_constr.datalen; c++) {
23000                 int64_t txdata_conv_28 = txdata_vals[c];
23001                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
23002                 CHECK_ACCESS(txdata_conv_28_ptr);
23003                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
23004                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
23005                 txdata_constr.data[c] = txdata_conv_28_conv;
23006         }
23007         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
23008         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
23009         CHECK_ACCESS(broadcaster_ptr);
23010         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23011         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23012                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23013                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23014         }
23015         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
23016         CHECK_ACCESS(fee_estimator_ptr);
23017         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23018         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23019                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23020                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23021         }
23022         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
23023         CHECK_ACCESS(logger_ptr);
23024         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23025         if (logger_conv.free == LDKLogger_JCalls_free) {
23026                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23027                 LDKLogger_JCalls_cloned(&logger_conv);
23028         }
23029         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);
23030         int64_tArray ret_arr = NULL;
23031         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23032         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23033         for (size_t n = 0; n < ret_var.datalen; n++) {
23034                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23035                 *ret_conv_39_conv = ret_var.data[n];
23036                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
23037         }
23038         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23039         FREE(ret_var.data);
23040         return ret_arr;
23041 }
23042
23043 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) {
23044         LDKChannelMonitor this_arg_conv;
23045         this_arg_conv.inner = (void*)(this_arg & (~1));
23046         this_arg_conv.is_owned = false;
23047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23048         unsigned char txid_arr[32];
23049         CHECK((*env)->GetArrayLength(env, txid) == 32);
23050         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
23051         unsigned char (*txid_ref)[32] = &txid_arr;
23052         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
23053         CHECK_ACCESS(broadcaster_ptr);
23054         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23055         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23056                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23057                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23058         }
23059         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
23060         CHECK_ACCESS(fee_estimator_ptr);
23061         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23062         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23063                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23064                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23065         }
23066         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
23067         CHECK_ACCESS(logger_ptr);
23068         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23069         if (logger_conv.free == LDKLogger_JCalls_free) {
23070                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23071                 LDKLogger_JCalls_cloned(&logger_conv);
23072         }
23073         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
23074 }
23075
23076 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) {
23077         LDKChannelMonitor this_arg_conv;
23078         this_arg_conv.inner = (void*)(this_arg & (~1));
23079         this_arg_conv.is_owned = false;
23080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23081         unsigned char header_arr[80];
23082         CHECK((*env)->GetArrayLength(env, header) == 80);
23083         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
23084         unsigned char (*header_ref)[80] = &header_arr;
23085         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
23086         CHECK_ACCESS(broadcaster_ptr);
23087         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23088         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23089                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23090                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23091         }
23092         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
23093         CHECK_ACCESS(fee_estimator_ptr);
23094         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23095         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23096                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23097                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23098         }
23099         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
23100         CHECK_ACCESS(logger_ptr);
23101         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23102         if (logger_conv.free == LDKLogger_JCalls_free) {
23103                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23104                 LDKLogger_JCalls_cloned(&logger_conv);
23105         }
23106         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
23107         int64_tArray ret_arr = NULL;
23108         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23109         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23110         for (size_t n = 0; n < ret_var.datalen; n++) {
23111                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23112                 *ret_conv_39_conv = ret_var.data[n];
23113                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
23114         }
23115         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23116         FREE(ret_var.data);
23117         return ret_arr;
23118 }
23119
23120 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
23121         LDKChannelMonitor this_arg_conv;
23122         this_arg_conv.inner = (void*)(this_arg & (~1));
23123         this_arg_conv.is_owned = false;
23124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23125         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
23126         jobjectArray ret_arr = NULL;
23127         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
23128         ;
23129         for (size_t i = 0; i < ret_var.datalen; i++) {
23130                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
23131                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
23132                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
23133         }
23134         
23135         FREE(ret_var.data);
23136         return ret_arr;
23137 }
23138
23139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
23140         LDKChannelMonitor this_arg_conv;
23141         this_arg_conv.inner = (void*)(this_arg & (~1));
23142         this_arg_conv.is_owned = false;
23143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23144         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
23145         uint64_t ret_ref = 0;
23146         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23147         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23149         ret_ref = (uint64_t)ret_var.inner;
23150         if (ret_var.is_owned) {
23151                 ret_ref |= 1;
23152         }
23153         return ret_ref;
23154 }
23155
23156 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
23157         LDKChannelMonitor this_arg_conv;
23158         this_arg_conv.inner = (void*)(this_arg & (~1));
23159         this_arg_conv.is_owned = false;
23160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23161         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
23162         int64_tArray ret_arr = NULL;
23163         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23164         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23165         for (size_t j = 0; j < ret_var.datalen; j++) {
23166                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23167                 *ret_conv_9_copy = ret_var.data[j];
23168                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
23169                 ret_arr_ptr[j] = ret_conv_9_ref;
23170         }
23171         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23172         FREE(ret_var.data);
23173         return ret_arr;
23174 }
23175
23176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
23177         LDKu8slice ser_ref;
23178         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23179         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23180         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
23181         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23182         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
23183         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23184         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
23185         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23186         return (uint64_t)ret_conv;
23187 }
23188
23189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23190         LDKOutPoint this_obj_conv;
23191         this_obj_conv.inner = (void*)(this_obj & (~1));
23192         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23194         OutPoint_free(this_obj_conv);
23195 }
23196
23197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
23198         LDKOutPoint this_ptr_conv;
23199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23200         this_ptr_conv.is_owned = false;
23201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23202         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23203         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
23204         return ret_arr;
23205 }
23206
23207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23208         LDKOutPoint this_ptr_conv;
23209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23210         this_ptr_conv.is_owned = false;
23211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23212         LDKThirtyTwoBytes val_ref;
23213         CHECK((*env)->GetArrayLength(env, val) == 32);
23214         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23215         OutPoint_set_txid(&this_ptr_conv, val_ref);
23216 }
23217
23218 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
23219         LDKOutPoint this_ptr_conv;
23220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23221         this_ptr_conv.is_owned = false;
23222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23223         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
23224         return ret_val;
23225 }
23226
23227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23228         LDKOutPoint this_ptr_conv;
23229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23230         this_ptr_conv.is_owned = false;
23231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23232         OutPoint_set_index(&this_ptr_conv, val);
23233 }
23234
23235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
23236         LDKThirtyTwoBytes txid_arg_ref;
23237         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
23238         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
23239         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
23240         uint64_t ret_ref = 0;
23241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23244         ret_ref = (uint64_t)ret_var.inner;
23245         if (ret_var.is_owned) {
23246                 ret_ref |= 1;
23247         }
23248         return ret_ref;
23249 }
23250
23251 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
23252         LDKOutPoint ret_var = OutPoint_clone(arg);
23253 uint64_t ret_ref = 0;
23254 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23255 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23256 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23257 ret_ref = (uint64_t)ret_var.inner;
23258 if (ret_var.is_owned) {
23259         ret_ref |= 1;
23260 }
23261         return ret_ref;
23262 }
23263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23264         LDKOutPoint arg_conv;
23265         arg_conv.inner = (void*)(arg & (~1));
23266         arg_conv.is_owned = false;
23267         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23268         int64_t ret_val = OutPoint_clone_ptr(&arg_conv);
23269         return ret_val;
23270 }
23271
23272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23273         LDKOutPoint orig_conv;
23274         orig_conv.inner = (void*)(orig & (~1));
23275         orig_conv.is_owned = false;
23276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23277         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
23278         uint64_t ret_ref = 0;
23279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23282         ret_ref = (uint64_t)ret_var.inner;
23283         if (ret_var.is_owned) {
23284                 ret_ref |= 1;
23285         }
23286         return ret_ref;
23287 }
23288
23289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23290         LDKOutPoint a_conv;
23291         a_conv.inner = (void*)(a & (~1));
23292         a_conv.is_owned = false;
23293         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23294         LDKOutPoint b_conv;
23295         b_conv.inner = (void*)(b & (~1));
23296         b_conv.is_owned = false;
23297         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
23298         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
23299         return ret_val;
23300 }
23301
23302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
23303         LDKOutPoint o_conv;
23304         o_conv.inner = (void*)(o & (~1));
23305         o_conv.is_owned = false;
23306         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23307         int64_t ret_val = OutPoint_hash(&o_conv);
23308         return ret_val;
23309 }
23310
23311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
23312         LDKOutPoint this_arg_conv;
23313         this_arg_conv.inner = (void*)(this_arg & (~1));
23314         this_arg_conv.is_owned = false;
23315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23316         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23317         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
23318         return ret_arr;
23319 }
23320
23321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
23322         LDKOutPoint obj_conv;
23323         obj_conv.inner = (void*)(obj & (~1));
23324         obj_conv.is_owned = false;
23325         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23326         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
23327         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23328         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23329         CVec_u8Z_free(ret_var);
23330         return ret_arr;
23331 }
23332
23333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23334         LDKu8slice ser_ref;
23335         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23336         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23337         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
23338         *ret_conv = OutPoint_read(ser_ref);
23339         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23340         return (uint64_t)ret_conv;
23341 }
23342
23343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23344         LDKDelayedPaymentOutputDescriptor this_obj_conv;
23345         this_obj_conv.inner = (void*)(this_obj & (~1));
23346         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23348         DelayedPaymentOutputDescriptor_free(this_obj_conv);
23349 }
23350
23351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
23352         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23354         this_ptr_conv.is_owned = false;
23355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23356         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23357         uint64_t ret_ref = 0;
23358         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23359         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23361         ret_ref = (uint64_t)ret_var.inner;
23362         if (ret_var.is_owned) {
23363                 ret_ref |= 1;
23364         }
23365         return ret_ref;
23366 }
23367
23368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23369         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23371         this_ptr_conv.is_owned = false;
23372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23373         LDKOutPoint val_conv;
23374         val_conv.inner = (void*)(val & (~1));
23375         val_conv.is_owned = (val & 1) || (val == 0);
23376         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23377         val_conv = OutPoint_clone(&val_conv);
23378         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23379 }
23380
23381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
23382         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23384         this_ptr_conv.is_owned = false;
23385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23386         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23387         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
23388         return ret_arr;
23389 }
23390
23391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23392         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23394         this_ptr_conv.is_owned = false;
23395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23396         LDKPublicKey val_ref;
23397         CHECK((*env)->GetArrayLength(env, val) == 33);
23398         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23399         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
23400 }
23401
23402 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
23403         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23405         this_ptr_conv.is_owned = false;
23406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23407         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
23408         return ret_val;
23409 }
23410
23411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23412         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23414         this_ptr_conv.is_owned = false;
23415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23416         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
23417 }
23418
23419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23420         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23422         this_ptr_conv.is_owned = false;
23423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23424         void* val_ptr = (void*)(((uint64_t)val) & ~1);
23425         CHECK_ACCESS(val_ptr);
23426         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23427         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
23428         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23429 }
23430
23431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
23432         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23434         this_ptr_conv.is_owned = false;
23435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23436         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
23438         return ret_arr;
23439 }
23440
23441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23442         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23444         this_ptr_conv.is_owned = false;
23445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23446         LDKPublicKey val_ref;
23447         CHECK((*env)->GetArrayLength(env, val) == 33);
23448         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23449         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
23450 }
23451
23452 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23453         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23455         this_ptr_conv.is_owned = false;
23456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23457         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23458         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
23459         return ret_arr;
23460 }
23461
23462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23463         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23465         this_ptr_conv.is_owned = false;
23466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23467         LDKThirtyTwoBytes val_ref;
23468         CHECK((*env)->GetArrayLength(env, val) == 32);
23469         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23470         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23471 }
23472
23473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
23474         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23476         this_ptr_conv.is_owned = false;
23477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23478         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23479         return ret_val;
23480 }
23481
23482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23483         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23485         this_ptr_conv.is_owned = false;
23486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23487         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23488 }
23489
23490 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) {
23491         LDKOutPoint outpoint_arg_conv;
23492         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23493         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23494         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23495         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23496         LDKPublicKey per_commitment_point_arg_ref;
23497         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
23498         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
23499         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
23500         CHECK_ACCESS(output_arg_ptr);
23501         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23502         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
23503         LDKPublicKey revocation_pubkey_arg_ref;
23504         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
23505         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
23506         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23507         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
23508         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
23509         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);
23510         uint64_t ret_ref = 0;
23511         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23512         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23514         ret_ref = (uint64_t)ret_var.inner;
23515         if (ret_var.is_owned) {
23516                 ret_ref |= 1;
23517         }
23518         return ret_ref;
23519 }
23520
23521 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
23522         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
23523 uint64_t ret_ref = 0;
23524 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23525 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23526 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23527 ret_ref = (uint64_t)ret_var.inner;
23528 if (ret_var.is_owned) {
23529         ret_ref |= 1;
23530 }
23531         return ret_ref;
23532 }
23533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23534         LDKDelayedPaymentOutputDescriptor arg_conv;
23535         arg_conv.inner = (void*)(arg & (~1));
23536         arg_conv.is_owned = false;
23537         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23538         int64_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
23539         return ret_val;
23540 }
23541
23542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23543         LDKDelayedPaymentOutputDescriptor orig_conv;
23544         orig_conv.inner = (void*)(orig & (~1));
23545         orig_conv.is_owned = false;
23546         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23547         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
23548         uint64_t ret_ref = 0;
23549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23552         ret_ref = (uint64_t)ret_var.inner;
23553         if (ret_var.is_owned) {
23554                 ret_ref |= 1;
23555         }
23556         return ret_ref;
23557 }
23558
23559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
23560         LDKDelayedPaymentOutputDescriptor obj_conv;
23561         obj_conv.inner = (void*)(obj & (~1));
23562         obj_conv.is_owned = false;
23563         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23564         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
23565         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23566         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23567         CVec_u8Z_free(ret_var);
23568         return ret_arr;
23569 }
23570
23571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23572         LDKu8slice ser_ref;
23573         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23574         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23575         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
23576         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
23577         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23578         return (uint64_t)ret_conv;
23579 }
23580
23581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23582         LDKStaticPaymentOutputDescriptor this_obj_conv;
23583         this_obj_conv.inner = (void*)(this_obj & (~1));
23584         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23586         StaticPaymentOutputDescriptor_free(this_obj_conv);
23587 }
23588
23589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
23590         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23592         this_ptr_conv.is_owned = false;
23593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23594         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23595         uint64_t ret_ref = 0;
23596         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23597         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23599         ret_ref = (uint64_t)ret_var.inner;
23600         if (ret_var.is_owned) {
23601                 ret_ref |= 1;
23602         }
23603         return ret_ref;
23604 }
23605
23606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23607         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23609         this_ptr_conv.is_owned = false;
23610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23611         LDKOutPoint val_conv;
23612         val_conv.inner = (void*)(val & (~1));
23613         val_conv.is_owned = (val & 1) || (val == 0);
23614         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23615         val_conv = OutPoint_clone(&val_conv);
23616         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23617 }
23618
23619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23620         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23622         this_ptr_conv.is_owned = false;
23623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23624         void* val_ptr = (void*)(((uint64_t)val) & ~1);
23625         CHECK_ACCESS(val_ptr);
23626         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23627         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
23628         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23629 }
23630
23631 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23632         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23634         this_ptr_conv.is_owned = false;
23635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23636         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23637         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
23638         return ret_arr;
23639 }
23640
23641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23642         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23644         this_ptr_conv.is_owned = false;
23645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23646         LDKThirtyTwoBytes val_ref;
23647         CHECK((*env)->GetArrayLength(env, val) == 32);
23648         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23649         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23650 }
23651
23652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
23653         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23655         this_ptr_conv.is_owned = false;
23656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23657         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23658         return ret_val;
23659 }
23660
23661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23662         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23664         this_ptr_conv.is_owned = false;
23665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23666         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23667 }
23668
23669 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) {
23670         LDKOutPoint outpoint_arg_conv;
23671         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23672         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23673         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23674         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23675         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
23676         CHECK_ACCESS(output_arg_ptr);
23677         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23678         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
23679         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23680         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
23681         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
23682         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
23683         uint64_t ret_ref = 0;
23684         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23685         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23687         ret_ref = (uint64_t)ret_var.inner;
23688         if (ret_var.is_owned) {
23689                 ret_ref |= 1;
23690         }
23691         return ret_ref;
23692 }
23693
23694 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
23695         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
23696 uint64_t ret_ref = 0;
23697 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23698 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23699 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23700 ret_ref = (uint64_t)ret_var.inner;
23701 if (ret_var.is_owned) {
23702         ret_ref |= 1;
23703 }
23704         return ret_ref;
23705 }
23706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23707         LDKStaticPaymentOutputDescriptor arg_conv;
23708         arg_conv.inner = (void*)(arg & (~1));
23709         arg_conv.is_owned = false;
23710         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23711         int64_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
23712         return ret_val;
23713 }
23714
23715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23716         LDKStaticPaymentOutputDescriptor orig_conv;
23717         orig_conv.inner = (void*)(orig & (~1));
23718         orig_conv.is_owned = false;
23719         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23720         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
23721         uint64_t ret_ref = 0;
23722         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23723         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23725         ret_ref = (uint64_t)ret_var.inner;
23726         if (ret_var.is_owned) {
23727                 ret_ref |= 1;
23728         }
23729         return ret_ref;
23730 }
23731
23732 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
23733         LDKStaticPaymentOutputDescriptor obj_conv;
23734         obj_conv.inner = (void*)(obj & (~1));
23735         obj_conv.is_owned = false;
23736         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23737         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
23738         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23739         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23740         CVec_u8Z_free(ret_var);
23741         return ret_arr;
23742 }
23743
23744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23745         LDKu8slice ser_ref;
23746         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23747         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23748         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
23749         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
23750         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23751         return (uint64_t)ret_conv;
23752 }
23753
23754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23755         if ((this_ptr & 1) != 0) return;
23756         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23757         CHECK_ACCESS(this_ptr_ptr);
23758         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
23759         FREE((void*)this_ptr);
23760         SpendableOutputDescriptor_free(this_ptr_conv);
23761 }
23762
23763 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
23764         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23765         *ret_copy = SpendableOutputDescriptor_clone(arg);
23766 uint64_t ret_ref = (uint64_t)ret_copy;
23767         return ret_ref;
23768 }
23769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23770         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
23771         int64_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
23772         return ret_val;
23773 }
23774
23775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23776         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
23777         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23778         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
23779         uint64_t ret_ref = (uint64_t)ret_copy;
23780         return ret_ref;
23781 }
23782
23783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
23784         LDKOutPoint outpoint_conv;
23785         outpoint_conv.inner = (void*)(outpoint & (~1));
23786         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
23787         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
23788         outpoint_conv = OutPoint_clone(&outpoint_conv);
23789         void* output_ptr = (void*)(((uint64_t)output) & ~1);
23790         CHECK_ACCESS(output_ptr);
23791         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
23792         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
23793         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23794         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
23795         uint64_t ret_ref = (uint64_t)ret_copy;
23796         return ret_ref;
23797 }
23798
23799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
23800         LDKDelayedPaymentOutputDescriptor a_conv;
23801         a_conv.inner = (void*)(a & (~1));
23802         a_conv.is_owned = (a & 1) || (a == 0);
23803         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23804         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
23805         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23806         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
23807         uint64_t ret_ref = (uint64_t)ret_copy;
23808         return ret_ref;
23809 }
23810
23811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
23812         LDKStaticPaymentOutputDescriptor a_conv;
23813         a_conv.inner = (void*)(a & (~1));
23814         a_conv.is_owned = (a & 1) || (a == 0);
23815         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23816         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
23817         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23818         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
23819         uint64_t ret_ref = (uint64_t)ret_copy;
23820         return ret_ref;
23821 }
23822
23823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
23824         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
23825         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
23826         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23827         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23828         CVec_u8Z_free(ret_var);
23829         return ret_arr;
23830 }
23831
23832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23833         LDKu8slice ser_ref;
23834         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23835         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23836         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23837         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23838         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23839         return (uint64_t)ret_conv;
23840 }
23841
23842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23843         if ((this_ptr & 1) != 0) return;
23844         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23845         CHECK_ACCESS(this_ptr_ptr);
23846         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23847         FREE((void*)this_ptr);
23848         BaseSign_free(this_ptr_conv);
23849 }
23850
23851 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23852         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23853         *ret_ret = Sign_clone(arg);
23854         return (uint64_t)ret_ret;
23855 }
23856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23857         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
23858         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23859         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23860         int64_t ret_val = Sign_clone_ptr(arg_conv);
23861         return ret_val;
23862 }
23863
23864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23865         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
23866         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23867         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23868         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23869         *ret_ret = Sign_clone(orig_conv);
23870         return (uint64_t)ret_ret;
23871 }
23872
23873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23874         if ((this_ptr & 1) != 0) return;
23875         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23876         CHECK_ACCESS(this_ptr_ptr);
23877         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23878         FREE((void*)this_ptr);
23879         Sign_free(this_ptr_conv);
23880 }
23881
23882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23883         if ((this_ptr & 1) != 0) return;
23884         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23885         CHECK_ACCESS(this_ptr_ptr);
23886         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23887         FREE((void*)this_ptr);
23888         KeysInterface_free(this_ptr_conv);
23889 }
23890
23891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23892         LDKInMemorySigner this_obj_conv;
23893         this_obj_conv.inner = (void*)(this_obj & (~1));
23894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23896         InMemorySigner_free(this_obj_conv);
23897 }
23898
23899 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23900         LDKInMemorySigner this_ptr_conv;
23901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23902         this_ptr_conv.is_owned = false;
23903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23904         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23905         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
23906         return ret_arr;
23907 }
23908
23909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23910         LDKInMemorySigner this_ptr_conv;
23911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23912         this_ptr_conv.is_owned = false;
23913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23914         LDKSecretKey val_ref;
23915         CHECK((*env)->GetArrayLength(env, val) == 32);
23916         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23917         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23918 }
23919
23920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23921         LDKInMemorySigner this_ptr_conv;
23922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23923         this_ptr_conv.is_owned = false;
23924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23925         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23926         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
23927         return ret_arr;
23928 }
23929
23930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23931         LDKInMemorySigner this_ptr_conv;
23932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23933         this_ptr_conv.is_owned = false;
23934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23935         LDKSecretKey val_ref;
23936         CHECK((*env)->GetArrayLength(env, val) == 32);
23937         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23938         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23939 }
23940
23941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23942         LDKInMemorySigner this_ptr_conv;
23943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23944         this_ptr_conv.is_owned = false;
23945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23946         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
23948         return ret_arr;
23949 }
23950
23951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23952         LDKInMemorySigner this_ptr_conv;
23953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23954         this_ptr_conv.is_owned = false;
23955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23956         LDKSecretKey val_ref;
23957         CHECK((*env)->GetArrayLength(env, val) == 32);
23958         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23959         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23960 }
23961
23962 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23963         LDKInMemorySigner this_ptr_conv;
23964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23965         this_ptr_conv.is_owned = false;
23966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23967         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23968         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
23969         return ret_arr;
23970 }
23971
23972 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) {
23973         LDKInMemorySigner this_ptr_conv;
23974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23975         this_ptr_conv.is_owned = false;
23976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23977         LDKSecretKey val_ref;
23978         CHECK((*env)->GetArrayLength(env, val) == 32);
23979         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23980         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
23981 }
23982
23983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23984         LDKInMemorySigner this_ptr_conv;
23985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23986         this_ptr_conv.is_owned = false;
23987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23988         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23989         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
23990         return ret_arr;
23991 }
23992
23993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23994         LDKInMemorySigner this_ptr_conv;
23995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23996         this_ptr_conv.is_owned = false;
23997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23998         LDKSecretKey val_ref;
23999         CHECK((*env)->GetArrayLength(env, val) == 32);
24000         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
24001         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
24002 }
24003
24004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
24005         LDKInMemorySigner this_ptr_conv;
24006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24007         this_ptr_conv.is_owned = false;
24008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24009         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24010         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
24011         return ret_arr;
24012 }
24013
24014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24015         LDKInMemorySigner this_ptr_conv;
24016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24017         this_ptr_conv.is_owned = false;
24018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24019         LDKThirtyTwoBytes val_ref;
24020         CHECK((*env)->GetArrayLength(env, val) == 32);
24021         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24022         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
24023 }
24024
24025 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
24026         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
24027 uint64_t ret_ref = 0;
24028 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24029 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24030 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24031 ret_ref = (uint64_t)ret_var.inner;
24032 if (ret_var.is_owned) {
24033         ret_ref |= 1;
24034 }
24035         return ret_ref;
24036 }
24037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24038         LDKInMemorySigner arg_conv;
24039         arg_conv.inner = (void*)(arg & (~1));
24040         arg_conv.is_owned = false;
24041         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24042         int64_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
24043         return ret_val;
24044 }
24045
24046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24047         LDKInMemorySigner orig_conv;
24048         orig_conv.inner = (void*)(orig & (~1));
24049         orig_conv.is_owned = false;
24050         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24051         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
24052         uint64_t ret_ref = 0;
24053         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24054         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24056         ret_ref = (uint64_t)ret_var.inner;
24057         if (ret_var.is_owned) {
24058                 ret_ref |= 1;
24059         }
24060         return ret_ref;
24061 }
24062
24063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv *env, jclass clz, 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) {
24064         LDKSecretKey funding_key_ref;
24065         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
24066         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
24067         LDKSecretKey revocation_base_key_ref;
24068         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
24069         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
24070         LDKSecretKey payment_key_ref;
24071         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
24072         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
24073         LDKSecretKey delayed_payment_base_key_ref;
24074         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
24075         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
24076         LDKSecretKey htlc_base_key_ref;
24077         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
24078         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
24079         LDKThirtyTwoBytes commitment_seed_ref;
24080         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
24081         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
24082         LDKThirtyTwoBytes channel_keys_id_ref;
24083         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
24084         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
24085         LDKInMemorySigner ret_var = InMemorySigner_new(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);
24086         uint64_t ret_ref = 0;
24087         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24088         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24090         ret_ref = (uint64_t)ret_var.inner;
24091         if (ret_var.is_owned) {
24092                 ret_ref |= 1;
24093         }
24094         return ret_ref;
24095 }
24096
24097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
24098         LDKInMemorySigner this_arg_conv;
24099         this_arg_conv.inner = (void*)(this_arg & (~1));
24100         this_arg_conv.is_owned = false;
24101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24102         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
24103         uint64_t ret_ref = 0;
24104         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24105         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
24108         if (ret_var.is_owned) {
24109                 ret_ref |= 1;
24110         }
24111         return ret_ref;
24112 }
24113
24114 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
24115         LDKInMemorySigner this_arg_conv;
24116         this_arg_conv.inner = (void*)(this_arg & (~1));
24117         this_arg_conv.is_owned = false;
24118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24119         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
24120         return ret_val;
24121 }
24122
24123 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
24124         LDKInMemorySigner this_arg_conv;
24125         this_arg_conv.inner = (void*)(this_arg & (~1));
24126         this_arg_conv.is_owned = false;
24127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24128         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
24129         return ret_val;
24130 }
24131
24132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
24133         LDKInMemorySigner this_arg_conv;
24134         this_arg_conv.inner = (void*)(this_arg & (~1));
24135         this_arg_conv.is_owned = false;
24136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24137         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
24138         return ret_val;
24139 }
24140
24141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
24142         LDKInMemorySigner this_arg_conv;
24143         this_arg_conv.inner = (void*)(this_arg & (~1));
24144         this_arg_conv.is_owned = false;
24145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24146         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
24147         uint64_t ret_ref = 0;
24148         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24149         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24151         ret_ref = (uint64_t)ret_var.inner;
24152         if (ret_var.is_owned) {
24153                 ret_ref |= 1;
24154         }
24155         return ret_ref;
24156 }
24157
24158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
24159         LDKInMemorySigner this_arg_conv;
24160         this_arg_conv.inner = (void*)(this_arg & (~1));
24161         this_arg_conv.is_owned = false;
24162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24163         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
24164         uint64_t ret_ref = 0;
24165         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24166         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24168         ret_ref = (uint64_t)ret_var.inner;
24169         if (ret_var.is_owned) {
24170                 ret_ref |= 1;
24171         }
24172         return ret_ref;
24173 }
24174
24175 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
24176         LDKInMemorySigner this_arg_conv;
24177         this_arg_conv.inner = (void*)(this_arg & (~1));
24178         this_arg_conv.is_owned = false;
24179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24180         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
24181         return ret_val;
24182 }
24183
24184 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) {
24185         LDKInMemorySigner this_arg_conv;
24186         this_arg_conv.inner = (void*)(this_arg & (~1));
24187         this_arg_conv.is_owned = false;
24188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24189         LDKTransaction spend_tx_ref;
24190         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
24191         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
24192         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
24193         spend_tx_ref.data_is_owned = true;
24194         LDKStaticPaymentOutputDescriptor descriptor_conv;
24195         descriptor_conv.inner = (void*)(descriptor & (~1));
24196         descriptor_conv.is_owned = false;
24197         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
24198         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
24199         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
24200         return (uint64_t)ret_conv;
24201 }
24202
24203 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) {
24204         LDKInMemorySigner this_arg_conv;
24205         this_arg_conv.inner = (void*)(this_arg & (~1));
24206         this_arg_conv.is_owned = false;
24207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24208         LDKTransaction spend_tx_ref;
24209         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
24210         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
24211         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
24212         spend_tx_ref.data_is_owned = true;
24213         LDKDelayedPaymentOutputDescriptor descriptor_conv;
24214         descriptor_conv.inner = (void*)(descriptor & (~1));
24215         descriptor_conv.is_owned = false;
24216         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
24217         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
24218         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
24219         return (uint64_t)ret_conv;
24220 }
24221
24222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
24223         LDKInMemorySigner this_arg_conv;
24224         this_arg_conv.inner = (void*)(this_arg & (~1));
24225         this_arg_conv.is_owned = false;
24226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24227         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
24228         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
24229         return (uint64_t)ret_ret;
24230 }
24231
24232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
24233         LDKInMemorySigner this_arg_conv;
24234         this_arg_conv.inner = (void*)(this_arg & (~1));
24235         this_arg_conv.is_owned = false;
24236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24237         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24238         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
24239         return (uint64_t)ret_ret;
24240 }
24241
24242 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
24243         LDKInMemorySigner obj_conv;
24244         obj_conv.inner = (void*)(obj & (~1));
24245         obj_conv.is_owned = false;
24246         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24247         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
24248         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24249         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24250         CVec_u8Z_free(ret_var);
24251         return ret_arr;
24252 }
24253
24254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24255         LDKu8slice ser_ref;
24256         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24257         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24258         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
24259         *ret_conv = InMemorySigner_read(ser_ref);
24260         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24261         return (uint64_t)ret_conv;
24262 }
24263
24264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24265         LDKKeysManager this_obj_conv;
24266         this_obj_conv.inner = (void*)(this_obj & (~1));
24267         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24269         KeysManager_free(this_obj_conv);
24270 }
24271
24272 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) {
24273         unsigned char seed_arr[32];
24274         CHECK((*env)->GetArrayLength(env, seed) == 32);
24275         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
24276         unsigned char (*seed_ref)[32] = &seed_arr;
24277         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
24278         uint64_t ret_ref = 0;
24279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24282         ret_ref = (uint64_t)ret_var.inner;
24283         if (ret_var.is_owned) {
24284                 ret_ref |= 1;
24285         }
24286         return ret_ref;
24287 }
24288
24289 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) {
24290         LDKKeysManager this_arg_conv;
24291         this_arg_conv.inner = (void*)(this_arg & (~1));
24292         this_arg_conv.is_owned = false;
24293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24294         unsigned char params_arr[32];
24295         CHECK((*env)->GetArrayLength(env, params) == 32);
24296         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
24297         unsigned char (*params_ref)[32] = &params_arr;
24298         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
24299         uint64_t ret_ref = 0;
24300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24303         ret_ref = (uint64_t)ret_var.inner;
24304         if (ret_var.is_owned) {
24305                 ret_ref |= 1;
24306         }
24307         return ret_ref;
24308 }
24309
24310 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) {
24311         LDKKeysManager this_arg_conv;
24312         this_arg_conv.inner = (void*)(this_arg & (~1));
24313         this_arg_conv.is_owned = false;
24314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24315         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
24316         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
24317         if (descriptors_constr.datalen > 0)
24318                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24319         else
24320                 descriptors_constr.data = NULL;
24321         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
24322         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
24323                 int64_t descriptors_conv_27 = descriptors_vals[b];
24324                 void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
24325                 CHECK_ACCESS(descriptors_conv_27_ptr);
24326                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
24327                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
24328                 descriptors_constr.data[b] = descriptors_conv_27_conv;
24329         }
24330         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
24331         LDKCVec_TxOutZ outputs_constr;
24332         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
24333         if (outputs_constr.datalen > 0)
24334                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
24335         else
24336                 outputs_constr.data = NULL;
24337         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
24338         for (size_t h = 0; h < outputs_constr.datalen; h++) {
24339                 int64_t outputs_conv_7 = outputs_vals[h];
24340                 void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
24341                 CHECK_ACCESS(outputs_conv_7_ptr);
24342                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
24343                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
24344                 outputs_constr.data[h] = outputs_conv_7_conv;
24345         }
24346         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
24347         LDKCVec_u8Z change_destination_script_ref;
24348         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
24349         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
24350         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
24351         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
24352         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
24353         return (uint64_t)ret_conv;
24354 }
24355
24356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
24357         LDKKeysManager this_arg_conv;
24358         this_arg_conv.inner = (void*)(this_arg & (~1));
24359         this_arg_conv.is_owned = false;
24360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24361         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
24362         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
24363         return (uint64_t)ret_ret;
24364 }
24365
24366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24367         LDKChannelManager this_obj_conv;
24368         this_obj_conv.inner = (void*)(this_obj & (~1));
24369         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24371         ChannelManager_free(this_obj_conv);
24372 }
24373
24374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24375         LDKChainParameters this_obj_conv;
24376         this_obj_conv.inner = (void*)(this_obj & (~1));
24377         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24379         ChainParameters_free(this_obj_conv);
24380 }
24381
24382 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
24383         LDKChainParameters this_ptr_conv;
24384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24385         this_ptr_conv.is_owned = false;
24386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24387         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
24388         return ret_conv;
24389 }
24390
24391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
24392         LDKChainParameters this_ptr_conv;
24393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24394         this_ptr_conv.is_owned = false;
24395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24396         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
24397         ChainParameters_set_network(&this_ptr_conv, val_conv);
24398 }
24399
24400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
24401         LDKChainParameters this_ptr_conv;
24402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24403         this_ptr_conv.is_owned = false;
24404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24405         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
24406         uint64_t ret_ref = 0;
24407         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24408         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24410         ret_ref = (uint64_t)ret_var.inner;
24411         if (ret_var.is_owned) {
24412                 ret_ref |= 1;
24413         }
24414         return ret_ref;
24415 }
24416
24417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24418         LDKChainParameters this_ptr_conv;
24419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24420         this_ptr_conv.is_owned = false;
24421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24422         LDKBestBlock val_conv;
24423         val_conv.inner = (void*)(val & (~1));
24424         val_conv.is_owned = (val & 1) || (val == 0);
24425         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24426         val_conv = BestBlock_clone(&val_conv);
24427         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
24428 }
24429
24430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
24431         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
24432         LDKBestBlock best_block_arg_conv;
24433         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
24434         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
24435         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
24436         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
24437         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
24438         uint64_t ret_ref = 0;
24439         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24440         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24442         ret_ref = (uint64_t)ret_var.inner;
24443         if (ret_var.is_owned) {
24444                 ret_ref |= 1;
24445         }
24446         return ret_ref;
24447 }
24448
24449 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
24450         LDKChainParameters ret_var = ChainParameters_clone(arg);
24451 uint64_t ret_ref = 0;
24452 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24453 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24454 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24455 ret_ref = (uint64_t)ret_var.inner;
24456 if (ret_var.is_owned) {
24457         ret_ref |= 1;
24458 }
24459         return ret_ref;
24460 }
24461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24462         LDKChainParameters arg_conv;
24463         arg_conv.inner = (void*)(arg & (~1));
24464         arg_conv.is_owned = false;
24465         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24466         int64_t ret_val = ChainParameters_clone_ptr(&arg_conv);
24467         return ret_val;
24468 }
24469
24470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24471         LDKChainParameters orig_conv;
24472         orig_conv.inner = (void*)(orig & (~1));
24473         orig_conv.is_owned = false;
24474         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24475         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
24476         uint64_t ret_ref = 0;
24477         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24478         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24480         ret_ref = (uint64_t)ret_var.inner;
24481         if (ret_var.is_owned) {
24482                 ret_ref |= 1;
24483         }
24484         return ret_ref;
24485 }
24486
24487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24488         LDKCounterpartyForwardingInfo this_obj_conv;
24489         this_obj_conv.inner = (void*)(this_obj & (~1));
24490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24492         CounterpartyForwardingInfo_free(this_obj_conv);
24493 }
24494
24495 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24496         LDKCounterpartyForwardingInfo this_ptr_conv;
24497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24498         this_ptr_conv.is_owned = false;
24499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24500         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
24501         return ret_val;
24502 }
24503
24504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24505         LDKCounterpartyForwardingInfo this_ptr_conv;
24506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24507         this_ptr_conv.is_owned = false;
24508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24509         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
24510 }
24511
24512 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24513         LDKCounterpartyForwardingInfo this_ptr_conv;
24514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24515         this_ptr_conv.is_owned = false;
24516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24517         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
24518         return ret_val;
24519 }
24520
24521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24522         LDKCounterpartyForwardingInfo this_ptr_conv;
24523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24524         this_ptr_conv.is_owned = false;
24525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24526         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
24527 }
24528
24529 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24530         LDKCounterpartyForwardingInfo this_ptr_conv;
24531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24532         this_ptr_conv.is_owned = false;
24533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24534         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
24535         return ret_val;
24536 }
24537
24538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24539         LDKCounterpartyForwardingInfo this_ptr_conv;
24540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24541         this_ptr_conv.is_owned = false;
24542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24543         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24544 }
24545
24546 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) {
24547         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
24548         uint64_t ret_ref = 0;
24549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24552         ret_ref = (uint64_t)ret_var.inner;
24553         if (ret_var.is_owned) {
24554                 ret_ref |= 1;
24555         }
24556         return ret_ref;
24557 }
24558
24559 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
24560         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
24561 uint64_t ret_ref = 0;
24562 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24563 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24564 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24565 ret_ref = (uint64_t)ret_var.inner;
24566 if (ret_var.is_owned) {
24567         ret_ref |= 1;
24568 }
24569         return ret_ref;
24570 }
24571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24572         LDKCounterpartyForwardingInfo arg_conv;
24573         arg_conv.inner = (void*)(arg & (~1));
24574         arg_conv.is_owned = false;
24575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24576         int64_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
24577         return ret_val;
24578 }
24579
24580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24581         LDKCounterpartyForwardingInfo orig_conv;
24582         orig_conv.inner = (void*)(orig & (~1));
24583         orig_conv.is_owned = false;
24584         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24585         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
24586         uint64_t ret_ref = 0;
24587         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24588         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24590         ret_ref = (uint64_t)ret_var.inner;
24591         if (ret_var.is_owned) {
24592                 ret_ref |= 1;
24593         }
24594         return ret_ref;
24595 }
24596
24597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24598         LDKChannelCounterparty this_obj_conv;
24599         this_obj_conv.inner = (void*)(this_obj & (~1));
24600         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24602         ChannelCounterparty_free(this_obj_conv);
24603 }
24604
24605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24606         LDKChannelCounterparty this_ptr_conv;
24607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24608         this_ptr_conv.is_owned = false;
24609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24610         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
24612         return ret_arr;
24613 }
24614
24615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24616         LDKChannelCounterparty this_ptr_conv;
24617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24618         this_ptr_conv.is_owned = false;
24619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24620         LDKPublicKey val_ref;
24621         CHECK((*env)->GetArrayLength(env, val) == 33);
24622         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24623         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
24624 }
24625
24626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24627         LDKChannelCounterparty this_ptr_conv;
24628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24629         this_ptr_conv.is_owned = false;
24630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24631         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
24632         uint64_t ret_ref = 0;
24633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24636         ret_ref = (uint64_t)ret_var.inner;
24637         if (ret_var.is_owned) {
24638                 ret_ref |= 1;
24639         }
24640         return ret_ref;
24641 }
24642
24643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24644         LDKChannelCounterparty this_ptr_conv;
24645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24646         this_ptr_conv.is_owned = false;
24647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24648         LDKInitFeatures val_conv;
24649         val_conv.inner = (void*)(val & (~1));
24650         val_conv.is_owned = (val & 1) || (val == 0);
24651         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24652         val_conv = InitFeatures_clone(&val_conv);
24653         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
24654 }
24655
24656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
24657         LDKChannelCounterparty this_ptr_conv;
24658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24659         this_ptr_conv.is_owned = false;
24660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24661         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
24662         return ret_val;
24663 }
24664
24665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24666         LDKChannelCounterparty this_ptr_conv;
24667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24668         this_ptr_conv.is_owned = false;
24669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24670         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
24671 }
24672
24673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
24674         LDKChannelCounterparty this_ptr_conv;
24675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24676         this_ptr_conv.is_owned = false;
24677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24678         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
24679         uint64_t ret_ref = 0;
24680         if ((uint64_t)ret_var.inner > 4096) {
24681                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24682                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24684                 ret_ref = (uint64_t)ret_var.inner;
24685                 if (ret_var.is_owned) {
24686                         ret_ref |= 1;
24687                 }
24688         }
24689         return ret_ref;
24690 }
24691
24692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24693         LDKChannelCounterparty this_ptr_conv;
24694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24695         this_ptr_conv.is_owned = false;
24696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24697         LDKCounterpartyForwardingInfo val_conv;
24698         val_conv.inner = (void*)(val & (~1));
24699         val_conv.is_owned = (val & 1) || (val == 0);
24700         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24701         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
24702         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
24703 }
24704
24705 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) {
24706         LDKPublicKey node_id_arg_ref;
24707         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
24708         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
24709         LDKInitFeatures features_arg_conv;
24710         features_arg_conv.inner = (void*)(features_arg & (~1));
24711         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24712         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
24713         features_arg_conv = InitFeatures_clone(&features_arg_conv);
24714         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
24715         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
24716         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
24717         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
24718         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
24719         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
24720         uint64_t ret_ref = 0;
24721         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24722         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24724         ret_ref = (uint64_t)ret_var.inner;
24725         if (ret_var.is_owned) {
24726                 ret_ref |= 1;
24727         }
24728         return ret_ref;
24729 }
24730
24731 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
24732         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
24733 uint64_t ret_ref = 0;
24734 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24735 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24736 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24737 ret_ref = (uint64_t)ret_var.inner;
24738 if (ret_var.is_owned) {
24739         ret_ref |= 1;
24740 }
24741         return ret_ref;
24742 }
24743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24744         LDKChannelCounterparty arg_conv;
24745         arg_conv.inner = (void*)(arg & (~1));
24746         arg_conv.is_owned = false;
24747         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24748         int64_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
24749         return ret_val;
24750 }
24751
24752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24753         LDKChannelCounterparty orig_conv;
24754         orig_conv.inner = (void*)(orig & (~1));
24755         orig_conv.is_owned = false;
24756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24757         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24758         uint64_t ret_ref = 0;
24759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24762         ret_ref = (uint64_t)ret_var.inner;
24763         if (ret_var.is_owned) {
24764                 ret_ref |= 1;
24765         }
24766         return ret_ref;
24767 }
24768
24769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24770         LDKChannelDetails this_obj_conv;
24771         this_obj_conv.inner = (void*)(this_obj & (~1));
24772         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24774         ChannelDetails_free(this_obj_conv);
24775 }
24776
24777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24778         LDKChannelDetails this_ptr_conv;
24779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24780         this_ptr_conv.is_owned = false;
24781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24782         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24783         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
24784         return ret_arr;
24785 }
24786
24787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24788         LDKChannelDetails this_ptr_conv;
24789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24790         this_ptr_conv.is_owned = false;
24791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24792         LDKThirtyTwoBytes val_ref;
24793         CHECK((*env)->GetArrayLength(env, val) == 32);
24794         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24795         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24796 }
24797
24798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
24799         LDKChannelDetails this_ptr_conv;
24800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24801         this_ptr_conv.is_owned = false;
24802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24803         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24804         uint64_t ret_ref = 0;
24805         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24806         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24808         ret_ref = (uint64_t)ret_var.inner;
24809         if (ret_var.is_owned) {
24810                 ret_ref |= 1;
24811         }
24812         return ret_ref;
24813 }
24814
24815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24816         LDKChannelDetails this_ptr_conv;
24817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24818         this_ptr_conv.is_owned = false;
24819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24820         LDKChannelCounterparty val_conv;
24821         val_conv.inner = (void*)(val & (~1));
24822         val_conv.is_owned = (val & 1) || (val == 0);
24823         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24824         val_conv = ChannelCounterparty_clone(&val_conv);
24825         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24826 }
24827
24828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
24829         LDKChannelDetails this_ptr_conv;
24830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24831         this_ptr_conv.is_owned = false;
24832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24833         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24834         uint64_t ret_ref = 0;
24835         if ((uint64_t)ret_var.inner > 4096) {
24836                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24837                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24839                 ret_ref = (uint64_t)ret_var.inner;
24840                 if (ret_var.is_owned) {
24841                         ret_ref |= 1;
24842                 }
24843         }
24844         return ret_ref;
24845 }
24846
24847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24848         LDKChannelDetails this_ptr_conv;
24849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24850         this_ptr_conv.is_owned = false;
24851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24852         LDKOutPoint val_conv;
24853         val_conv.inner = (void*)(val & (~1));
24854         val_conv.is_owned = (val & 1) || (val == 0);
24855         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24856         val_conv = OutPoint_clone(&val_conv);
24857         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24858 }
24859
24860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24861         LDKChannelDetails this_ptr_conv;
24862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24863         this_ptr_conv.is_owned = false;
24864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24865         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24866         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24867         uint64_t ret_ref = (uint64_t)ret_copy;
24868         return ret_ref;
24869 }
24870
24871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24872         LDKChannelDetails this_ptr_conv;
24873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24874         this_ptr_conv.is_owned = false;
24875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24876         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24877         CHECK_ACCESS(val_ptr);
24878         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24879         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24880         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24881 }
24882
24883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24884         LDKChannelDetails this_ptr_conv;
24885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24886         this_ptr_conv.is_owned = false;
24887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24888         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24889         return ret_val;
24890 }
24891
24892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24893         LDKChannelDetails this_ptr_conv;
24894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24895         this_ptr_conv.is_owned = false;
24896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24897         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24898 }
24899
24900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
24901         LDKChannelDetails this_ptr_conv;
24902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24903         this_ptr_conv.is_owned = false;
24904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24905         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24906         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
24907         uint64_t ret_ref = (uint64_t)ret_copy;
24908         return ret_ref;
24909 }
24910
24911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24912         LDKChannelDetails this_ptr_conv;
24913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24914         this_ptr_conv.is_owned = false;
24915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24916         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24917         CHECK_ACCESS(val_ptr);
24918         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24919         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24920         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24921 }
24922
24923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24924         LDKChannelDetails this_ptr_conv;
24925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24926         this_ptr_conv.is_owned = false;
24927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24928         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24929         return ret_val;
24930 }
24931
24932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24933         LDKChannelDetails this_ptr_conv;
24934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24935         this_ptr_conv.is_owned = false;
24936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24937         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24938 }
24939
24940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24941         LDKChannelDetails this_ptr_conv;
24942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24943         this_ptr_conv.is_owned = false;
24944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24945         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
24946         return ret_val;
24947 }
24948
24949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24950         LDKChannelDetails this_ptr_conv;
24951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24952         this_ptr_conv.is_owned = false;
24953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24954         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
24955 }
24956
24957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24958         LDKChannelDetails this_ptr_conv;
24959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24960         this_ptr_conv.is_owned = false;
24961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24962         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24963         return ret_val;
24964 }
24965
24966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24967         LDKChannelDetails this_ptr_conv;
24968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24969         this_ptr_conv.is_owned = false;
24970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24971         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24972 }
24973
24974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24975         LDKChannelDetails this_ptr_conv;
24976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24977         this_ptr_conv.is_owned = false;
24978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24979         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24980         return ret_val;
24981 }
24982
24983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24984         LDKChannelDetails this_ptr_conv;
24985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24986         this_ptr_conv.is_owned = false;
24987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24988         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24989 }
24990
24991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
24992         LDKChannelDetails this_ptr_conv;
24993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24994         this_ptr_conv.is_owned = false;
24995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24996         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24997         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24998         uint64_t ret_ref = (uint64_t)ret_copy;
24999         return ret_ref;
25000 }
25001
25002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25003         LDKChannelDetails this_ptr_conv;
25004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25005         this_ptr_conv.is_owned = false;
25006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25007         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25008         CHECK_ACCESS(val_ptr);
25009         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
25010         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
25011         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
25012 }
25013
25014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25015         LDKChannelDetails this_ptr_conv;
25016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25017         this_ptr_conv.is_owned = false;
25018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25019         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
25020         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
25021         uint64_t ret_ref = (uint64_t)ret_copy;
25022         return ret_ref;
25023 }
25024
25025 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) {
25026         LDKChannelDetails this_ptr_conv;
25027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25028         this_ptr_conv.is_owned = false;
25029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25030         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25031         CHECK_ACCESS(val_ptr);
25032         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
25033         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
25034         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
25035 }
25036
25037 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
25038         LDKChannelDetails this_ptr_conv;
25039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25040         this_ptr_conv.is_owned = false;
25041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25042         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
25043         return ret_val;
25044 }
25045
25046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25047         LDKChannelDetails this_ptr_conv;
25048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25049         this_ptr_conv.is_owned = false;
25050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25051         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
25052 }
25053
25054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
25055         LDKChannelDetails this_ptr_conv;
25056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25057         this_ptr_conv.is_owned = false;
25058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25059         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
25060         return ret_val;
25061 }
25062
25063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25064         LDKChannelDetails this_ptr_conv;
25065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25066         this_ptr_conv.is_owned = false;
25067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25068         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
25069 }
25070
25071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
25072         LDKChannelDetails this_ptr_conv;
25073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25074         this_ptr_conv.is_owned = false;
25075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25076         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
25077         return ret_val;
25078 }
25079
25080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25081         LDKChannelDetails this_ptr_conv;
25082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25083         this_ptr_conv.is_owned = false;
25084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25085         ChannelDetails_set_is_usable(&this_ptr_conv, val);
25086 }
25087
25088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
25089         LDKChannelDetails this_ptr_conv;
25090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25091         this_ptr_conv.is_owned = false;
25092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25093         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
25094         return ret_val;
25095 }
25096
25097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25098         LDKChannelDetails this_ptr_conv;
25099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25100         this_ptr_conv.is_owned = false;
25101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25102         ChannelDetails_set_is_public(&this_ptr_conv, val);
25103 }
25104
25105 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) {
25106         LDKThirtyTwoBytes channel_id_arg_ref;
25107         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
25108         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
25109         LDKChannelCounterparty counterparty_arg_conv;
25110         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
25111         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
25112         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
25113         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
25114         LDKOutPoint funding_txo_arg_conv;
25115         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
25116         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
25117         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
25118         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
25119         void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
25120         CHECK_ACCESS(short_channel_id_arg_ptr);
25121         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
25122         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
25123         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
25124         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
25125         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
25126         void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
25127         CHECK_ACCESS(confirmations_required_arg_ptr);
25128         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
25129         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
25130         void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
25131         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
25132         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
25133         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
25134         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);
25135         uint64_t ret_ref = 0;
25136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25139         ret_ref = (uint64_t)ret_var.inner;
25140         if (ret_var.is_owned) {
25141                 ret_ref |= 1;
25142         }
25143         return ret_ref;
25144 }
25145
25146 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
25147         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
25148 uint64_t ret_ref = 0;
25149 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25150 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25151 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25152 ret_ref = (uint64_t)ret_var.inner;
25153 if (ret_var.is_owned) {
25154         ret_ref |= 1;
25155 }
25156         return ret_ref;
25157 }
25158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25159         LDKChannelDetails arg_conv;
25160         arg_conv.inner = (void*)(arg & (~1));
25161         arg_conv.is_owned = false;
25162         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25163         int64_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
25164         return ret_val;
25165 }
25166
25167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25168         LDKChannelDetails orig_conv;
25169         orig_conv.inner = (void*)(orig & (~1));
25170         orig_conv.is_owned = false;
25171         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25172         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
25173         uint64_t ret_ref = 0;
25174         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25175         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25177         ret_ref = (uint64_t)ret_var.inner;
25178         if (ret_var.is_owned) {
25179                 ret_ref |= 1;
25180         }
25181         return ret_ref;
25182 }
25183
25184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25185         if ((this_ptr & 1) != 0) return;
25186         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
25187         CHECK_ACCESS(this_ptr_ptr);
25188         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
25189         FREE((void*)this_ptr);
25190         PaymentSendFailure_free(this_ptr_conv);
25191 }
25192
25193 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
25194         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25195         *ret_copy = PaymentSendFailure_clone(arg);
25196 uint64_t ret_ref = (uint64_t)ret_copy;
25197         return ret_ref;
25198 }
25199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25200         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
25201         int64_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
25202         return ret_val;
25203 }
25204
25205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25206         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
25207         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25208         *ret_copy = PaymentSendFailure_clone(orig_conv);
25209         uint64_t ret_ref = (uint64_t)ret_copy;
25210         return ret_ref;
25211 }
25212
25213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
25214         void* a_ptr = (void*)(((uint64_t)a) & ~1);
25215         CHECK_ACCESS(a_ptr);
25216         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
25217         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
25218         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25219         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
25220         uint64_t ret_ref = (uint64_t)ret_copy;
25221         return ret_ref;
25222 }
25223
25224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
25225         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
25226         a_constr.datalen = (*env)->GetArrayLength(env, a);
25227         if (a_constr.datalen > 0)
25228                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25229         else
25230                 a_constr.data = NULL;
25231         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
25232         for (size_t w = 0; w < a_constr.datalen; w++) {
25233                 int64_t a_conv_22 = a_vals[w];
25234                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
25235                 CHECK_ACCESS(a_conv_22_ptr);
25236                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
25237                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
25238                 a_constr.data[w] = a_conv_22_conv;
25239         }
25240         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
25241         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25242         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
25243         uint64_t ret_ref = (uint64_t)ret_copy;
25244         return ret_ref;
25245 }
25246
25247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
25248         LDKCVec_APIErrorZ a_constr;
25249         a_constr.datalen = (*env)->GetArrayLength(env, a);
25250         if (a_constr.datalen > 0)
25251                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
25252         else
25253                 a_constr.data = NULL;
25254         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
25255         for (size_t k = 0; k < a_constr.datalen; k++) {
25256                 int64_t a_conv_10 = a_vals[k];
25257                 void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
25258                 CHECK_ACCESS(a_conv_10_ptr);
25259                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
25260                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
25261                 a_constr.data[k] = a_conv_10_conv;
25262         }
25263         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
25264         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25265         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
25266         uint64_t ret_ref = (uint64_t)ret_copy;
25267         return ret_ref;
25268 }
25269
25270 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) {
25271         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
25272         results_constr.datalen = (*env)->GetArrayLength(env, results);
25273         if (results_constr.datalen > 0)
25274                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25275         else
25276                 results_constr.data = NULL;
25277         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
25278         for (size_t w = 0; w < results_constr.datalen; w++) {
25279                 int64_t results_conv_22 = results_vals[w];
25280                 void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
25281                 CHECK_ACCESS(results_conv_22_ptr);
25282                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
25283                 results_constr.data[w] = results_conv_22_conv;
25284         }
25285         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
25286         LDKRouteParameters failed_paths_retry_conv;
25287         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
25288         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
25289         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
25290         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
25291         LDKThirtyTwoBytes payment_id_ref;
25292         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25293         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25294         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25295         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
25296         uint64_t ret_ref = (uint64_t)ret_copy;
25297         return ret_ref;
25298 }
25299
25300 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) {
25301         void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
25302         CHECK_ACCESS(fee_est_ptr);
25303         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
25304         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
25305                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25306                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
25307         }
25308         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
25309         CHECK_ACCESS(chain_monitor_ptr);
25310         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25311         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
25312                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25313                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
25314         }
25315         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
25316         CHECK_ACCESS(tx_broadcaster_ptr);
25317         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25318         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25319                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25320                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
25321         }
25322         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
25323         CHECK_ACCESS(logger_ptr);
25324         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25325         if (logger_conv.free == LDKLogger_JCalls_free) {
25326                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25327                 LDKLogger_JCalls_cloned(&logger_conv);
25328         }
25329         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
25330         CHECK_ACCESS(keys_manager_ptr);
25331         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25332         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25333                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25334                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25335         }
25336         LDKUserConfig config_conv;
25337         config_conv.inner = (void*)(config & (~1));
25338         config_conv.is_owned = (config & 1) || (config == 0);
25339         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
25340         config_conv = UserConfig_clone(&config_conv);
25341         LDKChainParameters params_conv;
25342         params_conv.inner = (void*)(params & (~1));
25343         params_conv.is_owned = (params & 1) || (params == 0);
25344         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
25345         params_conv = ChainParameters_clone(&params_conv);
25346         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
25347         uint64_t ret_ref = 0;
25348         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25349         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25351         ret_ref = (uint64_t)ret_var.inner;
25352         if (ret_var.is_owned) {
25353                 ret_ref |= 1;
25354         }
25355         return ret_ref;
25356 }
25357
25358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
25359         LDKChannelManager this_arg_conv;
25360         this_arg_conv.inner = (void*)(this_arg & (~1));
25361         this_arg_conv.is_owned = false;
25362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25363         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
25364         uint64_t ret_ref = 0;
25365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25368         ret_ref = (uint64_t)ret_var.inner;
25369         if (ret_var.is_owned) {
25370                 ret_ref |= 1;
25371         }
25372         return ret_ref;
25373 }
25374
25375 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) {
25376         LDKChannelManager this_arg_conv;
25377         this_arg_conv.inner = (void*)(this_arg & (~1));
25378         this_arg_conv.is_owned = false;
25379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25380         LDKPublicKey their_network_key_ref;
25381         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
25382         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
25383         LDKUserConfig override_config_conv;
25384         override_config_conv.inner = (void*)(override_config & (~1));
25385         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
25386         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
25387         override_config_conv = UserConfig_clone(&override_config_conv);
25388         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
25389         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
25390         return (uint64_t)ret_conv;
25391 }
25392
25393 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
25394         LDKChannelManager this_arg_conv;
25395         this_arg_conv.inner = (void*)(this_arg & (~1));
25396         this_arg_conv.is_owned = false;
25397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25398         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
25399         int64_tArray ret_arr = NULL;
25400         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25401         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25402         for (size_t q = 0; q < ret_var.datalen; q++) {
25403                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25404                 uint64_t ret_conv_16_ref = 0;
25405                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25406                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25407                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25408                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
25409                 if (ret_conv_16_var.is_owned) {
25410                         ret_conv_16_ref |= 1;
25411                 }
25412                 ret_arr_ptr[q] = ret_conv_16_ref;
25413         }
25414         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25415         FREE(ret_var.data);
25416         return ret_arr;
25417 }
25418
25419 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
25420         LDKChannelManager this_arg_conv;
25421         this_arg_conv.inner = (void*)(this_arg & (~1));
25422         this_arg_conv.is_owned = false;
25423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25424         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
25425         int64_tArray ret_arr = NULL;
25426         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25427         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25428         for (size_t q = 0; q < ret_var.datalen; q++) {
25429                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25430                 uint64_t ret_conv_16_ref = 0;
25431                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25432                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25433                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25434                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
25435                 if (ret_conv_16_var.is_owned) {
25436                         ret_conv_16_ref |= 1;
25437                 }
25438                 ret_arr_ptr[q] = ret_conv_16_ref;
25439         }
25440         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25441         FREE(ret_var.data);
25442         return ret_arr;
25443 }
25444
25445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
25446         LDKChannelManager this_arg_conv;
25447         this_arg_conv.inner = (void*)(this_arg & (~1));
25448         this_arg_conv.is_owned = false;
25449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25450         unsigned char channel_id_arr[32];
25451         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25452         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
25453         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25454         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25455         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
25456         return (uint64_t)ret_conv;
25457 }
25458
25459 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) {
25460         LDKChannelManager this_arg_conv;
25461         this_arg_conv.inner = (void*)(this_arg & (~1));
25462         this_arg_conv.is_owned = false;
25463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25464         unsigned char channel_id_arr[32];
25465         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25466         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
25467         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25468         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25469         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
25470         return (uint64_t)ret_conv;
25471 }
25472
25473 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) {
25474         LDKChannelManager this_arg_conv;
25475         this_arg_conv.inner = (void*)(this_arg & (~1));
25476         this_arg_conv.is_owned = false;
25477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25478         unsigned char channel_id_arr[32];
25479         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25480         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
25481         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25482         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25483         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
25484         return (uint64_t)ret_conv;
25485 }
25486
25487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
25488         LDKChannelManager this_arg_conv;
25489         this_arg_conv.inner = (void*)(this_arg & (~1));
25490         this_arg_conv.is_owned = false;
25491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25492         ChannelManager_force_close_all_channels(&this_arg_conv);
25493 }
25494
25495 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) {
25496         LDKChannelManager this_arg_conv;
25497         this_arg_conv.inner = (void*)(this_arg & (~1));
25498         this_arg_conv.is_owned = false;
25499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25500         LDKRoute route_conv;
25501         route_conv.inner = (void*)(route & (~1));
25502         route_conv.is_owned = false;
25503         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25504         LDKThirtyTwoBytes payment_hash_ref;
25505         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25506         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25507         LDKThirtyTwoBytes payment_secret_ref;
25508         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
25509         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
25510         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
25511         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
25512         return (uint64_t)ret_conv;
25513 }
25514
25515 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) {
25516         LDKChannelManager this_arg_conv;
25517         this_arg_conv.inner = (void*)(this_arg & (~1));
25518         this_arg_conv.is_owned = false;
25519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25520         LDKRoute route_conv;
25521         route_conv.inner = (void*)(route & (~1));
25522         route_conv.is_owned = false;
25523         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25524         LDKThirtyTwoBytes payment_id_ref;
25525         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25526         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25527         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
25528         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
25529         return (uint64_t)ret_conv;
25530 }
25531
25532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
25533         LDKChannelManager this_arg_conv;
25534         this_arg_conv.inner = (void*)(this_arg & (~1));
25535         this_arg_conv.is_owned = false;
25536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25537         LDKThirtyTwoBytes payment_id_ref;
25538         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25539         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25540         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
25541 }
25542
25543 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) {
25544         LDKChannelManager this_arg_conv;
25545         this_arg_conv.inner = (void*)(this_arg & (~1));
25546         this_arg_conv.is_owned = false;
25547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25548         LDKRoute route_conv;
25549         route_conv.inner = (void*)(route & (~1));
25550         route_conv.is_owned = false;
25551         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25552         LDKThirtyTwoBytes payment_preimage_ref;
25553         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
25554         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
25555         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
25556         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
25557         return (uint64_t)ret_conv;
25558 }
25559
25560 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) {
25561         LDKChannelManager this_arg_conv;
25562         this_arg_conv.inner = (void*)(this_arg & (~1));
25563         this_arg_conv.is_owned = false;
25564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25565         unsigned char temporary_channel_id_arr[32];
25566         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
25567         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
25568         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25569         LDKTransaction funding_transaction_ref;
25570         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
25571         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
25572         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
25573         funding_transaction_ref.data_is_owned = true;
25574         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25575         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
25576         return (uint64_t)ret_conv;
25577 }
25578
25579 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) {
25580         LDKChannelManager this_arg_conv;
25581         this_arg_conv.inner = (void*)(this_arg & (~1));
25582         this_arg_conv.is_owned = false;
25583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25584         LDKThreeBytes rgb_ref;
25585         CHECK((*env)->GetArrayLength(env, rgb) == 3);
25586         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
25587         LDKThirtyTwoBytes alias_ref;
25588         CHECK((*env)->GetArrayLength(env, alias) == 32);
25589         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
25590         LDKCVec_NetAddressZ addresses_constr;
25591         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
25592         if (addresses_constr.datalen > 0)
25593                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25594         else
25595                 addresses_constr.data = NULL;
25596         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
25597         for (size_t m = 0; m < addresses_constr.datalen; m++) {
25598                 int64_t addresses_conv_12 = addresses_vals[m];
25599                 void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
25600                 CHECK_ACCESS(addresses_conv_12_ptr);
25601                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
25602                 addresses_constr.data[m] = addresses_conv_12_conv;
25603         }
25604         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
25605         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
25606 }
25607
25608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
25609         LDKChannelManager this_arg_conv;
25610         this_arg_conv.inner = (void*)(this_arg & (~1));
25611         this_arg_conv.is_owned = false;
25612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25613         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
25614 }
25615
25616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
25617         LDKChannelManager this_arg_conv;
25618         this_arg_conv.inner = (void*)(this_arg & (~1));
25619         this_arg_conv.is_owned = false;
25620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25621         ChannelManager_timer_tick_occurred(&this_arg_conv);
25622 }
25623
25624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
25625         LDKChannelManager this_arg_conv;
25626         this_arg_conv.inner = (void*)(this_arg & (~1));
25627         this_arg_conv.is_owned = false;
25628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25629         unsigned char payment_hash_arr[32];
25630         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25631         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
25632         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
25633         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
25634         return ret_val;
25635 }
25636
25637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
25638         LDKChannelManager this_arg_conv;
25639         this_arg_conv.inner = (void*)(this_arg & (~1));
25640         this_arg_conv.is_owned = false;
25641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25642         LDKThirtyTwoBytes payment_preimage_ref;
25643         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
25644         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
25645         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
25646         return ret_val;
25647 }
25648
25649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
25650         LDKChannelManager this_arg_conv;
25651         this_arg_conv.inner = (void*)(this_arg & (~1));
25652         this_arg_conv.is_owned = false;
25653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25654         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
25656         return ret_arr;
25657 }
25658
25659 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) {
25660         LDKChannelManager this_arg_conv;
25661         this_arg_conv.inner = (void*)(this_arg & (~1));
25662         this_arg_conv.is_owned = false;
25663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25664         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
25665         CHECK_ACCESS(min_value_msat_ptr);
25666         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25667         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
25668         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
25669         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25670         return (uint64_t)ret_conv;
25671 }
25672
25673 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) {
25674         LDKChannelManager this_arg_conv;
25675         this_arg_conv.inner = (void*)(this_arg & (~1));
25676         this_arg_conv.is_owned = false;
25677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25678         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
25679         CHECK_ACCESS(min_value_msat_ptr);
25680         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25681         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
25682         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
25683         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25684         return (uint64_t)ret_conv;
25685 }
25686
25687 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) {
25688         LDKChannelManager this_arg_conv;
25689         this_arg_conv.inner = (void*)(this_arg & (~1));
25690         this_arg_conv.is_owned = false;
25691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25692         LDKThirtyTwoBytes payment_hash_ref;
25693         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25694         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25695         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
25696         CHECK_ACCESS(min_value_msat_ptr);
25697         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25698         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
25699         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
25700         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25701         return (uint64_t)ret_conv;
25702 }
25703
25704 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) {
25705         LDKChannelManager this_arg_conv;
25706         this_arg_conv.inner = (void*)(this_arg & (~1));
25707         this_arg_conv.is_owned = false;
25708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25709         LDKThirtyTwoBytes payment_hash_ref;
25710         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25711         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25712         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
25713         CHECK_ACCESS(min_value_msat_ptr);
25714         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25715         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
25716         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
25717         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25718         return (uint64_t)ret_conv;
25719 }
25720
25721 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) {
25722         LDKChannelManager this_arg_conv;
25723         this_arg_conv.inner = (void*)(this_arg & (~1));
25724         this_arg_conv.is_owned = false;
25725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25726         LDKThirtyTwoBytes payment_hash_ref;
25727         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25728         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25729         LDKThirtyTwoBytes payment_secret_ref;
25730         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
25731         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
25732         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
25733         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
25734         return (uint64_t)ret_conv;
25735 }
25736
25737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25738         LDKChannelManager this_arg_conv;
25739         this_arg_conv.inner = (void*)(this_arg & (~1));
25740         this_arg_conv.is_owned = false;
25741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25742         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25743         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
25744         return (uint64_t)ret_ret;
25745 }
25746
25747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25748         LDKChannelManager this_arg_conv;
25749         this_arg_conv.inner = (void*)(this_arg & (~1));
25750         this_arg_conv.is_owned = false;
25751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25752         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25753         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
25754         return (uint64_t)ret_ret;
25755 }
25756
25757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
25758         LDKChannelManager this_arg_conv;
25759         this_arg_conv.inner = (void*)(this_arg & (~1));
25760         this_arg_conv.is_owned = false;
25761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25762         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25763         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
25764         return (uint64_t)ret_ret;
25765 }
25766
25767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
25768         LDKChannelManager this_arg_conv;
25769         this_arg_conv.inner = (void*)(this_arg & (~1));
25770         this_arg_conv.is_owned = false;
25771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25772         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25773         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
25774         return (uint64_t)ret_ret;
25775 }
25776
25777 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) {
25778         LDKChannelManager this_arg_conv;
25779         this_arg_conv.inner = (void*)(this_arg & (~1));
25780         this_arg_conv.is_owned = false;
25781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25782         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
25783         return ret_val;
25784 }
25785
25786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
25787         LDKChannelManager this_arg_conv;
25788         this_arg_conv.inner = (void*)(this_arg & (~1));
25789         this_arg_conv.is_owned = false;
25790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25791         ChannelManager_await_persistable_update(&this_arg_conv);
25792 }
25793
25794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
25795         LDKChannelManager this_arg_conv;
25796         this_arg_conv.inner = (void*)(this_arg & (~1));
25797         this_arg_conv.is_owned = false;
25798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25799         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
25800         uint64_t ret_ref = 0;
25801         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25802         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25804         ret_ref = (uint64_t)ret_var.inner;
25805         if (ret_var.is_owned) {
25806                 ret_ref |= 1;
25807         }
25808         return ret_ref;
25809 }
25810
25811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
25812         LDKChannelManager this_arg_conv;
25813         this_arg_conv.inner = (void*)(this_arg & (~1));
25814         this_arg_conv.is_owned = false;
25815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25816         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25817         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25818         return (uint64_t)ret_ret;
25819 }
25820
25821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
25822         LDKChannelManager obj_conv;
25823         obj_conv.inner = (void*)(obj & (~1));
25824         obj_conv.is_owned = false;
25825         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25826         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
25827         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25828         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25829         CVec_u8Z_free(ret_var);
25830         return ret_arr;
25831 }
25832
25833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25834         LDKChannelManagerReadArgs this_obj_conv;
25835         this_obj_conv.inner = (void*)(this_obj & (~1));
25836         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25838         ChannelManagerReadArgs_free(this_obj_conv);
25839 }
25840
25841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
25842         LDKChannelManagerReadArgs this_ptr_conv;
25843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25844         this_ptr_conv.is_owned = false;
25845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25846         // WARNING: This object doesn't live past this scope, needs clone!
25847         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25848         return ret_ret;
25849 }
25850
25851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25852         LDKChannelManagerReadArgs this_ptr_conv;
25853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25854         this_ptr_conv.is_owned = false;
25855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25856         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25857         CHECK_ACCESS(val_ptr);
25858         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25859         if (val_conv.free == LDKKeysInterface_JCalls_free) {
25860                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25861                 LDKKeysInterface_JCalls_cloned(&val_conv);
25862         }
25863         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25864 }
25865
25866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
25867         LDKChannelManagerReadArgs this_ptr_conv;
25868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25869         this_ptr_conv.is_owned = false;
25870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25871         // WARNING: This object doesn't live past this scope, needs clone!
25872         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25873         return ret_ret;
25874 }
25875
25876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25877         LDKChannelManagerReadArgs this_ptr_conv;
25878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25879         this_ptr_conv.is_owned = false;
25880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25881         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25882         CHECK_ACCESS(val_ptr);
25883         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25884         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
25885                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25886                 LDKFeeEstimator_JCalls_cloned(&val_conv);
25887         }
25888         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25889 }
25890
25891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
25892         LDKChannelManagerReadArgs this_ptr_conv;
25893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25894         this_ptr_conv.is_owned = false;
25895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25896         // WARNING: This object doesn't live past this scope, needs clone!
25897         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25898         return ret_ret;
25899 }
25900
25901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25902         LDKChannelManagerReadArgs this_ptr_conv;
25903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25904         this_ptr_conv.is_owned = false;
25905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25906         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25907         CHECK_ACCESS(val_ptr);
25908         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25909         if (val_conv.free == LDKWatch_JCalls_free) {
25910                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25911                 LDKWatch_JCalls_cloned(&val_conv);
25912         }
25913         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25914 }
25915
25916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
25917         LDKChannelManagerReadArgs this_ptr_conv;
25918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25919         this_ptr_conv.is_owned = false;
25920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25921         // WARNING: This object doesn't live past this scope, needs clone!
25922         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
25923         return ret_ret;
25924 }
25925
25926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25927         LDKChannelManagerReadArgs this_ptr_conv;
25928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25929         this_ptr_conv.is_owned = false;
25930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25931         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25932         CHECK_ACCESS(val_ptr);
25933         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
25934         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
25935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25936                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
25937         }
25938         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
25939 }
25940
25941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
25942         LDKChannelManagerReadArgs this_ptr_conv;
25943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25944         this_ptr_conv.is_owned = false;
25945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25946         // WARNING: This object doesn't live past this scope, needs clone!
25947         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
25948         return ret_ret;
25949 }
25950
25951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25952         LDKChannelManagerReadArgs this_ptr_conv;
25953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25954         this_ptr_conv.is_owned = false;
25955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25956         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25957         CHECK_ACCESS(val_ptr);
25958         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
25959         if (val_conv.free == LDKLogger_JCalls_free) {
25960                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25961                 LDKLogger_JCalls_cloned(&val_conv);
25962         }
25963         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
25964 }
25965
25966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25967         LDKChannelManagerReadArgs this_ptr_conv;
25968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25969         this_ptr_conv.is_owned = false;
25970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25971         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
25972         uint64_t ret_ref = 0;
25973         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25974         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25976         ret_ref = (uint64_t)ret_var.inner;
25977         if (ret_var.is_owned) {
25978                 ret_ref |= 1;
25979         }
25980         return ret_ref;
25981 }
25982
25983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25984         LDKChannelManagerReadArgs this_ptr_conv;
25985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25986         this_ptr_conv.is_owned = false;
25987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25988         LDKUserConfig val_conv;
25989         val_conv.inner = (void*)(val & (~1));
25990         val_conv.is_owned = (val & 1) || (val == 0);
25991         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25992         val_conv = UserConfig_clone(&val_conv);
25993         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
25994 }
25995
25996 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) {
25997         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
25998         CHECK_ACCESS(keys_manager_ptr);
25999         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
26000         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26001                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26002                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26003         }
26004         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
26005         CHECK_ACCESS(fee_estimator_ptr);
26006         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26007         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26008                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26009                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26010         }
26011         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
26012         CHECK_ACCESS(chain_monitor_ptr);
26013         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26014         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26015                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26016                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26017         }
26018         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
26019         CHECK_ACCESS(tx_broadcaster_ptr);
26020         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26021         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26022                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26023                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26024         }
26025         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
26026         CHECK_ACCESS(logger_ptr);
26027         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26028         if (logger_conv.free == LDKLogger_JCalls_free) {
26029                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26030                 LDKLogger_JCalls_cloned(&logger_conv);
26031         }
26032         LDKUserConfig default_config_conv;
26033         default_config_conv.inner = (void*)(default_config & (~1));
26034         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
26035         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
26036         default_config_conv = UserConfig_clone(&default_config_conv);
26037         LDKCVec_ChannelMonitorZ channel_monitors_constr;
26038         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
26039         if (channel_monitors_constr.datalen > 0)
26040                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
26041         else
26042                 channel_monitors_constr.data = NULL;
26043         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
26044         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
26045                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
26046                 LDKChannelMonitor channel_monitors_conv_16_conv;
26047                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
26048                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
26049                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
26050                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
26051         }
26052         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
26053         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);
26054         uint64_t ret_ref = 0;
26055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26058         ret_ref = (uint64_t)ret_var.inner;
26059         if (ret_var.is_owned) {
26060                 ret_ref |= 1;
26061         }
26062         return ret_ref;
26063 }
26064
26065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
26066         LDKu8slice ser_ref;
26067         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26068         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26069         LDKChannelManagerReadArgs arg_conv;
26070         arg_conv.inner = (void*)(arg & (~1));
26071         arg_conv.is_owned = (arg & 1) || (arg == 0);
26072         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26073         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
26074         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
26075         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
26076         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26077         return (uint64_t)ret_conv;
26078 }
26079
26080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26081         LDKDecodeError this_obj_conv;
26082         this_obj_conv.inner = (void*)(this_obj & (~1));
26083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26085         DecodeError_free(this_obj_conv);
26086 }
26087
26088 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
26089         LDKDecodeError ret_var = DecodeError_clone(arg);
26090 uint64_t ret_ref = 0;
26091 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26092 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26093 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26094 ret_ref = (uint64_t)ret_var.inner;
26095 if (ret_var.is_owned) {
26096         ret_ref |= 1;
26097 }
26098         return ret_ref;
26099 }
26100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26101         LDKDecodeError arg_conv;
26102         arg_conv.inner = (void*)(arg & (~1));
26103         arg_conv.is_owned = false;
26104         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26105         int64_t ret_val = DecodeError_clone_ptr(&arg_conv);
26106         return ret_val;
26107 }
26108
26109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26110         LDKDecodeError orig_conv;
26111         orig_conv.inner = (void*)(orig & (~1));
26112         orig_conv.is_owned = false;
26113         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26114         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
26115         uint64_t ret_ref = 0;
26116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26119         ret_ref = (uint64_t)ret_var.inner;
26120         if (ret_var.is_owned) {
26121                 ret_ref |= 1;
26122         }
26123         return ret_ref;
26124 }
26125
26126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26127         LDKInit this_obj_conv;
26128         this_obj_conv.inner = (void*)(this_obj & (~1));
26129         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26131         Init_free(this_obj_conv);
26132 }
26133
26134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
26135         LDKInit this_ptr_conv;
26136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26137         this_ptr_conv.is_owned = false;
26138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26139         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
26140         uint64_t ret_ref = 0;
26141         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26142         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26144         ret_ref = (uint64_t)ret_var.inner;
26145         if (ret_var.is_owned) {
26146                 ret_ref |= 1;
26147         }
26148         return ret_ref;
26149 }
26150
26151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26152         LDKInit this_ptr_conv;
26153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26154         this_ptr_conv.is_owned = false;
26155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26156         LDKInitFeatures val_conv;
26157         val_conv.inner = (void*)(val & (~1));
26158         val_conv.is_owned = (val & 1) || (val == 0);
26159         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26160         val_conv = InitFeatures_clone(&val_conv);
26161         Init_set_features(&this_ptr_conv, val_conv);
26162 }
26163
26164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
26165         LDKInitFeatures features_arg_conv;
26166         features_arg_conv.inner = (void*)(features_arg & (~1));
26167         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26168         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26169         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26170         LDKInit ret_var = Init_new(features_arg_conv);
26171         uint64_t ret_ref = 0;
26172         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26173         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26175         ret_ref = (uint64_t)ret_var.inner;
26176         if (ret_var.is_owned) {
26177                 ret_ref |= 1;
26178         }
26179         return ret_ref;
26180 }
26181
26182 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
26183         LDKInit ret_var = Init_clone(arg);
26184 uint64_t ret_ref = 0;
26185 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26186 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26187 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26188 ret_ref = (uint64_t)ret_var.inner;
26189 if (ret_var.is_owned) {
26190         ret_ref |= 1;
26191 }
26192         return ret_ref;
26193 }
26194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26195         LDKInit arg_conv;
26196         arg_conv.inner = (void*)(arg & (~1));
26197         arg_conv.is_owned = false;
26198         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26199         int64_t ret_val = Init_clone_ptr(&arg_conv);
26200         return ret_val;
26201 }
26202
26203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26204         LDKInit orig_conv;
26205         orig_conv.inner = (void*)(orig & (~1));
26206         orig_conv.is_owned = false;
26207         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26208         LDKInit ret_var = Init_clone(&orig_conv);
26209         uint64_t ret_ref = 0;
26210         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26211         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26213         ret_ref = (uint64_t)ret_var.inner;
26214         if (ret_var.is_owned) {
26215                 ret_ref |= 1;
26216         }
26217         return ret_ref;
26218 }
26219
26220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26221         LDKErrorMessage this_obj_conv;
26222         this_obj_conv.inner = (void*)(this_obj & (~1));
26223         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26225         ErrorMessage_free(this_obj_conv);
26226 }
26227
26228 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26229         LDKErrorMessage this_ptr_conv;
26230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26231         this_ptr_conv.is_owned = false;
26232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26233         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26234         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
26235         return ret_arr;
26236 }
26237
26238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26239         LDKErrorMessage this_ptr_conv;
26240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26241         this_ptr_conv.is_owned = false;
26242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26243         LDKThirtyTwoBytes val_ref;
26244         CHECK((*env)->GetArrayLength(env, val) == 32);
26245         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26246         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
26247 }
26248
26249 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
26250         LDKErrorMessage this_ptr_conv;
26251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26252         this_ptr_conv.is_owned = false;
26253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26254         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
26255         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26256         Str_free(ret_str);
26257         return ret_conv;
26258 }
26259
26260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26261         LDKErrorMessage this_ptr_conv;
26262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26263         this_ptr_conv.is_owned = false;
26264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26265         LDKStr val_conv = java_to_owned_str(env, val);
26266         ErrorMessage_set_data(&this_ptr_conv, val_conv);
26267 }
26268
26269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
26270         LDKThirtyTwoBytes channel_id_arg_ref;
26271         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
26272         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
26273         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
26274         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
26275         uint64_t ret_ref = 0;
26276         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26277         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26279         ret_ref = (uint64_t)ret_var.inner;
26280         if (ret_var.is_owned) {
26281                 ret_ref |= 1;
26282         }
26283         return ret_ref;
26284 }
26285
26286 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
26287         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
26288 uint64_t ret_ref = 0;
26289 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26290 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26291 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26292 ret_ref = (uint64_t)ret_var.inner;
26293 if (ret_var.is_owned) {
26294         ret_ref |= 1;
26295 }
26296         return ret_ref;
26297 }
26298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26299         LDKErrorMessage arg_conv;
26300         arg_conv.inner = (void*)(arg & (~1));
26301         arg_conv.is_owned = false;
26302         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26303         int64_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
26304         return ret_val;
26305 }
26306
26307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26308         LDKErrorMessage orig_conv;
26309         orig_conv.inner = (void*)(orig & (~1));
26310         orig_conv.is_owned = false;
26311         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26312         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
26313         uint64_t ret_ref = 0;
26314         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26315         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26317         ret_ref = (uint64_t)ret_var.inner;
26318         if (ret_var.is_owned) {
26319                 ret_ref |= 1;
26320         }
26321         return ret_ref;
26322 }
26323
26324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26325         LDKPing this_obj_conv;
26326         this_obj_conv.inner = (void*)(this_obj & (~1));
26327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26329         Ping_free(this_obj_conv);
26330 }
26331
26332 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
26333         LDKPing this_ptr_conv;
26334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26335         this_ptr_conv.is_owned = false;
26336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26337         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
26338         return ret_val;
26339 }
26340
26341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26342         LDKPing this_ptr_conv;
26343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26344         this_ptr_conv.is_owned = false;
26345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26346         Ping_set_ponglen(&this_ptr_conv, val);
26347 }
26348
26349 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
26350         LDKPing this_ptr_conv;
26351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26352         this_ptr_conv.is_owned = false;
26353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26354         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
26355         return ret_val;
26356 }
26357
26358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26359         LDKPing this_ptr_conv;
26360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26361         this_ptr_conv.is_owned = false;
26362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26363         Ping_set_byteslen(&this_ptr_conv, val);
26364 }
26365
26366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
26367         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
26368         uint64_t ret_ref = 0;
26369         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26370         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26372         ret_ref = (uint64_t)ret_var.inner;
26373         if (ret_var.is_owned) {
26374                 ret_ref |= 1;
26375         }
26376         return ret_ref;
26377 }
26378
26379 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
26380         LDKPing ret_var = Ping_clone(arg);
26381 uint64_t ret_ref = 0;
26382 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26383 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26384 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26385 ret_ref = (uint64_t)ret_var.inner;
26386 if (ret_var.is_owned) {
26387         ret_ref |= 1;
26388 }
26389         return ret_ref;
26390 }
26391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26392         LDKPing arg_conv;
26393         arg_conv.inner = (void*)(arg & (~1));
26394         arg_conv.is_owned = false;
26395         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26396         int64_t ret_val = Ping_clone_ptr(&arg_conv);
26397         return ret_val;
26398 }
26399
26400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26401         LDKPing orig_conv;
26402         orig_conv.inner = (void*)(orig & (~1));
26403         orig_conv.is_owned = false;
26404         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26405         LDKPing ret_var = Ping_clone(&orig_conv);
26406         uint64_t ret_ref = 0;
26407         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26408         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26410         ret_ref = (uint64_t)ret_var.inner;
26411         if (ret_var.is_owned) {
26412                 ret_ref |= 1;
26413         }
26414         return ret_ref;
26415 }
26416
26417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26418         LDKPong this_obj_conv;
26419         this_obj_conv.inner = (void*)(this_obj & (~1));
26420         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26422         Pong_free(this_obj_conv);
26423 }
26424
26425 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
26426         LDKPong this_ptr_conv;
26427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26428         this_ptr_conv.is_owned = false;
26429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26430         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
26431         return ret_val;
26432 }
26433
26434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26435         LDKPong this_ptr_conv;
26436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26437         this_ptr_conv.is_owned = false;
26438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26439         Pong_set_byteslen(&this_ptr_conv, val);
26440 }
26441
26442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
26443         LDKPong ret_var = Pong_new(byteslen_arg);
26444         uint64_t ret_ref = 0;
26445         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26446         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26448         ret_ref = (uint64_t)ret_var.inner;
26449         if (ret_var.is_owned) {
26450                 ret_ref |= 1;
26451         }
26452         return ret_ref;
26453 }
26454
26455 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
26456         LDKPong ret_var = Pong_clone(arg);
26457 uint64_t ret_ref = 0;
26458 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26459 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26460 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26461 ret_ref = (uint64_t)ret_var.inner;
26462 if (ret_var.is_owned) {
26463         ret_ref |= 1;
26464 }
26465         return ret_ref;
26466 }
26467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26468         LDKPong arg_conv;
26469         arg_conv.inner = (void*)(arg & (~1));
26470         arg_conv.is_owned = false;
26471         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26472         int64_t ret_val = Pong_clone_ptr(&arg_conv);
26473         return ret_val;
26474 }
26475
26476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26477         LDKPong orig_conv;
26478         orig_conv.inner = (void*)(orig & (~1));
26479         orig_conv.is_owned = false;
26480         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26481         LDKPong ret_var = Pong_clone(&orig_conv);
26482         uint64_t ret_ref = 0;
26483         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26484         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26486         ret_ref = (uint64_t)ret_var.inner;
26487         if (ret_var.is_owned) {
26488                 ret_ref |= 1;
26489         }
26490         return ret_ref;
26491 }
26492
26493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26494         LDKOpenChannel this_obj_conv;
26495         this_obj_conv.inner = (void*)(this_obj & (~1));
26496         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26498         OpenChannel_free(this_obj_conv);
26499 }
26500
26501 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
26502         LDKOpenChannel this_ptr_conv;
26503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26504         this_ptr_conv.is_owned = false;
26505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26506         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26507         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
26508         return ret_arr;
26509 }
26510
26511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26512         LDKOpenChannel this_ptr_conv;
26513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26514         this_ptr_conv.is_owned = false;
26515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26516         LDKThirtyTwoBytes val_ref;
26517         CHECK((*env)->GetArrayLength(env, val) == 32);
26518         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26519         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
26520 }
26521
26522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26523         LDKOpenChannel this_ptr_conv;
26524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26525         this_ptr_conv.is_owned = false;
26526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26527         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26528         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
26529         return ret_arr;
26530 }
26531
26532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26533         LDKOpenChannel this_ptr_conv;
26534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26535         this_ptr_conv.is_owned = false;
26536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26537         LDKThirtyTwoBytes val_ref;
26538         CHECK((*env)->GetArrayLength(env, val) == 32);
26539         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26540         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26541 }
26542
26543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26544         LDKOpenChannel this_ptr_conv;
26545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26546         this_ptr_conv.is_owned = false;
26547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26548         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
26549         return ret_val;
26550 }
26551
26552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26553         LDKOpenChannel this_ptr_conv;
26554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26555         this_ptr_conv.is_owned = false;
26556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26557         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
26558 }
26559
26560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26561         LDKOpenChannel this_ptr_conv;
26562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26563         this_ptr_conv.is_owned = false;
26564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26565         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
26566         return ret_val;
26567 }
26568
26569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26570         LDKOpenChannel this_ptr_conv;
26571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26572         this_ptr_conv.is_owned = false;
26573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26574         OpenChannel_set_push_msat(&this_ptr_conv, val);
26575 }
26576
26577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26578         LDKOpenChannel this_ptr_conv;
26579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26580         this_ptr_conv.is_owned = false;
26581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26582         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
26583         return ret_val;
26584 }
26585
26586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26587         LDKOpenChannel this_ptr_conv;
26588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26589         this_ptr_conv.is_owned = false;
26590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26591         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26592 }
26593
26594 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) {
26595         LDKOpenChannel this_ptr_conv;
26596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26597         this_ptr_conv.is_owned = false;
26598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26599         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26600         return ret_val;
26601 }
26602
26603 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) {
26604         LDKOpenChannel this_ptr_conv;
26605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26606         this_ptr_conv.is_owned = false;
26607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26608         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26609 }
26610
26611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26612         LDKOpenChannel this_ptr_conv;
26613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26614         this_ptr_conv.is_owned = false;
26615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26616         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26617         return ret_val;
26618 }
26619
26620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26621         LDKOpenChannel this_ptr_conv;
26622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26623         this_ptr_conv.is_owned = false;
26624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26625         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26626 }
26627
26628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26629         LDKOpenChannel this_ptr_conv;
26630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26631         this_ptr_conv.is_owned = false;
26632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26633         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
26634         return ret_val;
26635 }
26636
26637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26638         LDKOpenChannel this_ptr_conv;
26639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26640         this_ptr_conv.is_owned = false;
26641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26642         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26643 }
26644
26645 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
26646         LDKOpenChannel this_ptr_conv;
26647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26648         this_ptr_conv.is_owned = false;
26649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26650         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
26651         return ret_val;
26652 }
26653
26654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26655         LDKOpenChannel this_ptr_conv;
26656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26657         this_ptr_conv.is_owned = false;
26658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26659         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
26660 }
26661
26662 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26663         LDKOpenChannel this_ptr_conv;
26664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26665         this_ptr_conv.is_owned = false;
26666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26667         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
26668         return ret_val;
26669 }
26670
26671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26672         LDKOpenChannel this_ptr_conv;
26673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26674         this_ptr_conv.is_owned = false;
26675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26676         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
26677 }
26678
26679 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
26680         LDKOpenChannel this_ptr_conv;
26681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26682         this_ptr_conv.is_owned = false;
26683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26684         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
26685         return ret_val;
26686 }
26687
26688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26689         LDKOpenChannel this_ptr_conv;
26690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26691         this_ptr_conv.is_owned = false;
26692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26693         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26694 }
26695
26696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26697         LDKOpenChannel this_ptr_conv;
26698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26699         this_ptr_conv.is_owned = false;
26700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26701         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26702         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
26703         return ret_arr;
26704 }
26705
26706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26707         LDKOpenChannel this_ptr_conv;
26708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26709         this_ptr_conv.is_owned = false;
26710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26711         LDKPublicKey val_ref;
26712         CHECK((*env)->GetArrayLength(env, val) == 33);
26713         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26714         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26715 }
26716
26717 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26718         LDKOpenChannel this_ptr_conv;
26719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26720         this_ptr_conv.is_owned = false;
26721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26722         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26723         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
26724         return ret_arr;
26725 }
26726
26727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26728         LDKOpenChannel this_ptr_conv;
26729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26730         this_ptr_conv.is_owned = false;
26731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26732         LDKPublicKey val_ref;
26733         CHECK((*env)->GetArrayLength(env, val) == 33);
26734         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26735         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26736 }
26737
26738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26739         LDKOpenChannel this_ptr_conv;
26740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26741         this_ptr_conv.is_owned = false;
26742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26743         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26744         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
26745         return ret_arr;
26746 }
26747
26748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26749         LDKOpenChannel this_ptr_conv;
26750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26751         this_ptr_conv.is_owned = false;
26752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26753         LDKPublicKey val_ref;
26754         CHECK((*env)->GetArrayLength(env, val) == 33);
26755         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26756         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
26757 }
26758
26759 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26760         LDKOpenChannel this_ptr_conv;
26761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26762         this_ptr_conv.is_owned = false;
26763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26764         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
26766         return ret_arr;
26767 }
26768
26769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26770         LDKOpenChannel this_ptr_conv;
26771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26772         this_ptr_conv.is_owned = false;
26773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26774         LDKPublicKey val_ref;
26775         CHECK((*env)->GetArrayLength(env, val) == 33);
26776         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26777         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26778 }
26779
26780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26781         LDKOpenChannel 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, 33);
26786         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
26787         return ret_arr;
26788 }
26789
26790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26791         LDKOpenChannel 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         LDKPublicKey val_ref;
26796         CHECK((*env)->GetArrayLength(env, val) == 33);
26797         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26798         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26799 }
26800
26801 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26802         LDKOpenChannel 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, 33);
26807         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
26808         return ret_arr;
26809 }
26810
26811 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) {
26812         LDKOpenChannel 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         LDKPublicKey val_ref;
26817         CHECK((*env)->GetArrayLength(env, val) == 33);
26818         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26819         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26820 }
26821
26822 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
26823         LDKOpenChannel 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_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
26828         return ret_val;
26829 }
26830
26831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
26832         LDKOpenChannel this_ptr_conv;
26833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26834         this_ptr_conv.is_owned = false;
26835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26836         OpenChannel_set_channel_flags(&this_ptr_conv, val);
26837 }
26838
26839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
26840         LDKOpenChannel this_ptr_conv;
26841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26842         this_ptr_conv.is_owned = false;
26843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26844         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
26845         uint64_t ret_ref = 0;
26846         if ((uint64_t)ret_var.inner > 4096) {
26847                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26848                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26850                 ret_ref = (uint64_t)ret_var.inner;
26851                 if (ret_var.is_owned) {
26852                         ret_ref |= 1;
26853                 }
26854         }
26855         return ret_ref;
26856 }
26857
26858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26859         LDKOpenChannel this_ptr_conv;
26860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26861         this_ptr_conv.is_owned = false;
26862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26863         LDKChannelTypeFeatures val_conv;
26864         val_conv.inner = (void*)(val & (~1));
26865         val_conv.is_owned = (val & 1) || (val == 0);
26866         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26867         val_conv = ChannelTypeFeatures_clone(&val_conv);
26868         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
26869 }
26870
26871 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
26872         LDKOpenChannel ret_var = OpenChannel_clone(arg);
26873 uint64_t ret_ref = 0;
26874 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26875 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26876 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26877 ret_ref = (uint64_t)ret_var.inner;
26878 if (ret_var.is_owned) {
26879         ret_ref |= 1;
26880 }
26881         return ret_ref;
26882 }
26883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26884         LDKOpenChannel arg_conv;
26885         arg_conv.inner = (void*)(arg & (~1));
26886         arg_conv.is_owned = false;
26887         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26888         int64_t ret_val = OpenChannel_clone_ptr(&arg_conv);
26889         return ret_val;
26890 }
26891
26892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26893         LDKOpenChannel orig_conv;
26894         orig_conv.inner = (void*)(orig & (~1));
26895         orig_conv.is_owned = false;
26896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26897         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
26898         uint64_t ret_ref = 0;
26899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26902         ret_ref = (uint64_t)ret_var.inner;
26903         if (ret_var.is_owned) {
26904                 ret_ref |= 1;
26905         }
26906         return ret_ref;
26907 }
26908
26909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26910         LDKAcceptChannel this_obj_conv;
26911         this_obj_conv.inner = (void*)(this_obj & (~1));
26912         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26914         AcceptChannel_free(this_obj_conv);
26915 }
26916
26917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26918         LDKAcceptChannel this_ptr_conv;
26919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26920         this_ptr_conv.is_owned = false;
26921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26922         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
26924         return ret_arr;
26925 }
26926
26927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26928         LDKAcceptChannel this_ptr_conv;
26929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26930         this_ptr_conv.is_owned = false;
26931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26932         LDKThirtyTwoBytes val_ref;
26933         CHECK((*env)->GetArrayLength(env, val) == 32);
26934         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26935         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26936 }
26937
26938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26939         LDKAcceptChannel this_ptr_conv;
26940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26941         this_ptr_conv.is_owned = false;
26942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26943         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
26944         return ret_val;
26945 }
26946
26947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26948         LDKAcceptChannel this_ptr_conv;
26949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26950         this_ptr_conv.is_owned = false;
26951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26952         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26953 }
26954
26955 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) {
26956         LDKAcceptChannel this_ptr_conv;
26957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26958         this_ptr_conv.is_owned = false;
26959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26960         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26961         return ret_val;
26962 }
26963
26964 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) {
26965         LDKAcceptChannel this_ptr_conv;
26966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26967         this_ptr_conv.is_owned = false;
26968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26969         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26970 }
26971
26972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26973         LDKAcceptChannel this_ptr_conv;
26974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26975         this_ptr_conv.is_owned = false;
26976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26977         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26978         return ret_val;
26979 }
26980
26981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26982         LDKAcceptChannel this_ptr_conv;
26983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26984         this_ptr_conv.is_owned = false;
26985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26986         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26987 }
26988
26989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26990         LDKAcceptChannel this_ptr_conv;
26991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26992         this_ptr_conv.is_owned = false;
26993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26994         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
26995         return ret_val;
26996 }
26997
26998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26999         LDKAcceptChannel this_ptr_conv;
27000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27001         this_ptr_conv.is_owned = false;
27002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27003         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
27004 }
27005
27006 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27007         LDKAcceptChannel this_ptr_conv;
27008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27009         this_ptr_conv.is_owned = false;
27010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27011         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
27012         return ret_val;
27013 }
27014
27015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27016         LDKAcceptChannel this_ptr_conv;
27017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27018         this_ptr_conv.is_owned = false;
27019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27020         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
27021 }
27022
27023 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27024         LDKAcceptChannel this_ptr_conv;
27025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27026         this_ptr_conv.is_owned = false;
27027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27028         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
27029         return ret_val;
27030 }
27031
27032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27033         LDKAcceptChannel this_ptr_conv;
27034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27035         this_ptr_conv.is_owned = false;
27036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27037         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
27038 }
27039
27040 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
27041         LDKAcceptChannel this_ptr_conv;
27042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27043         this_ptr_conv.is_owned = false;
27044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27045         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
27046         return ret_val;
27047 }
27048
27049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27050         LDKAcceptChannel this_ptr_conv;
27051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27052         this_ptr_conv.is_owned = false;
27053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27054         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
27055 }
27056
27057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27058         LDKAcceptChannel this_ptr_conv;
27059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27060         this_ptr_conv.is_owned = false;
27061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27062         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
27064         return ret_arr;
27065 }
27066
27067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27068         LDKAcceptChannel this_ptr_conv;
27069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27070         this_ptr_conv.is_owned = false;
27071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27072         LDKPublicKey val_ref;
27073         CHECK((*env)->GetArrayLength(env, val) == 33);
27074         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27075         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
27076 }
27077
27078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27079         LDKAcceptChannel this_ptr_conv;
27080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27081         this_ptr_conv.is_owned = false;
27082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27083         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27084         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
27085         return ret_arr;
27086 }
27087
27088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27089         LDKAcceptChannel this_ptr_conv;
27090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27091         this_ptr_conv.is_owned = false;
27092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27093         LDKPublicKey val_ref;
27094         CHECK((*env)->GetArrayLength(env, val) == 33);
27095         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27096         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
27097 }
27098
27099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27100         LDKAcceptChannel this_ptr_conv;
27101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27102         this_ptr_conv.is_owned = false;
27103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27104         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
27106         return ret_arr;
27107 }
27108
27109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27110         LDKAcceptChannel this_ptr_conv;
27111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27112         this_ptr_conv.is_owned = false;
27113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27114         LDKPublicKey val_ref;
27115         CHECK((*env)->GetArrayLength(env, val) == 33);
27116         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27117         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
27118 }
27119
27120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27121         LDKAcceptChannel this_ptr_conv;
27122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27123         this_ptr_conv.is_owned = false;
27124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27125         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27126         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
27127         return ret_arr;
27128 }
27129
27130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27131         LDKAcceptChannel this_ptr_conv;
27132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27133         this_ptr_conv.is_owned = false;
27134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27135         LDKPublicKey val_ref;
27136         CHECK((*env)->GetArrayLength(env, val) == 33);
27137         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27138         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
27139 }
27140
27141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27142         LDKAcceptChannel this_ptr_conv;
27143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27144         this_ptr_conv.is_owned = false;
27145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27146         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
27148         return ret_arr;
27149 }
27150
27151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27152         LDKAcceptChannel this_ptr_conv;
27153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27154         this_ptr_conv.is_owned = false;
27155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27156         LDKPublicKey val_ref;
27157         CHECK((*env)->GetArrayLength(env, val) == 33);
27158         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27159         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
27160 }
27161
27162 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27163         LDKAcceptChannel this_ptr_conv;
27164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27165         this_ptr_conv.is_owned = false;
27166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27167         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
27169         return ret_arr;
27170 }
27171
27172 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) {
27173         LDKAcceptChannel this_ptr_conv;
27174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27175         this_ptr_conv.is_owned = false;
27176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27177         LDKPublicKey val_ref;
27178         CHECK((*env)->GetArrayLength(env, val) == 33);
27179         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27180         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
27181 }
27182
27183 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
27184         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
27185 uint64_t ret_ref = 0;
27186 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27187 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27188 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27189 ret_ref = (uint64_t)ret_var.inner;
27190 if (ret_var.is_owned) {
27191         ret_ref |= 1;
27192 }
27193         return ret_ref;
27194 }
27195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27196         LDKAcceptChannel arg_conv;
27197         arg_conv.inner = (void*)(arg & (~1));
27198         arg_conv.is_owned = false;
27199         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27200         int64_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
27201         return ret_val;
27202 }
27203
27204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27205         LDKAcceptChannel orig_conv;
27206         orig_conv.inner = (void*)(orig & (~1));
27207         orig_conv.is_owned = false;
27208         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27209         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
27210         uint64_t ret_ref = 0;
27211         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27212         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27214         ret_ref = (uint64_t)ret_var.inner;
27215         if (ret_var.is_owned) {
27216                 ret_ref |= 1;
27217         }
27218         return ret_ref;
27219 }
27220
27221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27222         LDKFundingCreated this_obj_conv;
27223         this_obj_conv.inner = (void*)(this_obj & (~1));
27224         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27226         FundingCreated_free(this_obj_conv);
27227 }
27228
27229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27230         LDKFundingCreated this_ptr_conv;
27231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27232         this_ptr_conv.is_owned = false;
27233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27234         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27235         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
27236         return ret_arr;
27237 }
27238
27239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27240         LDKFundingCreated this_ptr_conv;
27241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27242         this_ptr_conv.is_owned = false;
27243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27244         LDKThirtyTwoBytes val_ref;
27245         CHECK((*env)->GetArrayLength(env, val) == 32);
27246         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27247         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
27248 }
27249
27250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
27251         LDKFundingCreated this_ptr_conv;
27252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27253         this_ptr_conv.is_owned = false;
27254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27255         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27256         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
27257         return ret_arr;
27258 }
27259
27260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27261         LDKFundingCreated this_ptr_conv;
27262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27263         this_ptr_conv.is_owned = false;
27264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27265         LDKThirtyTwoBytes val_ref;
27266         CHECK((*env)->GetArrayLength(env, val) == 32);
27267         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27268         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
27269 }
27270
27271 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
27272         LDKFundingCreated this_ptr_conv;
27273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27274         this_ptr_conv.is_owned = false;
27275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27276         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
27277         return ret_val;
27278 }
27279
27280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27281         LDKFundingCreated this_ptr_conv;
27282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27283         this_ptr_conv.is_owned = false;
27284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27285         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
27286 }
27287
27288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
27289         LDKFundingCreated this_ptr_conv;
27290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27291         this_ptr_conv.is_owned = false;
27292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27293         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
27294         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
27295         return ret_arr;
27296 }
27297
27298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27299         LDKFundingCreated this_ptr_conv;
27300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27301         this_ptr_conv.is_owned = false;
27302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27303         LDKSignature val_ref;
27304         CHECK((*env)->GetArrayLength(env, val) == 64);
27305         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
27306         FundingCreated_set_signature(&this_ptr_conv, val_ref);
27307 }
27308
27309 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) {
27310         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
27311         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
27312         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
27313         LDKThirtyTwoBytes funding_txid_arg_ref;
27314         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
27315         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
27316         LDKSignature signature_arg_ref;
27317         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
27318         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
27319         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
27320         uint64_t ret_ref = 0;
27321         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27322         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27324         ret_ref = (uint64_t)ret_var.inner;
27325         if (ret_var.is_owned) {
27326                 ret_ref |= 1;
27327         }
27328         return ret_ref;
27329 }
27330
27331 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
27332         LDKFundingCreated ret_var = FundingCreated_clone(arg);
27333 uint64_t ret_ref = 0;
27334 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27335 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27336 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27337 ret_ref = (uint64_t)ret_var.inner;
27338 if (ret_var.is_owned) {
27339         ret_ref |= 1;
27340 }
27341         return ret_ref;
27342 }
27343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27344         LDKFundingCreated arg_conv;
27345         arg_conv.inner = (void*)(arg & (~1));
27346         arg_conv.is_owned = false;
27347         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27348         int64_t ret_val = FundingCreated_clone_ptr(&arg_conv);
27349         return ret_val;
27350 }
27351
27352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27353         LDKFundingCreated orig_conv;
27354         orig_conv.inner = (void*)(orig & (~1));
27355         orig_conv.is_owned = false;
27356         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27357         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
27358         uint64_t ret_ref = 0;
27359         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27360         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27362         ret_ref = (uint64_t)ret_var.inner;
27363         if (ret_var.is_owned) {
27364                 ret_ref |= 1;
27365         }
27366         return ret_ref;
27367 }
27368
27369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27370         LDKFundingSigned this_obj_conv;
27371         this_obj_conv.inner = (void*)(this_obj & (~1));
27372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27374         FundingSigned_free(this_obj_conv);
27375 }
27376
27377 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27378         LDKFundingSigned this_ptr_conv;
27379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27380         this_ptr_conv.is_owned = false;
27381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27382         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27383         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
27384         return ret_arr;
27385 }
27386
27387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27388         LDKFundingSigned this_ptr_conv;
27389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27390         this_ptr_conv.is_owned = false;
27391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27392         LDKThirtyTwoBytes val_ref;
27393         CHECK((*env)->GetArrayLength(env, val) == 32);
27394         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27395         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
27396 }
27397
27398 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
27399         LDKFundingSigned this_ptr_conv;
27400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27401         this_ptr_conv.is_owned = false;
27402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27403         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
27404         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
27405         return ret_arr;
27406 }
27407
27408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27409         LDKFundingSigned this_ptr_conv;
27410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27411         this_ptr_conv.is_owned = false;
27412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27413         LDKSignature val_ref;
27414         CHECK((*env)->GetArrayLength(env, val) == 64);
27415         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
27416         FundingSigned_set_signature(&this_ptr_conv, val_ref);
27417 }
27418
27419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
27420         LDKThirtyTwoBytes channel_id_arg_ref;
27421         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27422         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27423         LDKSignature signature_arg_ref;
27424         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
27425         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
27426         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
27427         uint64_t ret_ref = 0;
27428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27431         ret_ref = (uint64_t)ret_var.inner;
27432         if (ret_var.is_owned) {
27433                 ret_ref |= 1;
27434         }
27435         return ret_ref;
27436 }
27437
27438 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
27439         LDKFundingSigned ret_var = FundingSigned_clone(arg);
27440 uint64_t ret_ref = 0;
27441 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27442 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27443 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27444 ret_ref = (uint64_t)ret_var.inner;
27445 if (ret_var.is_owned) {
27446         ret_ref |= 1;
27447 }
27448         return ret_ref;
27449 }
27450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27451         LDKFundingSigned arg_conv;
27452         arg_conv.inner = (void*)(arg & (~1));
27453         arg_conv.is_owned = false;
27454         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27455         int64_t ret_val = FundingSigned_clone_ptr(&arg_conv);
27456         return ret_val;
27457 }
27458
27459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27460         LDKFundingSigned orig_conv;
27461         orig_conv.inner = (void*)(orig & (~1));
27462         orig_conv.is_owned = false;
27463         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27464         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
27465         uint64_t ret_ref = 0;
27466         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27467         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27469         ret_ref = (uint64_t)ret_var.inner;
27470         if (ret_var.is_owned) {
27471                 ret_ref |= 1;
27472         }
27473         return ret_ref;
27474 }
27475
27476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27477         LDKFundingLocked this_obj_conv;
27478         this_obj_conv.inner = (void*)(this_obj & (~1));
27479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27481         FundingLocked_free(this_obj_conv);
27482 }
27483
27484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27485         LDKFundingLocked this_ptr_conv;
27486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27487         this_ptr_conv.is_owned = false;
27488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27489         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27490         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
27491         return ret_arr;
27492 }
27493
27494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27495         LDKFundingLocked this_ptr_conv;
27496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27497         this_ptr_conv.is_owned = false;
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27499         LDKThirtyTwoBytes val_ref;
27500         CHECK((*env)->GetArrayLength(env, val) == 32);
27501         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27502         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
27503 }
27504
27505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27506         LDKFundingLocked 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
27512         return ret_arr;
27513 }
27514
27515 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) {
27516         LDKFundingLocked this_ptr_conv;
27517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27518         this_ptr_conv.is_owned = false;
27519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27520         LDKPublicKey val_ref;
27521         CHECK((*env)->GetArrayLength(env, val) == 33);
27522         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27523         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27524 }
27525
27526 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) {
27527         LDKThirtyTwoBytes channel_id_arg_ref;
27528         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27529         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27530         LDKPublicKey next_per_commitment_point_arg_ref;
27531         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
27532         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
27533         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
27534         uint64_t ret_ref = 0;
27535         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27536         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27538         ret_ref = (uint64_t)ret_var.inner;
27539         if (ret_var.is_owned) {
27540                 ret_ref |= 1;
27541         }
27542         return ret_ref;
27543 }
27544
27545 static inline uint64_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
27546         LDKFundingLocked ret_var = FundingLocked_clone(arg);
27547 uint64_t ret_ref = 0;
27548 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27549 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27550 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27551 ret_ref = (uint64_t)ret_var.inner;
27552 if (ret_var.is_owned) {
27553         ret_ref |= 1;
27554 }
27555         return ret_ref;
27556 }
27557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27558         LDKFundingLocked arg_conv;
27559         arg_conv.inner = (void*)(arg & (~1));
27560         arg_conv.is_owned = false;
27561         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27562         int64_t ret_val = FundingLocked_clone_ptr(&arg_conv);
27563         return ret_val;
27564 }
27565
27566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27567         LDKFundingLocked orig_conv;
27568         orig_conv.inner = (void*)(orig & (~1));
27569         orig_conv.is_owned = false;
27570         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27571         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
27572         uint64_t ret_ref = 0;
27573         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27574         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27576         ret_ref = (uint64_t)ret_var.inner;
27577         if (ret_var.is_owned) {
27578                 ret_ref |= 1;
27579         }
27580         return ret_ref;
27581 }
27582
27583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27584         LDKShutdown this_obj_conv;
27585         this_obj_conv.inner = (void*)(this_obj & (~1));
27586         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27588         Shutdown_free(this_obj_conv);
27589 }
27590
27591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27592         LDKShutdown this_ptr_conv;
27593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27594         this_ptr_conv.is_owned = false;
27595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27596         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27597         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
27598         return ret_arr;
27599 }
27600
27601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27602         LDKShutdown this_ptr_conv;
27603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27604         this_ptr_conv.is_owned = false;
27605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27606         LDKThirtyTwoBytes val_ref;
27607         CHECK((*env)->GetArrayLength(env, val) == 32);
27608         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27609         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
27610 }
27611
27612 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27613         LDKShutdown this_ptr_conv;
27614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27615         this_ptr_conv.is_owned = false;
27616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27617         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
27618         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27619         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27620         return ret_arr;
27621 }
27622
27623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27624         LDKShutdown this_ptr_conv;
27625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27626         this_ptr_conv.is_owned = false;
27627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27628         LDKCVec_u8Z val_ref;
27629         val_ref.datalen = (*env)->GetArrayLength(env, val);
27630         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27631         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
27632         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
27633 }
27634
27635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
27636         LDKThirtyTwoBytes channel_id_arg_ref;
27637         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27638         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27639         LDKCVec_u8Z scriptpubkey_arg_ref;
27640         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
27641         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27642         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
27643         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
27644         uint64_t ret_ref = 0;
27645         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27646         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27648         ret_ref = (uint64_t)ret_var.inner;
27649         if (ret_var.is_owned) {
27650                 ret_ref |= 1;
27651         }
27652         return ret_ref;
27653 }
27654
27655 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
27656         LDKShutdown ret_var = Shutdown_clone(arg);
27657 uint64_t ret_ref = 0;
27658 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27659 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27660 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27661 ret_ref = (uint64_t)ret_var.inner;
27662 if (ret_var.is_owned) {
27663         ret_ref |= 1;
27664 }
27665         return ret_ref;
27666 }
27667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27668         LDKShutdown arg_conv;
27669         arg_conv.inner = (void*)(arg & (~1));
27670         arg_conv.is_owned = false;
27671         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27672         int64_t ret_val = Shutdown_clone_ptr(&arg_conv);
27673         return ret_val;
27674 }
27675
27676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27677         LDKShutdown orig_conv;
27678         orig_conv.inner = (void*)(orig & (~1));
27679         orig_conv.is_owned = false;
27680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27681         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
27682         uint64_t ret_ref = 0;
27683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27686         ret_ref = (uint64_t)ret_var.inner;
27687         if (ret_var.is_owned) {
27688                 ret_ref |= 1;
27689         }
27690         return ret_ref;
27691 }
27692
27693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27694         LDKClosingSignedFeeRange this_obj_conv;
27695         this_obj_conv.inner = (void*)(this_obj & (~1));
27696         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27698         ClosingSignedFeeRange_free(this_obj_conv);
27699 }
27700
27701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27702         LDKClosingSignedFeeRange this_ptr_conv;
27703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27704         this_ptr_conv.is_owned = false;
27705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27706         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
27707         return ret_val;
27708 }
27709
27710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27711         LDKClosingSignedFeeRange this_ptr_conv;
27712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27713         this_ptr_conv.is_owned = false;
27714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27715         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
27716 }
27717
27718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27719         LDKClosingSignedFeeRange this_ptr_conv;
27720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27721         this_ptr_conv.is_owned = false;
27722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27723         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
27724         return ret_val;
27725 }
27726
27727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27728         LDKClosingSignedFeeRange this_ptr_conv;
27729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27730         this_ptr_conv.is_owned = false;
27731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27732         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
27733 }
27734
27735 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) {
27736         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
27737         uint64_t ret_ref = 0;
27738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27741         ret_ref = (uint64_t)ret_var.inner;
27742         if (ret_var.is_owned) {
27743                 ret_ref |= 1;
27744         }
27745         return ret_ref;
27746 }
27747
27748 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
27749         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
27750 uint64_t ret_ref = 0;
27751 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27752 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27753 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27754 ret_ref = (uint64_t)ret_var.inner;
27755 if (ret_var.is_owned) {
27756         ret_ref |= 1;
27757 }
27758         return ret_ref;
27759 }
27760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27761         LDKClosingSignedFeeRange arg_conv;
27762         arg_conv.inner = (void*)(arg & (~1));
27763         arg_conv.is_owned = false;
27764         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27765         int64_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
27766         return ret_val;
27767 }
27768
27769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27770         LDKClosingSignedFeeRange orig_conv;
27771         orig_conv.inner = (void*)(orig & (~1));
27772         orig_conv.is_owned = false;
27773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27774         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
27775         uint64_t ret_ref = 0;
27776         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27777         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27779         ret_ref = (uint64_t)ret_var.inner;
27780         if (ret_var.is_owned) {
27781                 ret_ref |= 1;
27782         }
27783         return ret_ref;
27784 }
27785
27786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27787         LDKClosingSigned this_obj_conv;
27788         this_obj_conv.inner = (void*)(this_obj & (~1));
27789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27791         ClosingSigned_free(this_obj_conv);
27792 }
27793
27794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27795         LDKClosingSigned this_ptr_conv;
27796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27797         this_ptr_conv.is_owned = false;
27798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27799         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27800         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
27801         return ret_arr;
27802 }
27803
27804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27805         LDKClosingSigned this_ptr_conv;
27806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27807         this_ptr_conv.is_owned = false;
27808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27809         LDKThirtyTwoBytes val_ref;
27810         CHECK((*env)->GetArrayLength(env, val) == 32);
27811         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27812         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
27813 }
27814
27815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27816         LDKClosingSigned this_ptr_conv;
27817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27818         this_ptr_conv.is_owned = false;
27819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27820         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
27821         return ret_val;
27822 }
27823
27824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27825         LDKClosingSigned this_ptr_conv;
27826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27827         this_ptr_conv.is_owned = false;
27828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27829         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
27830 }
27831
27832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
27833         LDKClosingSigned this_ptr_conv;
27834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27835         this_ptr_conv.is_owned = false;
27836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27837         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
27838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
27839         return ret_arr;
27840 }
27841
27842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27843         LDKClosingSigned this_ptr_conv;
27844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27845         this_ptr_conv.is_owned = false;
27846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27847         LDKSignature val_ref;
27848         CHECK((*env)->GetArrayLength(env, val) == 64);
27849         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
27850         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
27851 }
27852
27853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
27854         LDKClosingSigned 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         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
27859         uint64_t ret_ref = 0;
27860         if ((uint64_t)ret_var.inner > 4096) {
27861                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27862                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27864                 ret_ref = (uint64_t)ret_var.inner;
27865                 if (ret_var.is_owned) {
27866                         ret_ref |= 1;
27867                 }
27868         }
27869         return ret_ref;
27870 }
27871
27872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27873         LDKClosingSigned this_ptr_conv;
27874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27875         this_ptr_conv.is_owned = false;
27876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27877         LDKClosingSignedFeeRange val_conv;
27878         val_conv.inner = (void*)(val & (~1));
27879         val_conv.is_owned = (val & 1) || (val == 0);
27880         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27881         val_conv = ClosingSignedFeeRange_clone(&val_conv);
27882         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
27883 }
27884
27885 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) {
27886         LDKThirtyTwoBytes channel_id_arg_ref;
27887         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27888         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27889         LDKSignature signature_arg_ref;
27890         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
27891         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
27892         LDKClosingSignedFeeRange fee_range_arg_conv;
27893         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
27894         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
27895         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
27896         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
27897         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
27898         uint64_t ret_ref = 0;
27899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27902         ret_ref = (uint64_t)ret_var.inner;
27903         if (ret_var.is_owned) {
27904                 ret_ref |= 1;
27905         }
27906         return ret_ref;
27907 }
27908
27909 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
27910         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
27911 uint64_t ret_ref = 0;
27912 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27913 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27914 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27915 ret_ref = (uint64_t)ret_var.inner;
27916 if (ret_var.is_owned) {
27917         ret_ref |= 1;
27918 }
27919         return ret_ref;
27920 }
27921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27922         LDKClosingSigned arg_conv;
27923         arg_conv.inner = (void*)(arg & (~1));
27924         arg_conv.is_owned = false;
27925         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27926         int64_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
27927         return ret_val;
27928 }
27929
27930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27931         LDKClosingSigned orig_conv;
27932         orig_conv.inner = (void*)(orig & (~1));
27933         orig_conv.is_owned = false;
27934         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27935         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
27936         uint64_t ret_ref = 0;
27937         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27938         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27940         ret_ref = (uint64_t)ret_var.inner;
27941         if (ret_var.is_owned) {
27942                 ret_ref |= 1;
27943         }
27944         return ret_ref;
27945 }
27946
27947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27948         LDKUpdateAddHTLC this_obj_conv;
27949         this_obj_conv.inner = (void*)(this_obj & (~1));
27950         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27952         UpdateAddHTLC_free(this_obj_conv);
27953 }
27954
27955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27956         LDKUpdateAddHTLC this_ptr_conv;
27957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27958         this_ptr_conv.is_owned = false;
27959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27960         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
27962         return ret_arr;
27963 }
27964
27965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27966         LDKUpdateAddHTLC this_ptr_conv;
27967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27968         this_ptr_conv.is_owned = false;
27969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27970         LDKThirtyTwoBytes val_ref;
27971         CHECK((*env)->GetArrayLength(env, val) == 32);
27972         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27973         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
27974 }
27975
27976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27977         LDKUpdateAddHTLC 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         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
27982         return ret_val;
27983 }
27984
27985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27986         LDKUpdateAddHTLC this_ptr_conv;
27987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27988         this_ptr_conv.is_owned = false;
27989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27990         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
27991 }
27992
27993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27994         LDKUpdateAddHTLC this_ptr_conv;
27995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27996         this_ptr_conv.is_owned = false;
27997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27998         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
27999         return ret_val;
28000 }
28001
28002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28003         LDKUpdateAddHTLC this_ptr_conv;
28004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28005         this_ptr_conv.is_owned = false;
28006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28007         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
28008 }
28009
28010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28011         LDKUpdateAddHTLC this_ptr_conv;
28012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28013         this_ptr_conv.is_owned = false;
28014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28015         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28016         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
28017         return ret_arr;
28018 }
28019
28020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28021         LDKUpdateAddHTLC this_ptr_conv;
28022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28023         this_ptr_conv.is_owned = false;
28024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28025         LDKThirtyTwoBytes val_ref;
28026         CHECK((*env)->GetArrayLength(env, val) == 32);
28027         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28028         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
28029 }
28030
28031 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
28032         LDKUpdateAddHTLC this_ptr_conv;
28033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28034         this_ptr_conv.is_owned = false;
28035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28036         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
28037         return ret_val;
28038 }
28039
28040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28041         LDKUpdateAddHTLC this_ptr_conv;
28042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28043         this_ptr_conv.is_owned = false;
28044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28045         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
28046 }
28047
28048 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
28049         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
28050 uint64_t ret_ref = 0;
28051 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28052 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28053 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28054 ret_ref = (uint64_t)ret_var.inner;
28055 if (ret_var.is_owned) {
28056         ret_ref |= 1;
28057 }
28058         return ret_ref;
28059 }
28060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28061         LDKUpdateAddHTLC arg_conv;
28062         arg_conv.inner = (void*)(arg & (~1));
28063         arg_conv.is_owned = false;
28064         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28065         int64_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
28066         return ret_val;
28067 }
28068
28069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28070         LDKUpdateAddHTLC orig_conv;
28071         orig_conv.inner = (void*)(orig & (~1));
28072         orig_conv.is_owned = false;
28073         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28074         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
28075         uint64_t ret_ref = 0;
28076         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28077         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28079         ret_ref = (uint64_t)ret_var.inner;
28080         if (ret_var.is_owned) {
28081                 ret_ref |= 1;
28082         }
28083         return ret_ref;
28084 }
28085
28086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28087         LDKUpdateFulfillHTLC this_obj_conv;
28088         this_obj_conv.inner = (void*)(this_obj & (~1));
28089         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28091         UpdateFulfillHTLC_free(this_obj_conv);
28092 }
28093
28094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28095         LDKUpdateFulfillHTLC this_ptr_conv;
28096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28097         this_ptr_conv.is_owned = false;
28098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28099         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28100         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
28101         return ret_arr;
28102 }
28103
28104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28105         LDKUpdateFulfillHTLC this_ptr_conv;
28106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28107         this_ptr_conv.is_owned = false;
28108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28109         LDKThirtyTwoBytes val_ref;
28110         CHECK((*env)->GetArrayLength(env, val) == 32);
28111         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28112         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
28113 }
28114
28115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28116         LDKUpdateFulfillHTLC this_ptr_conv;
28117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28118         this_ptr_conv.is_owned = false;
28119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28120         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
28121         return ret_val;
28122 }
28123
28124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28125         LDKUpdateFulfillHTLC this_ptr_conv;
28126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28127         this_ptr_conv.is_owned = false;
28128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28129         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
28130 }
28131
28132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
28133         LDKUpdateFulfillHTLC this_ptr_conv;
28134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28135         this_ptr_conv.is_owned = false;
28136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28137         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28138         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
28139         return ret_arr;
28140 }
28141
28142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28143         LDKUpdateFulfillHTLC this_ptr_conv;
28144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28145         this_ptr_conv.is_owned = false;
28146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28147         LDKThirtyTwoBytes val_ref;
28148         CHECK((*env)->GetArrayLength(env, val) == 32);
28149         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28150         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
28151 }
28152
28153 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) {
28154         LDKThirtyTwoBytes channel_id_arg_ref;
28155         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28156         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28157         LDKThirtyTwoBytes payment_preimage_arg_ref;
28158         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
28159         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
28160         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
28161         uint64_t ret_ref = 0;
28162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28165         ret_ref = (uint64_t)ret_var.inner;
28166         if (ret_var.is_owned) {
28167                 ret_ref |= 1;
28168         }
28169         return ret_ref;
28170 }
28171
28172 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
28173         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
28174 uint64_t ret_ref = 0;
28175 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28176 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28177 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28178 ret_ref = (uint64_t)ret_var.inner;
28179 if (ret_var.is_owned) {
28180         ret_ref |= 1;
28181 }
28182         return ret_ref;
28183 }
28184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28185         LDKUpdateFulfillHTLC arg_conv;
28186         arg_conv.inner = (void*)(arg & (~1));
28187         arg_conv.is_owned = false;
28188         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28189         int64_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
28190         return ret_val;
28191 }
28192
28193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28194         LDKUpdateFulfillHTLC orig_conv;
28195         orig_conv.inner = (void*)(orig & (~1));
28196         orig_conv.is_owned = false;
28197         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28198         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
28199         uint64_t ret_ref = 0;
28200         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28201         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28203         ret_ref = (uint64_t)ret_var.inner;
28204         if (ret_var.is_owned) {
28205                 ret_ref |= 1;
28206         }
28207         return ret_ref;
28208 }
28209
28210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28211         LDKUpdateFailHTLC this_obj_conv;
28212         this_obj_conv.inner = (void*)(this_obj & (~1));
28213         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28215         UpdateFailHTLC_free(this_obj_conv);
28216 }
28217
28218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28219         LDKUpdateFailHTLC this_ptr_conv;
28220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28221         this_ptr_conv.is_owned = false;
28222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28223         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28224         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
28225         return ret_arr;
28226 }
28227
28228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28229         LDKUpdateFailHTLC this_ptr_conv;
28230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28231         this_ptr_conv.is_owned = false;
28232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28233         LDKThirtyTwoBytes val_ref;
28234         CHECK((*env)->GetArrayLength(env, val) == 32);
28235         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28236         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
28237 }
28238
28239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28240         LDKUpdateFailHTLC this_ptr_conv;
28241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28242         this_ptr_conv.is_owned = false;
28243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28244         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
28245         return ret_val;
28246 }
28247
28248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28249         LDKUpdateFailHTLC this_ptr_conv;
28250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28251         this_ptr_conv.is_owned = false;
28252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28253         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
28254 }
28255
28256 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
28257         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
28258 uint64_t ret_ref = 0;
28259 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28260 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28261 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28262 ret_ref = (uint64_t)ret_var.inner;
28263 if (ret_var.is_owned) {
28264         ret_ref |= 1;
28265 }
28266         return ret_ref;
28267 }
28268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28269         LDKUpdateFailHTLC arg_conv;
28270         arg_conv.inner = (void*)(arg & (~1));
28271         arg_conv.is_owned = false;
28272         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28273         int64_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
28274         return ret_val;
28275 }
28276
28277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28278         LDKUpdateFailHTLC orig_conv;
28279         orig_conv.inner = (void*)(orig & (~1));
28280         orig_conv.is_owned = false;
28281         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28282         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
28283         uint64_t ret_ref = 0;
28284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28287         ret_ref = (uint64_t)ret_var.inner;
28288         if (ret_var.is_owned) {
28289                 ret_ref |= 1;
28290         }
28291         return ret_ref;
28292 }
28293
28294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28295         LDKUpdateFailMalformedHTLC this_obj_conv;
28296         this_obj_conv.inner = (void*)(this_obj & (~1));
28297         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28299         UpdateFailMalformedHTLC_free(this_obj_conv);
28300 }
28301
28302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28303         LDKUpdateFailMalformedHTLC this_ptr_conv;
28304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28305         this_ptr_conv.is_owned = false;
28306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28307         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
28309         return ret_arr;
28310 }
28311
28312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28313         LDKUpdateFailMalformedHTLC this_ptr_conv;
28314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28315         this_ptr_conv.is_owned = false;
28316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28317         LDKThirtyTwoBytes val_ref;
28318         CHECK((*env)->GetArrayLength(env, val) == 32);
28319         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28320         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
28321 }
28322
28323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28324         LDKUpdateFailMalformedHTLC this_ptr_conv;
28325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28326         this_ptr_conv.is_owned = false;
28327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28328         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
28329         return ret_val;
28330 }
28331
28332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28333         LDKUpdateFailMalformedHTLC this_ptr_conv;
28334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28335         this_ptr_conv.is_owned = false;
28336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28337         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
28338 }
28339
28340 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
28341         LDKUpdateFailMalformedHTLC this_ptr_conv;
28342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28343         this_ptr_conv.is_owned = false;
28344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28345         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
28346         return ret_val;
28347 }
28348
28349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28350         LDKUpdateFailMalformedHTLC this_ptr_conv;
28351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28352         this_ptr_conv.is_owned = false;
28353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28354         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
28355 }
28356
28357 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
28358         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
28359 uint64_t ret_ref = 0;
28360 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28361 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28362 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28363 ret_ref = (uint64_t)ret_var.inner;
28364 if (ret_var.is_owned) {
28365         ret_ref |= 1;
28366 }
28367         return ret_ref;
28368 }
28369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28370         LDKUpdateFailMalformedHTLC arg_conv;
28371         arg_conv.inner = (void*)(arg & (~1));
28372         arg_conv.is_owned = false;
28373         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28374         int64_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
28375         return ret_val;
28376 }
28377
28378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28379         LDKUpdateFailMalformedHTLC orig_conv;
28380         orig_conv.inner = (void*)(orig & (~1));
28381         orig_conv.is_owned = false;
28382         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28383         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
28384         uint64_t ret_ref = 0;
28385         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28386         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28388         ret_ref = (uint64_t)ret_var.inner;
28389         if (ret_var.is_owned) {
28390                 ret_ref |= 1;
28391         }
28392         return ret_ref;
28393 }
28394
28395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28396         LDKCommitmentSigned this_obj_conv;
28397         this_obj_conv.inner = (void*)(this_obj & (~1));
28398         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28400         CommitmentSigned_free(this_obj_conv);
28401 }
28402
28403 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28404         LDKCommitmentSigned this_ptr_conv;
28405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28406         this_ptr_conv.is_owned = false;
28407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28408         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28409         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
28410         return ret_arr;
28411 }
28412
28413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28414         LDKCommitmentSigned this_ptr_conv;
28415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28416         this_ptr_conv.is_owned = false;
28417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28418         LDKThirtyTwoBytes val_ref;
28419         CHECK((*env)->GetArrayLength(env, val) == 32);
28420         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28421         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
28422 }
28423
28424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
28425         LDKCommitmentSigned this_ptr_conv;
28426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28427         this_ptr_conv.is_owned = false;
28428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28429         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28430         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
28431         return ret_arr;
28432 }
28433
28434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28435         LDKCommitmentSigned this_ptr_conv;
28436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28437         this_ptr_conv.is_owned = false;
28438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28439         LDKSignature val_ref;
28440         CHECK((*env)->GetArrayLength(env, val) == 64);
28441         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28442         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
28443 }
28444
28445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
28446         LDKCommitmentSigned this_ptr_conv;
28447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28448         this_ptr_conv.is_owned = false;
28449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28450         LDKCVec_SignatureZ val_constr;
28451         val_constr.datalen = (*env)->GetArrayLength(env, val);
28452         if (val_constr.datalen > 0)
28453                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28454         else
28455                 val_constr.data = NULL;
28456         for (size_t i = 0; i < val_constr.datalen; i++) {
28457                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
28458                 LDKSignature val_conv_8_ref;
28459                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
28460                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
28461                 val_constr.data[i] = val_conv_8_ref;
28462         }
28463         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
28464 }
28465
28466 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) {
28467         LDKThirtyTwoBytes channel_id_arg_ref;
28468         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28469         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28470         LDKSignature signature_arg_ref;
28471         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
28472         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
28473         LDKCVec_SignatureZ htlc_signatures_arg_constr;
28474         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
28475         if (htlc_signatures_arg_constr.datalen > 0)
28476                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28477         else
28478                 htlc_signatures_arg_constr.data = NULL;
28479         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
28480                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
28481                 LDKSignature htlc_signatures_arg_conv_8_ref;
28482                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
28483                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
28484                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
28485         }
28486         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
28487         uint64_t ret_ref = 0;
28488         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28489         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28491         ret_ref = (uint64_t)ret_var.inner;
28492         if (ret_var.is_owned) {
28493                 ret_ref |= 1;
28494         }
28495         return ret_ref;
28496 }
28497
28498 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
28499         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
28500 uint64_t ret_ref = 0;
28501 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28502 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28503 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28504 ret_ref = (uint64_t)ret_var.inner;
28505 if (ret_var.is_owned) {
28506         ret_ref |= 1;
28507 }
28508         return ret_ref;
28509 }
28510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28511         LDKCommitmentSigned arg_conv;
28512         arg_conv.inner = (void*)(arg & (~1));
28513         arg_conv.is_owned = false;
28514         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28515         int64_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
28516         return ret_val;
28517 }
28518
28519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28520         LDKCommitmentSigned orig_conv;
28521         orig_conv.inner = (void*)(orig & (~1));
28522         orig_conv.is_owned = false;
28523         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28524         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
28525         uint64_t ret_ref = 0;
28526         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28527         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
28530         if (ret_var.is_owned) {
28531                 ret_ref |= 1;
28532         }
28533         return ret_ref;
28534 }
28535
28536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28537         LDKRevokeAndACK this_obj_conv;
28538         this_obj_conv.inner = (void*)(this_obj & (~1));
28539         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28541         RevokeAndACK_free(this_obj_conv);
28542 }
28543
28544 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28545         LDKRevokeAndACK this_ptr_conv;
28546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28547         this_ptr_conv.is_owned = false;
28548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28549         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28550         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
28551         return ret_arr;
28552 }
28553
28554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28555         LDKRevokeAndACK this_ptr_conv;
28556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28557         this_ptr_conv.is_owned = false;
28558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28559         LDKThirtyTwoBytes val_ref;
28560         CHECK((*env)->GetArrayLength(env, val) == 32);
28561         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28562         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
28563 }
28564
28565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
28566         LDKRevokeAndACK this_ptr_conv;
28567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28568         this_ptr_conv.is_owned = false;
28569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28570         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28571         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
28572         return ret_arr;
28573 }
28574
28575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28576         LDKRevokeAndACK this_ptr_conv;
28577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28578         this_ptr_conv.is_owned = false;
28579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28580         LDKThirtyTwoBytes val_ref;
28581         CHECK((*env)->GetArrayLength(env, val) == 32);
28582         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28583         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
28584 }
28585
28586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28587         LDKRevokeAndACK this_ptr_conv;
28588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28589         this_ptr_conv.is_owned = false;
28590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28591         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28592         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
28593         return ret_arr;
28594 }
28595
28596 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) {
28597         LDKRevokeAndACK this_ptr_conv;
28598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28599         this_ptr_conv.is_owned = false;
28600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28601         LDKPublicKey val_ref;
28602         CHECK((*env)->GetArrayLength(env, val) == 33);
28603         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28604         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
28605 }
28606
28607 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) {
28608         LDKThirtyTwoBytes channel_id_arg_ref;
28609         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28610         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28611         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
28612         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
28613         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
28614         LDKPublicKey next_per_commitment_point_arg_ref;
28615         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
28616         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
28617         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
28618         uint64_t ret_ref = 0;
28619         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28620         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28622         ret_ref = (uint64_t)ret_var.inner;
28623         if (ret_var.is_owned) {
28624                 ret_ref |= 1;
28625         }
28626         return ret_ref;
28627 }
28628
28629 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
28630         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
28631 uint64_t ret_ref = 0;
28632 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28633 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28634 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28635 ret_ref = (uint64_t)ret_var.inner;
28636 if (ret_var.is_owned) {
28637         ret_ref |= 1;
28638 }
28639         return ret_ref;
28640 }
28641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28642         LDKRevokeAndACK arg_conv;
28643         arg_conv.inner = (void*)(arg & (~1));
28644         arg_conv.is_owned = false;
28645         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28646         int64_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
28647         return ret_val;
28648 }
28649
28650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28651         LDKRevokeAndACK orig_conv;
28652         orig_conv.inner = (void*)(orig & (~1));
28653         orig_conv.is_owned = false;
28654         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28655         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
28656         uint64_t ret_ref = 0;
28657         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28658         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28660         ret_ref = (uint64_t)ret_var.inner;
28661         if (ret_var.is_owned) {
28662                 ret_ref |= 1;
28663         }
28664         return ret_ref;
28665 }
28666
28667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28668         LDKUpdateFee this_obj_conv;
28669         this_obj_conv.inner = (void*)(this_obj & (~1));
28670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28672         UpdateFee_free(this_obj_conv);
28673 }
28674
28675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28676         LDKUpdateFee this_ptr_conv;
28677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28678         this_ptr_conv.is_owned = false;
28679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28680         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28681         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
28682         return ret_arr;
28683 }
28684
28685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28686         LDKUpdateFee this_ptr_conv;
28687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28688         this_ptr_conv.is_owned = false;
28689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28690         LDKThirtyTwoBytes val_ref;
28691         CHECK((*env)->GetArrayLength(env, val) == 32);
28692         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28693         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
28694 }
28695
28696 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
28697         LDKUpdateFee this_ptr_conv;
28698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28699         this_ptr_conv.is_owned = false;
28700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28701         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
28702         return ret_val;
28703 }
28704
28705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28706         LDKUpdateFee this_ptr_conv;
28707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28708         this_ptr_conv.is_owned = false;
28709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28710         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
28711 }
28712
28713 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) {
28714         LDKThirtyTwoBytes channel_id_arg_ref;
28715         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28716         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28717         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
28718         uint64_t ret_ref = 0;
28719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28722         ret_ref = (uint64_t)ret_var.inner;
28723         if (ret_var.is_owned) {
28724                 ret_ref |= 1;
28725         }
28726         return ret_ref;
28727 }
28728
28729 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
28730         LDKUpdateFee ret_var = UpdateFee_clone(arg);
28731 uint64_t ret_ref = 0;
28732 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28733 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28734 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28735 ret_ref = (uint64_t)ret_var.inner;
28736 if (ret_var.is_owned) {
28737         ret_ref |= 1;
28738 }
28739         return ret_ref;
28740 }
28741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28742         LDKUpdateFee arg_conv;
28743         arg_conv.inner = (void*)(arg & (~1));
28744         arg_conv.is_owned = false;
28745         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28746         int64_t ret_val = UpdateFee_clone_ptr(&arg_conv);
28747         return ret_val;
28748 }
28749
28750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28751         LDKUpdateFee orig_conv;
28752         orig_conv.inner = (void*)(orig & (~1));
28753         orig_conv.is_owned = false;
28754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28755         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
28756         uint64_t ret_ref = 0;
28757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28760         ret_ref = (uint64_t)ret_var.inner;
28761         if (ret_var.is_owned) {
28762                 ret_ref |= 1;
28763         }
28764         return ret_ref;
28765 }
28766
28767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28768         LDKDataLossProtect this_obj_conv;
28769         this_obj_conv.inner = (void*)(this_obj & (~1));
28770         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28772         DataLossProtect_free(this_obj_conv);
28773 }
28774
28775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
28776         LDKDataLossProtect this_ptr_conv;
28777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28778         this_ptr_conv.is_owned = false;
28779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28780         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28781         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
28782         return ret_arr;
28783 }
28784
28785 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) {
28786         LDKDataLossProtect this_ptr_conv;
28787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28788         this_ptr_conv.is_owned = false;
28789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28790         LDKThirtyTwoBytes val_ref;
28791         CHECK((*env)->GetArrayLength(env, val) == 32);
28792         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28793         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
28794 }
28795
28796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28797         LDKDataLossProtect this_ptr_conv;
28798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28799         this_ptr_conv.is_owned = false;
28800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28801         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28802         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
28803         return ret_arr;
28804 }
28805
28806 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) {
28807         LDKDataLossProtect this_ptr_conv;
28808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28809         this_ptr_conv.is_owned = false;
28810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28811         LDKPublicKey val_ref;
28812         CHECK((*env)->GetArrayLength(env, val) == 33);
28813         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28814         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
28815 }
28816
28817 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) {
28818         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
28819         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
28820         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
28821         LDKPublicKey my_current_per_commitment_point_arg_ref;
28822         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
28823         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
28824         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
28825         uint64_t ret_ref = 0;
28826         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28827         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28829         ret_ref = (uint64_t)ret_var.inner;
28830         if (ret_var.is_owned) {
28831                 ret_ref |= 1;
28832         }
28833         return ret_ref;
28834 }
28835
28836 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
28837         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
28838 uint64_t ret_ref = 0;
28839 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28840 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28841 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28842 ret_ref = (uint64_t)ret_var.inner;
28843 if (ret_var.is_owned) {
28844         ret_ref |= 1;
28845 }
28846         return ret_ref;
28847 }
28848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28849         LDKDataLossProtect arg_conv;
28850         arg_conv.inner = (void*)(arg & (~1));
28851         arg_conv.is_owned = false;
28852         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28853         int64_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
28854         return ret_val;
28855 }
28856
28857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28858         LDKDataLossProtect orig_conv;
28859         orig_conv.inner = (void*)(orig & (~1));
28860         orig_conv.is_owned = false;
28861         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28862         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
28863         uint64_t ret_ref = 0;
28864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28867         ret_ref = (uint64_t)ret_var.inner;
28868         if (ret_var.is_owned) {
28869                 ret_ref |= 1;
28870         }
28871         return ret_ref;
28872 }
28873
28874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28875         LDKChannelReestablish this_obj_conv;
28876         this_obj_conv.inner = (void*)(this_obj & (~1));
28877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28879         ChannelReestablish_free(this_obj_conv);
28880 }
28881
28882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28883         LDKChannelReestablish this_ptr_conv;
28884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28885         this_ptr_conv.is_owned = false;
28886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28887         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28888         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
28889         return ret_arr;
28890 }
28891
28892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28893         LDKChannelReestablish this_ptr_conv;
28894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28895         this_ptr_conv.is_owned = false;
28896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28897         LDKThirtyTwoBytes val_ref;
28898         CHECK((*env)->GetArrayLength(env, val) == 32);
28899         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28900         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
28901 }
28902
28903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
28904         LDKChannelReestablish this_ptr_conv;
28905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28906         this_ptr_conv.is_owned = false;
28907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28908         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
28909         return ret_val;
28910 }
28911
28912 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) {
28913         LDKChannelReestablish this_ptr_conv;
28914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28915         this_ptr_conv.is_owned = false;
28916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28917         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
28918 }
28919
28920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
28921         LDKChannelReestablish this_ptr_conv;
28922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28923         this_ptr_conv.is_owned = false;
28924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28925         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
28926         return ret_val;
28927 }
28928
28929 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) {
28930         LDKChannelReestablish this_ptr_conv;
28931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28932         this_ptr_conv.is_owned = false;
28933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28934         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
28935 }
28936
28937 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
28938         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
28939 uint64_t ret_ref = 0;
28940 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28941 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28942 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28943 ret_ref = (uint64_t)ret_var.inner;
28944 if (ret_var.is_owned) {
28945         ret_ref |= 1;
28946 }
28947         return ret_ref;
28948 }
28949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28950         LDKChannelReestablish arg_conv;
28951         arg_conv.inner = (void*)(arg & (~1));
28952         arg_conv.is_owned = false;
28953         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28954         int64_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
28955         return ret_val;
28956 }
28957
28958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28959         LDKChannelReestablish orig_conv;
28960         orig_conv.inner = (void*)(orig & (~1));
28961         orig_conv.is_owned = false;
28962         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28963         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
28964         uint64_t ret_ref = 0;
28965         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28966         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28968         ret_ref = (uint64_t)ret_var.inner;
28969         if (ret_var.is_owned) {
28970                 ret_ref |= 1;
28971         }
28972         return ret_ref;
28973 }
28974
28975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28976         LDKAnnouncementSignatures this_obj_conv;
28977         this_obj_conv.inner = (void*)(this_obj & (~1));
28978         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28980         AnnouncementSignatures_free(this_obj_conv);
28981 }
28982
28983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28984         LDKAnnouncementSignatures this_ptr_conv;
28985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28986         this_ptr_conv.is_owned = false;
28987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28988         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28989         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
28990         return ret_arr;
28991 }
28992
28993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28994         LDKAnnouncementSignatures this_ptr_conv;
28995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28996         this_ptr_conv.is_owned = false;
28997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28998         LDKThirtyTwoBytes val_ref;
28999         CHECK((*env)->GetArrayLength(env, val) == 32);
29000         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29001         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
29002 }
29003
29004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29005         LDKAnnouncementSignatures this_ptr_conv;
29006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29007         this_ptr_conv.is_owned = false;
29008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29009         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
29010         return ret_val;
29011 }
29012
29013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29014         LDKAnnouncementSignatures this_ptr_conv;
29015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29016         this_ptr_conv.is_owned = false;
29017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29018         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
29019 }
29020
29021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
29022         LDKAnnouncementSignatures this_ptr_conv;
29023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29024         this_ptr_conv.is_owned = false;
29025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29026         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
29028         return ret_arr;
29029 }
29030
29031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29032         LDKAnnouncementSignatures this_ptr_conv;
29033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29034         this_ptr_conv.is_owned = false;
29035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29036         LDKSignature val_ref;
29037         CHECK((*env)->GetArrayLength(env, val) == 64);
29038         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29039         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
29040 }
29041
29042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
29043         LDKAnnouncementSignatures this_ptr_conv;
29044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29045         this_ptr_conv.is_owned = false;
29046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29047         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
29049         return ret_arr;
29050 }
29051
29052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29053         LDKAnnouncementSignatures this_ptr_conv;
29054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29055         this_ptr_conv.is_owned = false;
29056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29057         LDKSignature val_ref;
29058         CHECK((*env)->GetArrayLength(env, val) == 64);
29059         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29060         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
29061 }
29062
29063 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) {
29064         LDKThirtyTwoBytes channel_id_arg_ref;
29065         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29066         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29067         LDKSignature node_signature_arg_ref;
29068         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
29069         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
29070         LDKSignature bitcoin_signature_arg_ref;
29071         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
29072         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
29073         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
29074         uint64_t ret_ref = 0;
29075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29078         ret_ref = (uint64_t)ret_var.inner;
29079         if (ret_var.is_owned) {
29080                 ret_ref |= 1;
29081         }
29082         return ret_ref;
29083 }
29084
29085 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
29086         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
29087 uint64_t ret_ref = 0;
29088 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29089 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29090 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29091 ret_ref = (uint64_t)ret_var.inner;
29092 if (ret_var.is_owned) {
29093         ret_ref |= 1;
29094 }
29095         return ret_ref;
29096 }
29097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29098         LDKAnnouncementSignatures arg_conv;
29099         arg_conv.inner = (void*)(arg & (~1));
29100         arg_conv.is_owned = false;
29101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29102         int64_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
29103         return ret_val;
29104 }
29105
29106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29107         LDKAnnouncementSignatures orig_conv;
29108         orig_conv.inner = (void*)(orig & (~1));
29109         orig_conv.is_owned = false;
29110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29111         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
29112         uint64_t ret_ref = 0;
29113         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29114         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29116         ret_ref = (uint64_t)ret_var.inner;
29117         if (ret_var.is_owned) {
29118                 ret_ref |= 1;
29119         }
29120         return ret_ref;
29121 }
29122
29123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29124         if ((this_ptr & 1) != 0) return;
29125         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
29126         CHECK_ACCESS(this_ptr_ptr);
29127         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
29128         FREE((void*)this_ptr);
29129         NetAddress_free(this_ptr_conv);
29130 }
29131
29132 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
29133         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29134         *ret_copy = NetAddress_clone(arg);
29135 uint64_t ret_ref = (uint64_t)ret_copy;
29136         return ret_ref;
29137 }
29138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29139         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
29140         int64_t ret_val = NetAddress_clone_ptr(arg_conv);
29141         return ret_val;
29142 }
29143
29144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29145         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
29146         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29147         *ret_copy = NetAddress_clone(orig_conv);
29148         uint64_t ret_ref = (uint64_t)ret_copy;
29149         return ret_ref;
29150 }
29151
29152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
29153         LDKFourBytes addr_ref;
29154         CHECK((*env)->GetArrayLength(env, addr) == 4);
29155         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
29156         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29157         *ret_copy = NetAddress_ipv4(addr_ref, port);
29158         uint64_t ret_ref = (uint64_t)ret_copy;
29159         return ret_ref;
29160 }
29161
29162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
29163         LDKSixteenBytes addr_ref;
29164         CHECK((*env)->GetArrayLength(env, addr) == 16);
29165         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
29166         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29167         *ret_copy = NetAddress_ipv6(addr_ref, port);
29168         uint64_t ret_ref = (uint64_t)ret_copy;
29169         return ret_ref;
29170 }
29171
29172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
29173         LDKTwelveBytes a_ref;
29174         CHECK((*env)->GetArrayLength(env, a) == 12);
29175         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
29176         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29177         *ret_copy = NetAddress_onion_v2(a_ref);
29178         uint64_t ret_ref = (uint64_t)ret_copy;
29179         return ret_ref;
29180 }
29181
29182 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) {
29183         LDKThirtyTwoBytes ed25519_pubkey_ref;
29184         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
29185         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
29186         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29187         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
29188         uint64_t ret_ref = (uint64_t)ret_copy;
29189         return ret_ref;
29190 }
29191
29192 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
29193         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
29194         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
29195         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29196         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29197         CVec_u8Z_free(ret_var);
29198         return ret_arr;
29199 }
29200
29201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29202         LDKu8slice ser_ref;
29203         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29204         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29205         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
29206         *ret_conv = NetAddress_read(ser_ref);
29207         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29208         return (uint64_t)ret_conv;
29209 }
29210
29211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29212         LDKUnsignedNodeAnnouncement this_obj_conv;
29213         this_obj_conv.inner = (void*)(this_obj & (~1));
29214         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29216         UnsignedNodeAnnouncement_free(this_obj_conv);
29217 }
29218
29219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29220         LDKUnsignedNodeAnnouncement this_ptr_conv;
29221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29222         this_ptr_conv.is_owned = false;
29223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29224         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
29225         uint64_t ret_ref = 0;
29226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29229         ret_ref = (uint64_t)ret_var.inner;
29230         if (ret_var.is_owned) {
29231                 ret_ref |= 1;
29232         }
29233         return ret_ref;
29234 }
29235
29236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29237         LDKUnsignedNodeAnnouncement this_ptr_conv;
29238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29239         this_ptr_conv.is_owned = false;
29240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29241         LDKNodeFeatures val_conv;
29242         val_conv.inner = (void*)(val & (~1));
29243         val_conv.is_owned = (val & 1) || (val == 0);
29244         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29245         val_conv = NodeFeatures_clone(&val_conv);
29246         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
29247 }
29248
29249 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
29250         LDKUnsignedNodeAnnouncement this_ptr_conv;
29251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29252         this_ptr_conv.is_owned = false;
29253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29254         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
29255         return ret_val;
29256 }
29257
29258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29259         LDKUnsignedNodeAnnouncement this_ptr_conv;
29260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29261         this_ptr_conv.is_owned = false;
29262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29263         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
29264 }
29265
29266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29267         LDKUnsignedNodeAnnouncement this_ptr_conv;
29268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29269         this_ptr_conv.is_owned = false;
29270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29271         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29272         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
29273         return ret_arr;
29274 }
29275
29276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29277         LDKUnsignedNodeAnnouncement this_ptr_conv;
29278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29279         this_ptr_conv.is_owned = false;
29280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29281         LDKPublicKey val_ref;
29282         CHECK((*env)->GetArrayLength(env, val) == 33);
29283         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29284         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
29285 }
29286
29287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
29288         LDKUnsignedNodeAnnouncement this_ptr_conv;
29289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29290         this_ptr_conv.is_owned = false;
29291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29292         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
29293         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
29294         return ret_arr;
29295 }
29296
29297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29298         LDKUnsignedNodeAnnouncement this_ptr_conv;
29299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29300         this_ptr_conv.is_owned = false;
29301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29302         LDKThreeBytes val_ref;
29303         CHECK((*env)->GetArrayLength(env, val) == 3);
29304         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
29305         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
29306 }
29307
29308 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29309         LDKUnsignedNodeAnnouncement this_ptr_conv;
29310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29311         this_ptr_conv.is_owned = false;
29312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29313         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29314         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
29315         return ret_arr;
29316 }
29317
29318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29319         LDKUnsignedNodeAnnouncement this_ptr_conv;
29320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29321         this_ptr_conv.is_owned = false;
29322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29323         LDKThirtyTwoBytes val_ref;
29324         CHECK((*env)->GetArrayLength(env, val) == 32);
29325         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29326         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
29327 }
29328
29329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
29330         LDKUnsignedNodeAnnouncement this_ptr_conv;
29331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29332         this_ptr_conv.is_owned = false;
29333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29334         LDKCVec_NetAddressZ val_constr;
29335         val_constr.datalen = (*env)->GetArrayLength(env, val);
29336         if (val_constr.datalen > 0)
29337                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29338         else
29339                 val_constr.data = NULL;
29340         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
29341         for (size_t m = 0; m < val_constr.datalen; m++) {
29342                 int64_t val_conv_12 = val_vals[m];
29343                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
29344                 CHECK_ACCESS(val_conv_12_ptr);
29345                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
29346                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
29347                 val_constr.data[m] = val_conv_12_conv;
29348         }
29349         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
29350         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
29351 }
29352
29353 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
29354         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
29355 uint64_t ret_ref = 0;
29356 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29357 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29358 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29359 ret_ref = (uint64_t)ret_var.inner;
29360 if (ret_var.is_owned) {
29361         ret_ref |= 1;
29362 }
29363         return ret_ref;
29364 }
29365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29366         LDKUnsignedNodeAnnouncement arg_conv;
29367         arg_conv.inner = (void*)(arg & (~1));
29368         arg_conv.is_owned = false;
29369         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29370         int64_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
29371         return ret_val;
29372 }
29373
29374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29375         LDKUnsignedNodeAnnouncement orig_conv;
29376         orig_conv.inner = (void*)(orig & (~1));
29377         orig_conv.is_owned = false;
29378         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29379         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
29380         uint64_t ret_ref = 0;
29381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29384         ret_ref = (uint64_t)ret_var.inner;
29385         if (ret_var.is_owned) {
29386                 ret_ref |= 1;
29387         }
29388         return ret_ref;
29389 }
29390
29391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29392         LDKNodeAnnouncement this_obj_conv;
29393         this_obj_conv.inner = (void*)(this_obj & (~1));
29394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29396         NodeAnnouncement_free(this_obj_conv);
29397 }
29398
29399 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
29400         LDKNodeAnnouncement this_ptr_conv;
29401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29402         this_ptr_conv.is_owned = false;
29403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29404         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29405         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
29406         return ret_arr;
29407 }
29408
29409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29410         LDKNodeAnnouncement this_ptr_conv;
29411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29412         this_ptr_conv.is_owned = false;
29413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29414         LDKSignature val_ref;
29415         CHECK((*env)->GetArrayLength(env, val) == 64);
29416         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29417         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
29418 }
29419
29420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
29421         LDKNodeAnnouncement this_ptr_conv;
29422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29423         this_ptr_conv.is_owned = false;
29424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29425         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
29426         uint64_t ret_ref = 0;
29427         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29428         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29430         ret_ref = (uint64_t)ret_var.inner;
29431         if (ret_var.is_owned) {
29432                 ret_ref |= 1;
29433         }
29434         return ret_ref;
29435 }
29436
29437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29438         LDKNodeAnnouncement this_ptr_conv;
29439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29440         this_ptr_conv.is_owned = false;
29441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29442         LDKUnsignedNodeAnnouncement val_conv;
29443         val_conv.inner = (void*)(val & (~1));
29444         val_conv.is_owned = (val & 1) || (val == 0);
29445         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29446         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
29447         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
29448 }
29449
29450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
29451         LDKSignature signature_arg_ref;
29452         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
29453         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
29454         LDKUnsignedNodeAnnouncement contents_arg_conv;
29455         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29456         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29457         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29458         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
29459         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
29460         uint64_t ret_ref = 0;
29461         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29462         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
29465         if (ret_var.is_owned) {
29466                 ret_ref |= 1;
29467         }
29468         return ret_ref;
29469 }
29470
29471 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
29472         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
29473 uint64_t ret_ref = 0;
29474 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29475 CHECK((((uint64_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 = (uint64_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_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29484         LDKNodeAnnouncement 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 = NodeAnnouncement_clone_ptr(&arg_conv);
29489         return ret_val;
29490 }
29491
29492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29493         LDKNodeAnnouncement 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         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
29498         uint64_t ret_ref = 0;
29499         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29500         CHECK((((uint64_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 = (uint64_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_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29510         LDKUnsignedChannelAnnouncement 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         UnsignedChannelAnnouncement_free(this_obj_conv);
29515 }
29516
29517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29518         LDKUnsignedChannelAnnouncement 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         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
29523         uint64_t ret_ref = 0;
29524         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29525         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29527         ret_ref = (uint64_t)ret_var.inner;
29528         if (ret_var.is_owned) {
29529                 ret_ref |= 1;
29530         }
29531         return ret_ref;
29532 }
29533
29534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29535         LDKUnsignedChannelAnnouncement this_ptr_conv;
29536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29537         this_ptr_conv.is_owned = false;
29538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29539         LDKChannelFeatures val_conv;
29540         val_conv.inner = (void*)(val & (~1));
29541         val_conv.is_owned = (val & 1) || (val == 0);
29542         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29543         val_conv = ChannelFeatures_clone(&val_conv);
29544         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
29545 }
29546
29547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29548         LDKUnsignedChannelAnnouncement this_ptr_conv;
29549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29550         this_ptr_conv.is_owned = false;
29551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29552         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29553         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
29554         return ret_arr;
29555 }
29556
29557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29558         LDKUnsignedChannelAnnouncement this_ptr_conv;
29559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29560         this_ptr_conv.is_owned = false;
29561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29562         LDKThirtyTwoBytes val_ref;
29563         CHECK((*env)->GetArrayLength(env, val) == 32);
29564         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29565         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
29566 }
29567
29568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29569         LDKUnsignedChannelAnnouncement this_ptr_conv;
29570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29571         this_ptr_conv.is_owned = false;
29572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29573         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
29574         return ret_val;
29575 }
29576
29577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29578         LDKUnsignedChannelAnnouncement this_ptr_conv;
29579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29580         this_ptr_conv.is_owned = false;
29581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29582         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
29583 }
29584
29585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
29586         LDKUnsignedChannelAnnouncement this_ptr_conv;
29587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29588         this_ptr_conv.is_owned = false;
29589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29590         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
29592         return ret_arr;
29593 }
29594
29595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29596         LDKUnsignedChannelAnnouncement this_ptr_conv;
29597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29598         this_ptr_conv.is_owned = false;
29599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29600         LDKPublicKey val_ref;
29601         CHECK((*env)->GetArrayLength(env, val) == 33);
29602         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29603         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
29604 }
29605
29606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
29607         LDKUnsignedChannelAnnouncement this_ptr_conv;
29608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29609         this_ptr_conv.is_owned = false;
29610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29611         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29612         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
29613         return ret_arr;
29614 }
29615
29616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29617         LDKUnsignedChannelAnnouncement this_ptr_conv;
29618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29619         this_ptr_conv.is_owned = false;
29620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29621         LDKPublicKey val_ref;
29622         CHECK((*env)->GetArrayLength(env, val) == 33);
29623         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29624         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
29625 }
29626
29627 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
29628         LDKUnsignedChannelAnnouncement this_ptr_conv;
29629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29630         this_ptr_conv.is_owned = false;
29631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29632         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29633         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
29634         return ret_arr;
29635 }
29636
29637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29638         LDKUnsignedChannelAnnouncement this_ptr_conv;
29639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29640         this_ptr_conv.is_owned = false;
29641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29642         LDKPublicKey val_ref;
29643         CHECK((*env)->GetArrayLength(env, val) == 33);
29644         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29645         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
29646 }
29647
29648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
29649         LDKUnsignedChannelAnnouncement this_ptr_conv;
29650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29651         this_ptr_conv.is_owned = false;
29652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29653         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29654         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
29655         return ret_arr;
29656 }
29657
29658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29659         LDKUnsignedChannelAnnouncement this_ptr_conv;
29660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29661         this_ptr_conv.is_owned = false;
29662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29663         LDKPublicKey val_ref;
29664         CHECK((*env)->GetArrayLength(env, val) == 33);
29665         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29666         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
29667 }
29668
29669 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
29670         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
29671 uint64_t ret_ref = 0;
29672 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29673 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29674 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29675 ret_ref = (uint64_t)ret_var.inner;
29676 if (ret_var.is_owned) {
29677         ret_ref |= 1;
29678 }
29679         return ret_ref;
29680 }
29681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29682         LDKUnsignedChannelAnnouncement arg_conv;
29683         arg_conv.inner = (void*)(arg & (~1));
29684         arg_conv.is_owned = false;
29685         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29686         int64_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
29687         return ret_val;
29688 }
29689
29690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29691         LDKUnsignedChannelAnnouncement orig_conv;
29692         orig_conv.inner = (void*)(orig & (~1));
29693         orig_conv.is_owned = false;
29694         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29695         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
29696         uint64_t ret_ref = 0;
29697         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29698         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29700         ret_ref = (uint64_t)ret_var.inner;
29701         if (ret_var.is_owned) {
29702                 ret_ref |= 1;
29703         }
29704         return ret_ref;
29705 }
29706
29707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29708         LDKChannelAnnouncement this_obj_conv;
29709         this_obj_conv.inner = (void*)(this_obj & (~1));
29710         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29712         ChannelAnnouncement_free(this_obj_conv);
29713 }
29714
29715 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
29716         LDKChannelAnnouncement this_ptr_conv;
29717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29718         this_ptr_conv.is_owned = false;
29719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29720         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29721         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
29722         return ret_arr;
29723 }
29724
29725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29726         LDKChannelAnnouncement 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         LDKSignature val_ref;
29731         CHECK((*env)->GetArrayLength(env, val) == 64);
29732         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29733         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
29734 }
29735
29736 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
29737         LDKChannelAnnouncement this_ptr_conv;
29738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29739         this_ptr_conv.is_owned = false;
29740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29741         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29742         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
29743         return ret_arr;
29744 }
29745
29746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29747         LDKChannelAnnouncement this_ptr_conv;
29748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29749         this_ptr_conv.is_owned = false;
29750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29751         LDKSignature val_ref;
29752         CHECK((*env)->GetArrayLength(env, val) == 64);
29753         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29754         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
29755 }
29756
29757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
29758         LDKChannelAnnouncement this_ptr_conv;
29759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29760         this_ptr_conv.is_owned = false;
29761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29762         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29763         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
29764         return ret_arr;
29765 }
29766
29767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29768         LDKChannelAnnouncement this_ptr_conv;
29769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29770         this_ptr_conv.is_owned = false;
29771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29772         LDKSignature val_ref;
29773         CHECK((*env)->GetArrayLength(env, val) == 64);
29774         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29775         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
29776 }
29777
29778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
29779         LDKChannelAnnouncement this_ptr_conv;
29780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29781         this_ptr_conv.is_owned = false;
29782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29783         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29784         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
29785         return ret_arr;
29786 }
29787
29788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29789         LDKChannelAnnouncement this_ptr_conv;
29790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29791         this_ptr_conv.is_owned = false;
29792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29793         LDKSignature val_ref;
29794         CHECK((*env)->GetArrayLength(env, val) == 64);
29795         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29796         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
29797 }
29798
29799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
29800         LDKChannelAnnouncement this_ptr_conv;
29801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29802         this_ptr_conv.is_owned = false;
29803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29804         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
29805         uint64_t ret_ref = 0;
29806         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29807         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29809         ret_ref = (uint64_t)ret_var.inner;
29810         if (ret_var.is_owned) {
29811                 ret_ref |= 1;
29812         }
29813         return ret_ref;
29814 }
29815
29816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29817         LDKChannelAnnouncement this_ptr_conv;
29818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29819         this_ptr_conv.is_owned = false;
29820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29821         LDKUnsignedChannelAnnouncement val_conv;
29822         val_conv.inner = (void*)(val & (~1));
29823         val_conv.is_owned = (val & 1) || (val == 0);
29824         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29825         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
29826         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
29827 }
29828
29829 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) {
29830         LDKSignature node_signature_1_arg_ref;
29831         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
29832         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
29833         LDKSignature node_signature_2_arg_ref;
29834         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
29835         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
29836         LDKSignature bitcoin_signature_1_arg_ref;
29837         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
29838         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
29839         LDKSignature bitcoin_signature_2_arg_ref;
29840         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
29841         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
29842         LDKUnsignedChannelAnnouncement contents_arg_conv;
29843         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29844         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29845         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29846         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
29847         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);
29848         uint64_t ret_ref = 0;
29849         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29850         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29852         ret_ref = (uint64_t)ret_var.inner;
29853         if (ret_var.is_owned) {
29854                 ret_ref |= 1;
29855         }
29856         return ret_ref;
29857 }
29858
29859 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
29860         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
29861 uint64_t ret_ref = 0;
29862 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29863 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29864 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29865 ret_ref = (uint64_t)ret_var.inner;
29866 if (ret_var.is_owned) {
29867         ret_ref |= 1;
29868 }
29869         return ret_ref;
29870 }
29871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29872         LDKChannelAnnouncement arg_conv;
29873         arg_conv.inner = (void*)(arg & (~1));
29874         arg_conv.is_owned = false;
29875         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29876         int64_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
29877         return ret_val;
29878 }
29879
29880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29881         LDKChannelAnnouncement orig_conv;
29882         orig_conv.inner = (void*)(orig & (~1));
29883         orig_conv.is_owned = false;
29884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29885         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
29886         uint64_t ret_ref = 0;
29887         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29888         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29890         ret_ref = (uint64_t)ret_var.inner;
29891         if (ret_var.is_owned) {
29892                 ret_ref |= 1;
29893         }
29894         return ret_ref;
29895 }
29896
29897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29898         LDKUnsignedChannelUpdate this_obj_conv;
29899         this_obj_conv.inner = (void*)(this_obj & (~1));
29900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29902         UnsignedChannelUpdate_free(this_obj_conv);
29903 }
29904
29905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29906         LDKUnsignedChannelUpdate this_ptr_conv;
29907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29908         this_ptr_conv.is_owned = false;
29909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29910         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29911         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
29912         return ret_arr;
29913 }
29914
29915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29916         LDKUnsignedChannelUpdate 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         LDKThirtyTwoBytes val_ref;
29921         CHECK((*env)->GetArrayLength(env, val) == 32);
29922         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29923         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
29924 }
29925
29926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29927         LDKUnsignedChannelUpdate this_ptr_conv;
29928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29929         this_ptr_conv.is_owned = false;
29930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29931         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
29932         return ret_val;
29933 }
29934
29935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29936         LDKUnsignedChannelUpdate this_ptr_conv;
29937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29938         this_ptr_conv.is_owned = false;
29939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29940         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
29941 }
29942
29943 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
29944         LDKUnsignedChannelUpdate this_ptr_conv;
29945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29946         this_ptr_conv.is_owned = false;
29947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29948         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
29949         return ret_val;
29950 }
29951
29952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29953         LDKUnsignedChannelUpdate this_ptr_conv;
29954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29955         this_ptr_conv.is_owned = false;
29956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29957         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
29958 }
29959
29960 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
29961         LDKUnsignedChannelUpdate this_ptr_conv;
29962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29963         this_ptr_conv.is_owned = false;
29964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29965         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
29966         return ret_val;
29967 }
29968
29969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
29970         LDKUnsignedChannelUpdate this_ptr_conv;
29971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29972         this_ptr_conv.is_owned = false;
29973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29974         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
29975 }
29976
29977 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29978         LDKUnsignedChannelUpdate this_ptr_conv;
29979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29980         this_ptr_conv.is_owned = false;
29981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29982         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
29983         return ret_val;
29984 }
29985
29986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29987         LDKUnsignedChannelUpdate this_ptr_conv;
29988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29989         this_ptr_conv.is_owned = false;
29990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29991         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
29992 }
29993
29994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29995         LDKUnsignedChannelUpdate this_ptr_conv;
29996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29997         this_ptr_conv.is_owned = false;
29998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29999         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
30000         return ret_val;
30001 }
30002
30003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30004         LDKUnsignedChannelUpdate this_ptr_conv;
30005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30006         this_ptr_conv.is_owned = false;
30007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30008         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
30009 }
30010
30011 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30012         LDKUnsignedChannelUpdate this_ptr_conv;
30013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30014         this_ptr_conv.is_owned = false;
30015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30016         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
30017         return ret_val;
30018 }
30019
30020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30021         LDKUnsignedChannelUpdate this_ptr_conv;
30022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30023         this_ptr_conv.is_owned = false;
30024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30025         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
30026 }
30027
30028 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
30029         LDKUnsignedChannelUpdate this_ptr_conv;
30030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30031         this_ptr_conv.is_owned = false;
30032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30033         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
30034         return ret_val;
30035 }
30036
30037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30038         LDKUnsignedChannelUpdate this_ptr_conv;
30039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30040         this_ptr_conv.is_owned = false;
30041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30042         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
30043 }
30044
30045 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
30046         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
30047 uint64_t ret_ref = 0;
30048 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30049 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30050 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30051 ret_ref = (uint64_t)ret_var.inner;
30052 if (ret_var.is_owned) {
30053         ret_ref |= 1;
30054 }
30055         return ret_ref;
30056 }
30057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30058         LDKUnsignedChannelUpdate arg_conv;
30059         arg_conv.inner = (void*)(arg & (~1));
30060         arg_conv.is_owned = false;
30061         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30062         int64_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
30063         return ret_val;
30064 }
30065
30066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30067         LDKUnsignedChannelUpdate orig_conv;
30068         orig_conv.inner = (void*)(orig & (~1));
30069         orig_conv.is_owned = false;
30070         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30071         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
30072         uint64_t ret_ref = 0;
30073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30076         ret_ref = (uint64_t)ret_var.inner;
30077         if (ret_var.is_owned) {
30078                 ret_ref |= 1;
30079         }
30080         return ret_ref;
30081 }
30082
30083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30084         LDKChannelUpdate this_obj_conv;
30085         this_obj_conv.inner = (void*)(this_obj & (~1));
30086         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30088         ChannelUpdate_free(this_obj_conv);
30089 }
30090
30091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
30092         LDKChannelUpdate this_ptr_conv;
30093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30094         this_ptr_conv.is_owned = false;
30095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30096         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
30097         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
30098         return ret_arr;
30099 }
30100
30101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30102         LDKChannelUpdate this_ptr_conv;
30103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30104         this_ptr_conv.is_owned = false;
30105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30106         LDKSignature val_ref;
30107         CHECK((*env)->GetArrayLength(env, val) == 64);
30108         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
30109         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
30110 }
30111
30112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
30113         LDKChannelUpdate this_ptr_conv;
30114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30115         this_ptr_conv.is_owned = false;
30116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30117         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
30118         uint64_t ret_ref = 0;
30119         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30120         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30122         ret_ref = (uint64_t)ret_var.inner;
30123         if (ret_var.is_owned) {
30124                 ret_ref |= 1;
30125         }
30126         return ret_ref;
30127 }
30128
30129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30130         LDKChannelUpdate this_ptr_conv;
30131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30132         this_ptr_conv.is_owned = false;
30133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30134         LDKUnsignedChannelUpdate val_conv;
30135         val_conv.inner = (void*)(val & (~1));
30136         val_conv.is_owned = (val & 1) || (val == 0);
30137         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30138         val_conv = UnsignedChannelUpdate_clone(&val_conv);
30139         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
30140 }
30141
30142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
30143         LDKSignature signature_arg_ref;
30144         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
30145         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
30146         LDKUnsignedChannelUpdate contents_arg_conv;
30147         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30148         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30149         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30150         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
30151         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
30152         uint64_t ret_ref = 0;
30153         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30154         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30156         ret_ref = (uint64_t)ret_var.inner;
30157         if (ret_var.is_owned) {
30158                 ret_ref |= 1;
30159         }
30160         return ret_ref;
30161 }
30162
30163 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
30164         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
30165 uint64_t ret_ref = 0;
30166 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30167 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30168 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30169 ret_ref = (uint64_t)ret_var.inner;
30170 if (ret_var.is_owned) {
30171         ret_ref |= 1;
30172 }
30173         return ret_ref;
30174 }
30175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30176         LDKChannelUpdate arg_conv;
30177         arg_conv.inner = (void*)(arg & (~1));
30178         arg_conv.is_owned = false;
30179         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30180         int64_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
30181         return ret_val;
30182 }
30183
30184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30185         LDKChannelUpdate orig_conv;
30186         orig_conv.inner = (void*)(orig & (~1));
30187         orig_conv.is_owned = false;
30188         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30189         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
30190         uint64_t ret_ref = 0;
30191         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30192         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30194         ret_ref = (uint64_t)ret_var.inner;
30195         if (ret_var.is_owned) {
30196                 ret_ref |= 1;
30197         }
30198         return ret_ref;
30199 }
30200
30201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30202         LDKQueryChannelRange this_obj_conv;
30203         this_obj_conv.inner = (void*)(this_obj & (~1));
30204         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30206         QueryChannelRange_free(this_obj_conv);
30207 }
30208
30209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
30210         LDKQueryChannelRange this_ptr_conv;
30211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30212         this_ptr_conv.is_owned = false;
30213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30214         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30215         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
30216         return ret_arr;
30217 }
30218
30219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30220         LDKQueryChannelRange this_ptr_conv;
30221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30222         this_ptr_conv.is_owned = false;
30223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30224         LDKThirtyTwoBytes val_ref;
30225         CHECK((*env)->GetArrayLength(env, val) == 32);
30226         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30227         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30228 }
30229
30230 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
30231         LDKQueryChannelRange this_ptr_conv;
30232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30233         this_ptr_conv.is_owned = false;
30234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30235         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
30236         return ret_val;
30237 }
30238
30239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30240         LDKQueryChannelRange this_ptr_conv;
30241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30242         this_ptr_conv.is_owned = false;
30243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30244         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
30245 }
30246
30247 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
30248         LDKQueryChannelRange this_ptr_conv;
30249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30250         this_ptr_conv.is_owned = false;
30251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30252         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
30253         return ret_val;
30254 }
30255
30256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30257         LDKQueryChannelRange this_ptr_conv;
30258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30259         this_ptr_conv.is_owned = false;
30260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30261         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30262 }
30263
30264 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) {
30265         LDKThirtyTwoBytes chain_hash_arg_ref;
30266         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
30267         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
30268         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
30269         uint64_t ret_ref = 0;
30270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30273         ret_ref = (uint64_t)ret_var.inner;
30274         if (ret_var.is_owned) {
30275                 ret_ref |= 1;
30276         }
30277         return ret_ref;
30278 }
30279
30280 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
30281         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
30282 uint64_t ret_ref = 0;
30283 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30284 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30285 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30286 ret_ref = (uint64_t)ret_var.inner;
30287 if (ret_var.is_owned) {
30288         ret_ref |= 1;
30289 }
30290         return ret_ref;
30291 }
30292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30293         LDKQueryChannelRange arg_conv;
30294         arg_conv.inner = (void*)(arg & (~1));
30295         arg_conv.is_owned = false;
30296         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30297         int64_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
30298         return ret_val;
30299 }
30300
30301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30302         LDKQueryChannelRange orig_conv;
30303         orig_conv.inner = (void*)(orig & (~1));
30304         orig_conv.is_owned = false;
30305         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30306         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
30307         uint64_t ret_ref = 0;
30308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30311         ret_ref = (uint64_t)ret_var.inner;
30312         if (ret_var.is_owned) {
30313                 ret_ref |= 1;
30314         }
30315         return ret_ref;
30316 }
30317
30318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30319         LDKReplyChannelRange this_obj_conv;
30320         this_obj_conv.inner = (void*)(this_obj & (~1));
30321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30323         ReplyChannelRange_free(this_obj_conv);
30324 }
30325
30326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
30327         LDKReplyChannelRange this_ptr_conv;
30328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30329         this_ptr_conv.is_owned = false;
30330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30331         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30332         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
30333         return ret_arr;
30334 }
30335
30336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30337         LDKReplyChannelRange this_ptr_conv;
30338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30339         this_ptr_conv.is_owned = false;
30340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30341         LDKThirtyTwoBytes val_ref;
30342         CHECK((*env)->GetArrayLength(env, val) == 32);
30343         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30344         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30345 }
30346
30347 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
30348         LDKReplyChannelRange this_ptr_conv;
30349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30350         this_ptr_conv.is_owned = false;
30351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30352         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
30353         return ret_val;
30354 }
30355
30356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30357         LDKReplyChannelRange this_ptr_conv;
30358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30359         this_ptr_conv.is_owned = false;
30360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30361         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
30362 }
30363
30364 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
30365         LDKReplyChannelRange this_ptr_conv;
30366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30367         this_ptr_conv.is_owned = false;
30368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30369         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
30370         return ret_val;
30371 }
30372
30373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30374         LDKReplyChannelRange this_ptr_conv;
30375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30376         this_ptr_conv.is_owned = false;
30377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30378         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30379 }
30380
30381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
30382         LDKReplyChannelRange this_ptr_conv;
30383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30384         this_ptr_conv.is_owned = false;
30385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30386         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
30387         return ret_val;
30388 }
30389
30390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30391         LDKReplyChannelRange this_ptr_conv;
30392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30393         this_ptr_conv.is_owned = false;
30394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30395         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
30396 }
30397
30398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30399         LDKReplyChannelRange this_ptr_conv;
30400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30401         this_ptr_conv.is_owned = false;
30402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30403         LDKCVec_u64Z val_constr;
30404         val_constr.datalen = (*env)->GetArrayLength(env, val);
30405         if (val_constr.datalen > 0)
30406                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30407         else
30408                 val_constr.data = NULL;
30409         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30410         for (size_t g = 0; g < val_constr.datalen; g++) {
30411                 int64_t val_conv_6 = val_vals[g];
30412                 val_constr.data[g] = val_conv_6;
30413         }
30414         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30415         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
30416 }
30417
30418 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) {
30419         LDKThirtyTwoBytes chain_hash_arg_ref;
30420         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
30421         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
30422         LDKCVec_u64Z short_channel_ids_arg_constr;
30423         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
30424         if (short_channel_ids_arg_constr.datalen > 0)
30425                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30426         else
30427                 short_channel_ids_arg_constr.data = NULL;
30428         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
30429         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
30430                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
30431                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
30432         }
30433         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
30434         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
30435         uint64_t ret_ref = 0;
30436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30439         ret_ref = (uint64_t)ret_var.inner;
30440         if (ret_var.is_owned) {
30441                 ret_ref |= 1;
30442         }
30443         return ret_ref;
30444 }
30445
30446 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
30447         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
30448 uint64_t ret_ref = 0;
30449 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30450 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30451 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30452 ret_ref = (uint64_t)ret_var.inner;
30453 if (ret_var.is_owned) {
30454         ret_ref |= 1;
30455 }
30456         return ret_ref;
30457 }
30458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30459         LDKReplyChannelRange arg_conv;
30460         arg_conv.inner = (void*)(arg & (~1));
30461         arg_conv.is_owned = false;
30462         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30463         int64_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
30464         return ret_val;
30465 }
30466
30467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30468         LDKReplyChannelRange orig_conv;
30469         orig_conv.inner = (void*)(orig & (~1));
30470         orig_conv.is_owned = false;
30471         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30472         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
30473         uint64_t ret_ref = 0;
30474         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30475         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30477         ret_ref = (uint64_t)ret_var.inner;
30478         if (ret_var.is_owned) {
30479                 ret_ref |= 1;
30480         }
30481         return ret_ref;
30482 }
30483
30484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30485         LDKQueryShortChannelIds this_obj_conv;
30486         this_obj_conv.inner = (void*)(this_obj & (~1));
30487         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30489         QueryShortChannelIds_free(this_obj_conv);
30490 }
30491
30492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
30493         LDKQueryShortChannelIds 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, 32);
30498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
30499         return ret_arr;
30500 }
30501
30502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30503         LDKQueryShortChannelIds 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         LDKThirtyTwoBytes val_ref;
30508         CHECK((*env)->GetArrayLength(env, val) == 32);
30509         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30510         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
30511 }
30512
30513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30514         LDKQueryShortChannelIds 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         LDKCVec_u64Z val_constr;
30519         val_constr.datalen = (*env)->GetArrayLength(env, val);
30520         if (val_constr.datalen > 0)
30521                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30522         else
30523                 val_constr.data = NULL;
30524         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30525         for (size_t g = 0; g < val_constr.datalen; g++) {
30526                 int64_t val_conv_6 = val_vals[g];
30527                 val_constr.data[g] = val_conv_6;
30528         }
30529         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30530         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
30531 }
30532
30533 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) {
30534         LDKThirtyTwoBytes chain_hash_arg_ref;
30535         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
30536         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
30537         LDKCVec_u64Z short_channel_ids_arg_constr;
30538         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
30539         if (short_channel_ids_arg_constr.datalen > 0)
30540                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30541         else
30542                 short_channel_ids_arg_constr.data = NULL;
30543         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
30544         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
30545                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
30546                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
30547         }
30548         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
30549         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
30550         uint64_t ret_ref = 0;
30551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30554         ret_ref = (uint64_t)ret_var.inner;
30555         if (ret_var.is_owned) {
30556                 ret_ref |= 1;
30557         }
30558         return ret_ref;
30559 }
30560
30561 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
30562         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
30563 uint64_t ret_ref = 0;
30564 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30565 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30566 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30567 ret_ref = (uint64_t)ret_var.inner;
30568 if (ret_var.is_owned) {
30569         ret_ref |= 1;
30570 }
30571         return ret_ref;
30572 }
30573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30574         LDKQueryShortChannelIds arg_conv;
30575         arg_conv.inner = (void*)(arg & (~1));
30576         arg_conv.is_owned = false;
30577         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30578         int64_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
30579         return ret_val;
30580 }
30581
30582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30583         LDKQueryShortChannelIds orig_conv;
30584         orig_conv.inner = (void*)(orig & (~1));
30585         orig_conv.is_owned = false;
30586         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30587         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
30588         uint64_t ret_ref = 0;
30589         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30590         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30592         ret_ref = (uint64_t)ret_var.inner;
30593         if (ret_var.is_owned) {
30594                 ret_ref |= 1;
30595         }
30596         return ret_ref;
30597 }
30598
30599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30600         LDKReplyShortChannelIdsEnd this_obj_conv;
30601         this_obj_conv.inner = (void*)(this_obj & (~1));
30602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30604         ReplyShortChannelIdsEnd_free(this_obj_conv);
30605 }
30606
30607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
30608         LDKReplyShortChannelIdsEnd this_ptr_conv;
30609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30610         this_ptr_conv.is_owned = false;
30611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30612         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30613         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
30614         return ret_arr;
30615 }
30616
30617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30618         LDKReplyShortChannelIdsEnd this_ptr_conv;
30619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30620         this_ptr_conv.is_owned = false;
30621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30622         LDKThirtyTwoBytes val_ref;
30623         CHECK((*env)->GetArrayLength(env, val) == 32);
30624         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30625         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
30626 }
30627
30628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
30629         LDKReplyShortChannelIdsEnd this_ptr_conv;
30630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30631         this_ptr_conv.is_owned = false;
30632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30633         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
30634         return ret_val;
30635 }
30636
30637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30638         LDKReplyShortChannelIdsEnd this_ptr_conv;
30639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30640         this_ptr_conv.is_owned = false;
30641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30642         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
30643 }
30644
30645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
30646         LDKThirtyTwoBytes chain_hash_arg_ref;
30647         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
30648         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
30649         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
30650         uint64_t ret_ref = 0;
30651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30654         ret_ref = (uint64_t)ret_var.inner;
30655         if (ret_var.is_owned) {
30656                 ret_ref |= 1;
30657         }
30658         return ret_ref;
30659 }
30660
30661 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
30662         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
30663 uint64_t ret_ref = 0;
30664 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30665 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30666 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30667 ret_ref = (uint64_t)ret_var.inner;
30668 if (ret_var.is_owned) {
30669         ret_ref |= 1;
30670 }
30671         return ret_ref;
30672 }
30673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30674         LDKReplyShortChannelIdsEnd arg_conv;
30675         arg_conv.inner = (void*)(arg & (~1));
30676         arg_conv.is_owned = false;
30677         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30678         int64_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
30679         return ret_val;
30680 }
30681
30682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30683         LDKReplyShortChannelIdsEnd orig_conv;
30684         orig_conv.inner = (void*)(orig & (~1));
30685         orig_conv.is_owned = false;
30686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30687         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
30688         uint64_t ret_ref = 0;
30689         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30690         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30692         ret_ref = (uint64_t)ret_var.inner;
30693         if (ret_var.is_owned) {
30694                 ret_ref |= 1;
30695         }
30696         return ret_ref;
30697 }
30698
30699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30700         LDKGossipTimestampFilter this_obj_conv;
30701         this_obj_conv.inner = (void*)(this_obj & (~1));
30702         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30704         GossipTimestampFilter_free(this_obj_conv);
30705 }
30706
30707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
30708         LDKGossipTimestampFilter this_ptr_conv;
30709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30710         this_ptr_conv.is_owned = false;
30711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30712         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
30714         return ret_arr;
30715 }
30716
30717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30718         LDKGossipTimestampFilter this_ptr_conv;
30719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30720         this_ptr_conv.is_owned = false;
30721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30722         LDKThirtyTwoBytes val_ref;
30723         CHECK((*env)->GetArrayLength(env, val) == 32);
30724         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30725         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
30726 }
30727
30728 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
30729         LDKGossipTimestampFilter this_ptr_conv;
30730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30731         this_ptr_conv.is_owned = false;
30732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30733         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
30734         return ret_val;
30735 }
30736
30737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30738         LDKGossipTimestampFilter this_ptr_conv;
30739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30740         this_ptr_conv.is_owned = false;
30741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30742         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
30743 }
30744
30745 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
30746         LDKGossipTimestampFilter this_ptr_conv;
30747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30748         this_ptr_conv.is_owned = false;
30749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30750         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
30751         return ret_val;
30752 }
30753
30754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30755         LDKGossipTimestampFilter this_ptr_conv;
30756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30757         this_ptr_conv.is_owned = false;
30758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30759         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
30760 }
30761
30762 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) {
30763         LDKThirtyTwoBytes chain_hash_arg_ref;
30764         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
30765         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
30766         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
30767         uint64_t ret_ref = 0;
30768         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30769         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30771         ret_ref = (uint64_t)ret_var.inner;
30772         if (ret_var.is_owned) {
30773                 ret_ref |= 1;
30774         }
30775         return ret_ref;
30776 }
30777
30778 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
30779         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
30780 uint64_t ret_ref = 0;
30781 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30782 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30783 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30784 ret_ref = (uint64_t)ret_var.inner;
30785 if (ret_var.is_owned) {
30786         ret_ref |= 1;
30787 }
30788         return ret_ref;
30789 }
30790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30791         LDKGossipTimestampFilter arg_conv;
30792         arg_conv.inner = (void*)(arg & (~1));
30793         arg_conv.is_owned = false;
30794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30795         int64_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
30796         return ret_val;
30797 }
30798
30799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30800         LDKGossipTimestampFilter orig_conv;
30801         orig_conv.inner = (void*)(orig & (~1));
30802         orig_conv.is_owned = false;
30803         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30804         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
30805         uint64_t ret_ref = 0;
30806         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30807         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30809         ret_ref = (uint64_t)ret_var.inner;
30810         if (ret_var.is_owned) {
30811                 ret_ref |= 1;
30812         }
30813         return ret_ref;
30814 }
30815
30816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30817         if ((this_ptr & 1) != 0) return;
30818         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30819         CHECK_ACCESS(this_ptr_ptr);
30820         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
30821         FREE((void*)this_ptr);
30822         ErrorAction_free(this_ptr_conv);
30823 }
30824
30825 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
30826         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30827         *ret_copy = ErrorAction_clone(arg);
30828 uint64_t ret_ref = (uint64_t)ret_copy;
30829         return ret_ref;
30830 }
30831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30832         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
30833         int64_t ret_val = ErrorAction_clone_ptr(arg_conv);
30834         return ret_val;
30835 }
30836
30837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30838         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
30839         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30840         *ret_copy = ErrorAction_clone(orig_conv);
30841         uint64_t ret_ref = (uint64_t)ret_copy;
30842         return ret_ref;
30843 }
30844
30845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
30846         LDKErrorMessage msg_conv;
30847         msg_conv.inner = (void*)(msg & (~1));
30848         msg_conv.is_owned = (msg & 1) || (msg == 0);
30849         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30850         msg_conv = ErrorMessage_clone(&msg_conv);
30851         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30852         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
30853         uint64_t ret_ref = (uint64_t)ret_copy;
30854         return ret_ref;
30855 }
30856
30857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
30858         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30859         *ret_copy = ErrorAction_ignore_error();
30860         uint64_t ret_ref = (uint64_t)ret_copy;
30861         return ret_ref;
30862 }
30863
30864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
30865         LDKLevel a_conv = LDKLevel_from_java(env, a);
30866         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30867         *ret_copy = ErrorAction_ignore_and_log(a_conv);
30868         uint64_t ret_ref = (uint64_t)ret_copy;
30869         return ret_ref;
30870 }
30871
30872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
30873         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30874         *ret_copy = ErrorAction_ignore_duplicate_gossip();
30875         uint64_t ret_ref = (uint64_t)ret_copy;
30876         return ret_ref;
30877 }
30878
30879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
30880         LDKErrorMessage msg_conv;
30881         msg_conv.inner = (void*)(msg & (~1));
30882         msg_conv.is_owned = (msg & 1) || (msg == 0);
30883         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30884         msg_conv = ErrorMessage_clone(&msg_conv);
30885         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30886         *ret_copy = ErrorAction_send_error_message(msg_conv);
30887         uint64_t ret_ref = (uint64_t)ret_copy;
30888         return ret_ref;
30889 }
30890
30891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30892         LDKLightningError this_obj_conv;
30893         this_obj_conv.inner = (void*)(this_obj & (~1));
30894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30896         LightningError_free(this_obj_conv);
30897 }
30898
30899 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
30900         LDKLightningError this_ptr_conv;
30901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30902         this_ptr_conv.is_owned = false;
30903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30904         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
30905         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30906         Str_free(ret_str);
30907         return ret_conv;
30908 }
30909
30910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30911         LDKLightningError this_ptr_conv;
30912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30913         this_ptr_conv.is_owned = false;
30914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30915         LDKStr val_conv = java_to_owned_str(env, val);
30916         LightningError_set_err(&this_ptr_conv, val_conv);
30917 }
30918
30919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
30920         LDKLightningError 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         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30925         *ret_copy = LightningError_get_action(&this_ptr_conv);
30926         uint64_t ret_ref = (uint64_t)ret_copy;
30927         return ret_ref;
30928 }
30929
30930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30931         LDKLightningError 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         void* val_ptr = (void*)(((uint64_t)val) & ~1);
30936         CHECK_ACCESS(val_ptr);
30937         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
30938         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
30939         LightningError_set_action(&this_ptr_conv, val_conv);
30940 }
30941
30942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
30943         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
30944         void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
30945         CHECK_ACCESS(action_arg_ptr);
30946         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
30947         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
30948         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
30949         uint64_t ret_ref = 0;
30950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30953         ret_ref = (uint64_t)ret_var.inner;
30954         if (ret_var.is_owned) {
30955                 ret_ref |= 1;
30956         }
30957         return ret_ref;
30958 }
30959
30960 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
30961         LDKLightningError ret_var = LightningError_clone(arg);
30962 uint64_t ret_ref = 0;
30963 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30964 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30965 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30966 ret_ref = (uint64_t)ret_var.inner;
30967 if (ret_var.is_owned) {
30968         ret_ref |= 1;
30969 }
30970         return ret_ref;
30971 }
30972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30973         LDKLightningError arg_conv;
30974         arg_conv.inner = (void*)(arg & (~1));
30975         arg_conv.is_owned = false;
30976         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30977         int64_t ret_val = LightningError_clone_ptr(&arg_conv);
30978         return ret_val;
30979 }
30980
30981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30982         LDKLightningError orig_conv;
30983         orig_conv.inner = (void*)(orig & (~1));
30984         orig_conv.is_owned = false;
30985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30986         LDKLightningError ret_var = LightningError_clone(&orig_conv);
30987         uint64_t ret_ref = 0;
30988         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30989         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30991         ret_ref = (uint64_t)ret_var.inner;
30992         if (ret_var.is_owned) {
30993                 ret_ref |= 1;
30994         }
30995         return ret_ref;
30996 }
30997
30998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30999         LDKCommitmentUpdate this_obj_conv;
31000         this_obj_conv.inner = (void*)(this_obj & (~1));
31001         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31003         CommitmentUpdate_free(this_obj_conv);
31004 }
31005
31006 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31007         LDKCommitmentUpdate this_ptr_conv;
31008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31009         this_ptr_conv.is_owned = false;
31010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31011         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
31012         int64_tArray ret_arr = NULL;
31013         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31014         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31015         for (size_t p = 0; p < ret_var.datalen; p++) {
31016                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
31017                 uint64_t ret_conv_15_ref = 0;
31018                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31019                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31020                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
31021                 ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
31022                 if (ret_conv_15_var.is_owned) {
31023                         ret_conv_15_ref |= 1;
31024                 }
31025                 ret_arr_ptr[p] = ret_conv_15_ref;
31026         }
31027         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31028         FREE(ret_var.data);
31029         return ret_arr;
31030 }
31031
31032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
31033         LDKCommitmentUpdate this_ptr_conv;
31034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31035         this_ptr_conv.is_owned = false;
31036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31037         LDKCVec_UpdateAddHTLCZ val_constr;
31038         val_constr.datalen = (*env)->GetArrayLength(env, val);
31039         if (val_constr.datalen > 0)
31040                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31041         else
31042                 val_constr.data = NULL;
31043         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31044         for (size_t p = 0; p < val_constr.datalen; p++) {
31045                 int64_t val_conv_15 = val_vals[p];
31046                 LDKUpdateAddHTLC val_conv_15_conv;
31047                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
31048                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
31049                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
31050                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
31051                 val_constr.data[p] = val_conv_15_conv;
31052         }
31053         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31054         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
31055 }
31056
31057 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31058         LDKCommitmentUpdate this_ptr_conv;
31059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31060         this_ptr_conv.is_owned = false;
31061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31062         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
31063         int64_tArray ret_arr = NULL;
31064         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31065         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31066         for (size_t t = 0; t < ret_var.datalen; t++) {
31067                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
31068                 uint64_t ret_conv_19_ref = 0;
31069                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31070                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31071                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
31072                 ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
31073                 if (ret_conv_19_var.is_owned) {
31074                         ret_conv_19_ref |= 1;
31075                 }
31076                 ret_arr_ptr[t] = ret_conv_19_ref;
31077         }
31078         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31079         FREE(ret_var.data);
31080         return ret_arr;
31081 }
31082
31083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
31084         LDKCommitmentUpdate this_ptr_conv;
31085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31086         this_ptr_conv.is_owned = false;
31087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31088         LDKCVec_UpdateFulfillHTLCZ val_constr;
31089         val_constr.datalen = (*env)->GetArrayLength(env, val);
31090         if (val_constr.datalen > 0)
31091                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31092         else
31093                 val_constr.data = NULL;
31094         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31095         for (size_t t = 0; t < val_constr.datalen; t++) {
31096                 int64_t val_conv_19 = val_vals[t];
31097                 LDKUpdateFulfillHTLC val_conv_19_conv;
31098                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
31099                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
31100                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
31101                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
31102                 val_constr.data[t] = val_conv_19_conv;
31103         }
31104         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31105         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
31106 }
31107
31108 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31109         LDKCommitmentUpdate this_ptr_conv;
31110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31111         this_ptr_conv.is_owned = false;
31112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31113         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
31114         int64_tArray ret_arr = NULL;
31115         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31116         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31117         for (size_t q = 0; q < ret_var.datalen; q++) {
31118                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
31119                 uint64_t ret_conv_16_ref = 0;
31120                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31121                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31122                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31123                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
31124                 if (ret_conv_16_var.is_owned) {
31125                         ret_conv_16_ref |= 1;
31126                 }
31127                 ret_arr_ptr[q] = ret_conv_16_ref;
31128         }
31129         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31130         FREE(ret_var.data);
31131         return ret_arr;
31132 }
31133
31134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
31135         LDKCommitmentUpdate this_ptr_conv;
31136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31137         this_ptr_conv.is_owned = false;
31138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31139         LDKCVec_UpdateFailHTLCZ val_constr;
31140         val_constr.datalen = (*env)->GetArrayLength(env, val);
31141         if (val_constr.datalen > 0)
31142                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31143         else
31144                 val_constr.data = NULL;
31145         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31146         for (size_t q = 0; q < val_constr.datalen; q++) {
31147                 int64_t val_conv_16 = val_vals[q];
31148                 LDKUpdateFailHTLC val_conv_16_conv;
31149                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
31150                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
31151                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
31152                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
31153                 val_constr.data[q] = val_conv_16_conv;
31154         }
31155         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31156         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
31157 }
31158
31159 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31160         LDKCommitmentUpdate this_ptr_conv;
31161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31162         this_ptr_conv.is_owned = false;
31163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31164         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
31165         int64_tArray ret_arr = NULL;
31166         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31167         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31168         for (size_t z = 0; z < ret_var.datalen; z++) {
31169                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
31170                 uint64_t ret_conv_25_ref = 0;
31171                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31172                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31173                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
31174                 ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
31175                 if (ret_conv_25_var.is_owned) {
31176                         ret_conv_25_ref |= 1;
31177                 }
31178                 ret_arr_ptr[z] = ret_conv_25_ref;
31179         }
31180         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31181         FREE(ret_var.data);
31182         return ret_arr;
31183 }
31184
31185 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) {
31186         LDKCommitmentUpdate this_ptr_conv;
31187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31188         this_ptr_conv.is_owned = false;
31189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31190         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
31191         val_constr.datalen = (*env)->GetArrayLength(env, val);
31192         if (val_constr.datalen > 0)
31193                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31194         else
31195                 val_constr.data = NULL;
31196         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31197         for (size_t z = 0; z < val_constr.datalen; z++) {
31198                 int64_t val_conv_25 = val_vals[z];
31199                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
31200                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
31201                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
31202                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
31203                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
31204                 val_constr.data[z] = val_conv_25_conv;
31205         }
31206         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31207         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
31208 }
31209
31210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
31211         LDKCommitmentUpdate this_ptr_conv;
31212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31213         this_ptr_conv.is_owned = false;
31214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31215         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
31216         uint64_t ret_ref = 0;
31217         if ((uint64_t)ret_var.inner > 4096) {
31218                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31219                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31221                 ret_ref = (uint64_t)ret_var.inner;
31222                 if (ret_var.is_owned) {
31223                         ret_ref |= 1;
31224                 }
31225         }
31226         return ret_ref;
31227 }
31228
31229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31230         LDKCommitmentUpdate 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         LDKUpdateFee val_conv;
31235         val_conv.inner = (void*)(val & (~1));
31236         val_conv.is_owned = (val & 1) || (val == 0);
31237         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31238         val_conv = UpdateFee_clone(&val_conv);
31239         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
31240 }
31241
31242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
31243         LDKCommitmentUpdate this_ptr_conv;
31244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31245         this_ptr_conv.is_owned = false;
31246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31247         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
31248         uint64_t ret_ref = 0;
31249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31252         ret_ref = (uint64_t)ret_var.inner;
31253         if (ret_var.is_owned) {
31254                 ret_ref |= 1;
31255         }
31256         return ret_ref;
31257 }
31258
31259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31260         LDKCommitmentUpdate this_ptr_conv;
31261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31262         this_ptr_conv.is_owned = false;
31263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31264         LDKCommitmentSigned val_conv;
31265         val_conv.inner = (void*)(val & (~1));
31266         val_conv.is_owned = (val & 1) || (val == 0);
31267         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31268         val_conv = CommitmentSigned_clone(&val_conv);
31269         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
31270 }
31271
31272 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) {
31273         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
31274         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
31275         if (update_add_htlcs_arg_constr.datalen > 0)
31276                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31277         else
31278                 update_add_htlcs_arg_constr.data = NULL;
31279         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
31280         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
31281                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
31282                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
31283                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
31284                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
31285                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
31286                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
31287                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
31288         }
31289         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
31290         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
31291         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
31292         if (update_fulfill_htlcs_arg_constr.datalen > 0)
31293                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31294         else
31295                 update_fulfill_htlcs_arg_constr.data = NULL;
31296         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
31297         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
31298                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
31299                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
31300                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
31301                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
31302                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
31303                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
31304                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
31305         }
31306         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
31307         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
31308         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
31309         if (update_fail_htlcs_arg_constr.datalen > 0)
31310                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31311         else
31312                 update_fail_htlcs_arg_constr.data = NULL;
31313         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
31314         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
31315                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
31316                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
31317                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
31318                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
31319                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
31320                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
31321                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
31322         }
31323         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
31324         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
31325         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
31326         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
31327                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31328         else
31329                 update_fail_malformed_htlcs_arg_constr.data = NULL;
31330         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
31331         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
31332                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
31333                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
31334                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
31335                 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);
31336                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
31337                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
31338                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
31339         }
31340         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
31341         LDKUpdateFee update_fee_arg_conv;
31342         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
31343         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
31345         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
31346         LDKCommitmentSigned commitment_signed_arg_conv;
31347         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
31348         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
31349         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
31350         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
31351         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);
31352         uint64_t ret_ref = 0;
31353         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31354         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31356         ret_ref = (uint64_t)ret_var.inner;
31357         if (ret_var.is_owned) {
31358                 ret_ref |= 1;
31359         }
31360         return ret_ref;
31361 }
31362
31363 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
31364         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
31365 uint64_t ret_ref = 0;
31366 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31367 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31368 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31369 ret_ref = (uint64_t)ret_var.inner;
31370 if (ret_var.is_owned) {
31371         ret_ref |= 1;
31372 }
31373         return ret_ref;
31374 }
31375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31376         LDKCommitmentUpdate arg_conv;
31377         arg_conv.inner = (void*)(arg & (~1));
31378         arg_conv.is_owned = false;
31379         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31380         int64_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
31381         return ret_val;
31382 }
31383
31384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31385         LDKCommitmentUpdate orig_conv;
31386         orig_conv.inner = (void*)(orig & (~1));
31387         orig_conv.is_owned = false;
31388         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31389         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
31390         uint64_t ret_ref = 0;
31391         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31392         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31394         ret_ref = (uint64_t)ret_var.inner;
31395         if (ret_var.is_owned) {
31396                 ret_ref |= 1;
31397         }
31398         return ret_ref;
31399 }
31400
31401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31402         if ((this_ptr & 1) != 0) return;
31403         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31404         CHECK_ACCESS(this_ptr_ptr);
31405         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
31406         FREE((void*)this_ptr);
31407         ChannelMessageHandler_free(this_ptr_conv);
31408 }
31409
31410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31411         if ((this_ptr & 1) != 0) return;
31412         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31413         CHECK_ACCESS(this_ptr_ptr);
31414         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
31415         FREE((void*)this_ptr);
31416         RoutingMessageHandler_free(this_ptr_conv);
31417 }
31418
31419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
31420         LDKAcceptChannel obj_conv;
31421         obj_conv.inner = (void*)(obj & (~1));
31422         obj_conv.is_owned = false;
31423         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31424         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
31425         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31426         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31427         CVec_u8Z_free(ret_var);
31428         return ret_arr;
31429 }
31430
31431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31432         LDKu8slice ser_ref;
31433         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31434         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31435         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
31436         *ret_conv = AcceptChannel_read(ser_ref);
31437         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31438         return (uint64_t)ret_conv;
31439 }
31440
31441 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
31442         LDKAnnouncementSignatures obj_conv;
31443         obj_conv.inner = (void*)(obj & (~1));
31444         obj_conv.is_owned = false;
31445         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31446         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
31447         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31448         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31449         CVec_u8Z_free(ret_var);
31450         return ret_arr;
31451 }
31452
31453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31454         LDKu8slice ser_ref;
31455         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31456         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31457         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
31458         *ret_conv = AnnouncementSignatures_read(ser_ref);
31459         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31460         return (uint64_t)ret_conv;
31461 }
31462
31463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
31464         LDKChannelReestablish obj_conv;
31465         obj_conv.inner = (void*)(obj & (~1));
31466         obj_conv.is_owned = false;
31467         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31468         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
31469         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31470         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31471         CVec_u8Z_free(ret_var);
31472         return ret_arr;
31473 }
31474
31475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31476         LDKu8slice ser_ref;
31477         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31478         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31479         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
31480         *ret_conv = ChannelReestablish_read(ser_ref);
31481         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31482         return (uint64_t)ret_conv;
31483 }
31484
31485 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
31486         LDKClosingSigned obj_conv;
31487         obj_conv.inner = (void*)(obj & (~1));
31488         obj_conv.is_owned = false;
31489         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31490         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
31491         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31492         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31493         CVec_u8Z_free(ret_var);
31494         return ret_arr;
31495 }
31496
31497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31498         LDKu8slice ser_ref;
31499         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31500         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31501         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
31502         *ret_conv = ClosingSigned_read(ser_ref);
31503         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31504         return (uint64_t)ret_conv;
31505 }
31506
31507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
31508         LDKClosingSignedFeeRange obj_conv;
31509         obj_conv.inner = (void*)(obj & (~1));
31510         obj_conv.is_owned = false;
31511         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31512         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
31513         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31514         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31515         CVec_u8Z_free(ret_var);
31516         return ret_arr;
31517 }
31518
31519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31520         LDKu8slice ser_ref;
31521         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31522         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31523         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
31524         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
31525         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31526         return (uint64_t)ret_conv;
31527 }
31528
31529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
31530         LDKCommitmentSigned obj_conv;
31531         obj_conv.inner = (void*)(obj & (~1));
31532         obj_conv.is_owned = false;
31533         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31534         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
31535         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31536         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31537         CVec_u8Z_free(ret_var);
31538         return ret_arr;
31539 }
31540
31541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31542         LDKu8slice ser_ref;
31543         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31544         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31545         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
31546         *ret_conv = CommitmentSigned_read(ser_ref);
31547         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31548         return (uint64_t)ret_conv;
31549 }
31550
31551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
31552         LDKFundingCreated obj_conv;
31553         obj_conv.inner = (void*)(obj & (~1));
31554         obj_conv.is_owned = false;
31555         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31556         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
31557         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31558         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31559         CVec_u8Z_free(ret_var);
31560         return ret_arr;
31561 }
31562
31563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31564         LDKu8slice ser_ref;
31565         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31566         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31567         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
31568         *ret_conv = FundingCreated_read(ser_ref);
31569         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31570         return (uint64_t)ret_conv;
31571 }
31572
31573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
31574         LDKFundingSigned obj_conv;
31575         obj_conv.inner = (void*)(obj & (~1));
31576         obj_conv.is_owned = false;
31577         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31578         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
31579         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31580         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31581         CVec_u8Z_free(ret_var);
31582         return ret_arr;
31583 }
31584
31585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31586         LDKu8slice ser_ref;
31587         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31588         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31589         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
31590         *ret_conv = FundingSigned_read(ser_ref);
31591         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31592         return (uint64_t)ret_conv;
31593 }
31594
31595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
31596         LDKFundingLocked obj_conv;
31597         obj_conv.inner = (void*)(obj & (~1));
31598         obj_conv.is_owned = false;
31599         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31600         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
31601         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31602         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31603         CVec_u8Z_free(ret_var);
31604         return ret_arr;
31605 }
31606
31607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31608         LDKu8slice ser_ref;
31609         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31610         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31611         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
31612         *ret_conv = FundingLocked_read(ser_ref);
31613         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31614         return (uint64_t)ret_conv;
31615 }
31616
31617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
31618         LDKInit obj_conv;
31619         obj_conv.inner = (void*)(obj & (~1));
31620         obj_conv.is_owned = false;
31621         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31622         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
31623         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31624         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31625         CVec_u8Z_free(ret_var);
31626         return ret_arr;
31627 }
31628
31629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31630         LDKu8slice ser_ref;
31631         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31632         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31633         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
31634         *ret_conv = Init_read(ser_ref);
31635         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31636         return (uint64_t)ret_conv;
31637 }
31638
31639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
31640         LDKOpenChannel obj_conv;
31641         obj_conv.inner = (void*)(obj & (~1));
31642         obj_conv.is_owned = false;
31643         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31644         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
31645         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31646         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31647         CVec_u8Z_free(ret_var);
31648         return ret_arr;
31649 }
31650
31651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31652         LDKu8slice ser_ref;
31653         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31654         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31655         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
31656         *ret_conv = OpenChannel_read(ser_ref);
31657         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31658         return (uint64_t)ret_conv;
31659 }
31660
31661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
31662         LDKRevokeAndACK obj_conv;
31663         obj_conv.inner = (void*)(obj & (~1));
31664         obj_conv.is_owned = false;
31665         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31666         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
31667         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31668         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31669         CVec_u8Z_free(ret_var);
31670         return ret_arr;
31671 }
31672
31673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31674         LDKu8slice ser_ref;
31675         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31676         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31677         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
31678         *ret_conv = RevokeAndACK_read(ser_ref);
31679         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31680         return (uint64_t)ret_conv;
31681 }
31682
31683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
31684         LDKShutdown obj_conv;
31685         obj_conv.inner = (void*)(obj & (~1));
31686         obj_conv.is_owned = false;
31687         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31688         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
31689         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31690         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31691         CVec_u8Z_free(ret_var);
31692         return ret_arr;
31693 }
31694
31695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31696         LDKu8slice ser_ref;
31697         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31698         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31699         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
31700         *ret_conv = Shutdown_read(ser_ref);
31701         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31702         return (uint64_t)ret_conv;
31703 }
31704
31705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
31706         LDKUpdateFailHTLC obj_conv;
31707         obj_conv.inner = (void*)(obj & (~1));
31708         obj_conv.is_owned = false;
31709         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31710         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
31711         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31712         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31713         CVec_u8Z_free(ret_var);
31714         return ret_arr;
31715 }
31716
31717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31718         LDKu8slice ser_ref;
31719         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31720         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31721         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
31722         *ret_conv = UpdateFailHTLC_read(ser_ref);
31723         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31724         return (uint64_t)ret_conv;
31725 }
31726
31727 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
31728         LDKUpdateFailMalformedHTLC obj_conv;
31729         obj_conv.inner = (void*)(obj & (~1));
31730         obj_conv.is_owned = false;
31731         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31732         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
31733         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31734         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31735         CVec_u8Z_free(ret_var);
31736         return ret_arr;
31737 }
31738
31739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31740         LDKu8slice ser_ref;
31741         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31742         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31743         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
31744         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
31745         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31746         return (uint64_t)ret_conv;
31747 }
31748
31749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
31750         LDKUpdateFee obj_conv;
31751         obj_conv.inner = (void*)(obj & (~1));
31752         obj_conv.is_owned = false;
31753         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31754         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
31755         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31756         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31757         CVec_u8Z_free(ret_var);
31758         return ret_arr;
31759 }
31760
31761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31762         LDKu8slice ser_ref;
31763         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31764         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31765         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
31766         *ret_conv = UpdateFee_read(ser_ref);
31767         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31768         return (uint64_t)ret_conv;
31769 }
31770
31771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
31772         LDKUpdateFulfillHTLC obj_conv;
31773         obj_conv.inner = (void*)(obj & (~1));
31774         obj_conv.is_owned = false;
31775         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31776         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
31777         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31778         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31779         CVec_u8Z_free(ret_var);
31780         return ret_arr;
31781 }
31782
31783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31784         LDKu8slice ser_ref;
31785         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31786         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31787         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
31788         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
31789         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31790         return (uint64_t)ret_conv;
31791 }
31792
31793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
31794         LDKUpdateAddHTLC obj_conv;
31795         obj_conv.inner = (void*)(obj & (~1));
31796         obj_conv.is_owned = false;
31797         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31798         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
31799         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31800         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31801         CVec_u8Z_free(ret_var);
31802         return ret_arr;
31803 }
31804
31805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31806         LDKu8slice ser_ref;
31807         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31808         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31809         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
31810         *ret_conv = UpdateAddHTLC_read(ser_ref);
31811         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31812         return (uint64_t)ret_conv;
31813 }
31814
31815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
31816         LDKPing obj_conv;
31817         obj_conv.inner = (void*)(obj & (~1));
31818         obj_conv.is_owned = false;
31819         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31820         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
31821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31823         CVec_u8Z_free(ret_var);
31824         return ret_arr;
31825 }
31826
31827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31828         LDKu8slice ser_ref;
31829         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31830         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31831         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
31832         *ret_conv = Ping_read(ser_ref);
31833         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31834         return (uint64_t)ret_conv;
31835 }
31836
31837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
31838         LDKPong obj_conv;
31839         obj_conv.inner = (void*)(obj & (~1));
31840         obj_conv.is_owned = false;
31841         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31842         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
31843         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31844         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31845         CVec_u8Z_free(ret_var);
31846         return ret_arr;
31847 }
31848
31849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31850         LDKu8slice ser_ref;
31851         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31852         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31853         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
31854         *ret_conv = Pong_read(ser_ref);
31855         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31856         return (uint64_t)ret_conv;
31857 }
31858
31859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31860         LDKUnsignedChannelAnnouncement obj_conv;
31861         obj_conv.inner = (void*)(obj & (~1));
31862         obj_conv.is_owned = false;
31863         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31864         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
31865         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31866         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31867         CVec_u8Z_free(ret_var);
31868         return ret_arr;
31869 }
31870
31871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31872         LDKu8slice ser_ref;
31873         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31874         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31875         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
31876         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
31877         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31878         return (uint64_t)ret_conv;
31879 }
31880
31881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31882         LDKChannelAnnouncement obj_conv;
31883         obj_conv.inner = (void*)(obj & (~1));
31884         obj_conv.is_owned = false;
31885         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31886         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
31887         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31888         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31889         CVec_u8Z_free(ret_var);
31890         return ret_arr;
31891 }
31892
31893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31894         LDKu8slice ser_ref;
31895         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31896         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31897         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
31898         *ret_conv = ChannelAnnouncement_read(ser_ref);
31899         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31900         return (uint64_t)ret_conv;
31901 }
31902
31903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
31904         LDKUnsignedChannelUpdate obj_conv;
31905         obj_conv.inner = (void*)(obj & (~1));
31906         obj_conv.is_owned = false;
31907         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31908         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
31909         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31910         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31911         CVec_u8Z_free(ret_var);
31912         return ret_arr;
31913 }
31914
31915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31916         LDKu8slice ser_ref;
31917         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31918         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31919         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
31920         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
31921         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31922         return (uint64_t)ret_conv;
31923 }
31924
31925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
31926         LDKChannelUpdate obj_conv;
31927         obj_conv.inner = (void*)(obj & (~1));
31928         obj_conv.is_owned = false;
31929         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31930         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
31931         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31932         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31933         CVec_u8Z_free(ret_var);
31934         return ret_arr;
31935 }
31936
31937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31938         LDKu8slice ser_ref;
31939         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31940         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31941         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
31942         *ret_conv = ChannelUpdate_read(ser_ref);
31943         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31944         return (uint64_t)ret_conv;
31945 }
31946
31947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
31948         LDKErrorMessage obj_conv;
31949         obj_conv.inner = (void*)(obj & (~1));
31950         obj_conv.is_owned = false;
31951         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31952         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
31953         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31954         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31955         CVec_u8Z_free(ret_var);
31956         return ret_arr;
31957 }
31958
31959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31960         LDKu8slice ser_ref;
31961         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31962         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31963         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
31964         *ret_conv = ErrorMessage_read(ser_ref);
31965         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31966         return (uint64_t)ret_conv;
31967 }
31968
31969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31970         LDKUnsignedNodeAnnouncement obj_conv;
31971         obj_conv.inner = (void*)(obj & (~1));
31972         obj_conv.is_owned = false;
31973         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31974         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
31975         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31976         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31977         CVec_u8Z_free(ret_var);
31978         return ret_arr;
31979 }
31980
31981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31982         LDKu8slice ser_ref;
31983         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31984         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31985         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
31986         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
31987         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31988         return (uint64_t)ret_conv;
31989 }
31990
31991 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31992         LDKNodeAnnouncement obj_conv;
31993         obj_conv.inner = (void*)(obj & (~1));
31994         obj_conv.is_owned = false;
31995         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31996         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
31997         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31998         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31999         CVec_u8Z_free(ret_var);
32000         return ret_arr;
32001 }
32002
32003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32004         LDKu8slice ser_ref;
32005         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32006         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32007         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
32008         *ret_conv = NodeAnnouncement_read(ser_ref);
32009         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32010         return (uint64_t)ret_conv;
32011 }
32012
32013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32014         LDKu8slice ser_ref;
32015         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32016         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32017         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
32018         *ret_conv = QueryShortChannelIds_read(ser_ref);
32019         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32020         return (uint64_t)ret_conv;
32021 }
32022
32023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
32024         LDKQueryShortChannelIds obj_conv;
32025         obj_conv.inner = (void*)(obj & (~1));
32026         obj_conv.is_owned = false;
32027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32028         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
32029         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32030         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32031         CVec_u8Z_free(ret_var);
32032         return ret_arr;
32033 }
32034
32035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
32036         LDKReplyShortChannelIdsEnd obj_conv;
32037         obj_conv.inner = (void*)(obj & (~1));
32038         obj_conv.is_owned = false;
32039         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32040         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
32041         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32042         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32043         CVec_u8Z_free(ret_var);
32044         return ret_arr;
32045 }
32046
32047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32048         LDKu8slice ser_ref;
32049         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32050         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32051         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
32052         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
32053         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32054         return (uint64_t)ret_conv;
32055 }
32056
32057 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
32058         LDKQueryChannelRange this_arg_conv;
32059         this_arg_conv.inner = (void*)(this_arg & (~1));
32060         this_arg_conv.is_owned = false;
32061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32062         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
32063         return ret_val;
32064 }
32065
32066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
32067         LDKQueryChannelRange obj_conv;
32068         obj_conv.inner = (void*)(obj & (~1));
32069         obj_conv.is_owned = false;
32070         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32071         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
32072         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32073         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32074         CVec_u8Z_free(ret_var);
32075         return ret_arr;
32076 }
32077
32078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32079         LDKu8slice ser_ref;
32080         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32081         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32082         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
32083         *ret_conv = QueryChannelRange_read(ser_ref);
32084         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32085         return (uint64_t)ret_conv;
32086 }
32087
32088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32089         LDKu8slice ser_ref;
32090         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32091         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32092         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
32093         *ret_conv = ReplyChannelRange_read(ser_ref);
32094         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32095         return (uint64_t)ret_conv;
32096 }
32097
32098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
32099         LDKReplyChannelRange obj_conv;
32100         obj_conv.inner = (void*)(obj & (~1));
32101         obj_conv.is_owned = false;
32102         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32103         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
32104         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32105         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32106         CVec_u8Z_free(ret_var);
32107         return ret_arr;
32108 }
32109
32110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
32111         LDKGossipTimestampFilter obj_conv;
32112         obj_conv.inner = (void*)(obj & (~1));
32113         obj_conv.is_owned = false;
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32115         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
32116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32118         CVec_u8Z_free(ret_var);
32119         return ret_arr;
32120 }
32121
32122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32123         LDKu8slice ser_ref;
32124         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32125         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32126         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
32127         *ret_conv = GossipTimestampFilter_read(ser_ref);
32128         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32129         return (uint64_t)ret_conv;
32130 }
32131
32132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32133         if ((this_ptr & 1) != 0) return;
32134         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
32135         CHECK_ACCESS(this_ptr_ptr);
32136         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
32137         FREE((void*)this_ptr);
32138         CustomMessageHandler_free(this_ptr_conv);
32139 }
32140
32141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32142         LDKIgnoringMessageHandler this_obj_conv;
32143         this_obj_conv.inner = (void*)(this_obj & (~1));
32144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32146         IgnoringMessageHandler_free(this_obj_conv);
32147 }
32148
32149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
32150         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
32151         uint64_t ret_ref = 0;
32152         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32153         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32155         ret_ref = (uint64_t)ret_var.inner;
32156         if (ret_var.is_owned) {
32157                 ret_ref |= 1;
32158         }
32159         return ret_ref;
32160 }
32161
32162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
32163         LDKIgnoringMessageHandler this_arg_conv;
32164         this_arg_conv.inner = (void*)(this_arg & (~1));
32165         this_arg_conv.is_owned = false;
32166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32167         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32168         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32169         return (uint64_t)ret_ret;
32170 }
32171
32172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
32173         LDKIgnoringMessageHandler this_arg_conv;
32174         this_arg_conv.inner = (void*)(this_arg & (~1));
32175         this_arg_conv.is_owned = false;
32176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32177         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
32178         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
32179         return (uint64_t)ret_ret;
32180 }
32181
32182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
32183         LDKIgnoringMessageHandler this_arg_conv;
32184         this_arg_conv.inner = (void*)(this_arg & (~1));
32185         this_arg_conv.is_owned = false;
32186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32187         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
32188         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
32189         return (uint64_t)ret_ret;
32190 }
32191
32192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
32193         LDKIgnoringMessageHandler this_arg_conv;
32194         this_arg_conv.inner = (void*)(this_arg & (~1));
32195         this_arg_conv.is_owned = false;
32196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32197         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
32198         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
32199         return (uint64_t)ret_ret;
32200 }
32201
32202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32203         LDKErroringMessageHandler this_obj_conv;
32204         this_obj_conv.inner = (void*)(this_obj & (~1));
32205         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32207         ErroringMessageHandler_free(this_obj_conv);
32208 }
32209
32210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
32211         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
32212         uint64_t ret_ref = 0;
32213         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32214         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32216         ret_ref = (uint64_t)ret_var.inner;
32217         if (ret_var.is_owned) {
32218                 ret_ref |= 1;
32219         }
32220         return ret_ref;
32221 }
32222
32223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
32224         LDKErroringMessageHandler this_arg_conv;
32225         this_arg_conv.inner = (void*)(this_arg & (~1));
32226         this_arg_conv.is_owned = false;
32227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32228         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32229         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32230         return (uint64_t)ret_ret;
32231 }
32232
32233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
32234         LDKErroringMessageHandler this_arg_conv;
32235         this_arg_conv.inner = (void*)(this_arg & (~1));
32236         this_arg_conv.is_owned = false;
32237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32238         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
32239         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
32240         return (uint64_t)ret_ret;
32241 }
32242
32243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32244         LDKMessageHandler this_obj_conv;
32245         this_obj_conv.inner = (void*)(this_obj & (~1));
32246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32248         MessageHandler_free(this_obj_conv);
32249 }
32250
32251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
32252         LDKMessageHandler this_ptr_conv;
32253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32254         this_ptr_conv.is_owned = false;
32255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32256         // WARNING: This object doesn't live past this scope, needs clone!
32257         uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
32258         return ret_ret;
32259 }
32260
32261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32262         LDKMessageHandler this_ptr_conv;
32263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32264         this_ptr_conv.is_owned = false;
32265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32266         void* val_ptr = (void*)(((uint64_t)val) & ~1);
32267         CHECK_ACCESS(val_ptr);
32268         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
32269         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
32270                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32271                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
32272         }
32273         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
32274 }
32275
32276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
32277         LDKMessageHandler this_ptr_conv;
32278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32279         this_ptr_conv.is_owned = false;
32280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32281         // WARNING: This object doesn't live past this scope, needs clone!
32282         uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
32283         return ret_ret;
32284 }
32285
32286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32287         LDKMessageHandler this_ptr_conv;
32288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32289         this_ptr_conv.is_owned = false;
32290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32291         void* val_ptr = (void*)(((uint64_t)val) & ~1);
32292         CHECK_ACCESS(val_ptr);
32293         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
32294         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32295                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32296                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
32297         }
32298         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
32299 }
32300
32301 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) {
32302         void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
32303         CHECK_ACCESS(chan_handler_arg_ptr);
32304         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
32305         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
32306                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32307                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
32308         }
32309         void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
32310         CHECK_ACCESS(route_handler_arg_ptr);
32311         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
32312         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32313                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32314                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
32315         }
32316         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
32317         uint64_t ret_ref = 0;
32318         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32319         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32321         ret_ref = (uint64_t)ret_var.inner;
32322         if (ret_var.is_owned) {
32323                 ret_ref |= 1;
32324         }
32325         return ret_ref;
32326 }
32327
32328 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
32329         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32330         *ret_ret = SocketDescriptor_clone(arg);
32331         return (uint64_t)ret_ret;
32332 }
32333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32334         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
32335         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
32336         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
32337         int64_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
32338         return ret_val;
32339 }
32340
32341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32342         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
32343         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
32344         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
32345         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32346         *ret_ret = SocketDescriptor_clone(orig_conv);
32347         return (uint64_t)ret_ret;
32348 }
32349
32350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32351         if ((this_ptr & 1) != 0) return;
32352         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
32353         CHECK_ACCESS(this_ptr_ptr);
32354         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
32355         FREE((void*)this_ptr);
32356         SocketDescriptor_free(this_ptr_conv);
32357 }
32358
32359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32360         LDKPeerHandleError this_obj_conv;
32361         this_obj_conv.inner = (void*)(this_obj & (~1));
32362         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32364         PeerHandleError_free(this_obj_conv);
32365 }
32366
32367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
32368         LDKPeerHandleError this_ptr_conv;
32369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32370         this_ptr_conv.is_owned = false;
32371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32372         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
32373         return ret_val;
32374 }
32375
32376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32377         LDKPeerHandleError this_ptr_conv;
32378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32379         this_ptr_conv.is_owned = false;
32380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32381         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
32382 }
32383
32384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
32385         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
32386         uint64_t ret_ref = 0;
32387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32390         ret_ref = (uint64_t)ret_var.inner;
32391         if (ret_var.is_owned) {
32392                 ret_ref |= 1;
32393         }
32394         return ret_ref;
32395 }
32396
32397 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
32398         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
32399 uint64_t ret_ref = 0;
32400 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32401 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32402 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32403 ret_ref = (uint64_t)ret_var.inner;
32404 if (ret_var.is_owned) {
32405         ret_ref |= 1;
32406 }
32407         return ret_ref;
32408 }
32409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32410         LDKPeerHandleError arg_conv;
32411         arg_conv.inner = (void*)(arg & (~1));
32412         arg_conv.is_owned = false;
32413         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32414         int64_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
32415         return ret_val;
32416 }
32417
32418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32419         LDKPeerHandleError orig_conv;
32420         orig_conv.inner = (void*)(orig & (~1));
32421         orig_conv.is_owned = false;
32422         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32423         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
32424         uint64_t ret_ref = 0;
32425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32428         ret_ref = (uint64_t)ret_var.inner;
32429         if (ret_var.is_owned) {
32430                 ret_ref |= 1;
32431         }
32432         return ret_ref;
32433 }
32434
32435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32436         LDKPeerManager this_obj_conv;
32437         this_obj_conv.inner = (void*)(this_obj & (~1));
32438         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32440         PeerManager_free(this_obj_conv);
32441 }
32442
32443 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) {
32444         LDKMessageHandler message_handler_conv;
32445         message_handler_conv.inner = (void*)(message_handler & (~1));
32446         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
32447         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
32448         // Warning: we need a move here but no clone is available for LDKMessageHandler
32449         LDKSecretKey our_node_secret_ref;
32450         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
32451         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
32452         unsigned char ephemeral_random_data_arr[32];
32453         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
32454         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
32455         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
32456         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
32457         CHECK_ACCESS(logger_ptr);
32458         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32459         if (logger_conv.free == LDKLogger_JCalls_free) {
32460                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32461                 LDKLogger_JCalls_cloned(&logger_conv);
32462         }
32463         void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
32464         CHECK_ACCESS(custom_message_handler_ptr);
32465         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
32466         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
32467                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32468                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
32469         }
32470         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
32471         uint64_t ret_ref = 0;
32472         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32473         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32475         ret_ref = (uint64_t)ret_var.inner;
32476         if (ret_var.is_owned) {
32477                 ret_ref |= 1;
32478         }
32479         return ret_ref;
32480 }
32481
32482 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
32483         LDKPeerManager this_arg_conv;
32484         this_arg_conv.inner = (void*)(this_arg & (~1));
32485         this_arg_conv.is_owned = false;
32486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32487         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
32488         jobjectArray ret_arr = NULL;
32489         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
32490         ;
32491         for (size_t i = 0; i < ret_var.datalen; i++) {
32492                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
32493                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
32494                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
32495         }
32496         
32497         FREE(ret_var.data);
32498         return ret_arr;
32499 }
32500
32501 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) {
32502         LDKPeerManager this_arg_conv;
32503         this_arg_conv.inner = (void*)(this_arg & (~1));
32504         this_arg_conv.is_owned = false;
32505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32506         LDKPublicKey their_node_id_ref;
32507         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
32508         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
32509         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
32510         CHECK_ACCESS(descriptor_ptr);
32511         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32512         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32513                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32514                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32515         }
32516         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
32517         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
32518         return (uint64_t)ret_conv;
32519 }
32520
32521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
32522         LDKPeerManager this_arg_conv;
32523         this_arg_conv.inner = (void*)(this_arg & (~1));
32524         this_arg_conv.is_owned = false;
32525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32526         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
32527         CHECK_ACCESS(descriptor_ptr);
32528         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32529         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32530                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32531                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32532         }
32533         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32534         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
32535         return (uint64_t)ret_conv;
32536 }
32537
32538 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) {
32539         LDKPeerManager this_arg_conv;
32540         this_arg_conv.inner = (void*)(this_arg & (~1));
32541         this_arg_conv.is_owned = false;
32542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32543         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
32544         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32545         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32546         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32547         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
32548         return (uint64_t)ret_conv;
32549 }
32550
32551 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) {
32552         LDKPeerManager this_arg_conv;
32553         this_arg_conv.inner = (void*)(this_arg & (~1));
32554         this_arg_conv.is_owned = false;
32555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32556         void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
32557         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
32558         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
32559         LDKu8slice data_ref;
32560         data_ref.datalen = (*env)->GetArrayLength(env, data);
32561         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
32562         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
32563         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
32564         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
32565         return (uint64_t)ret_conv;
32566 }
32567
32568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
32569         LDKPeerManager this_arg_conv;
32570         this_arg_conv.inner = (void*)(this_arg & (~1));
32571         this_arg_conv.is_owned = false;
32572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32573         PeerManager_process_events(&this_arg_conv);
32574 }
32575
32576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
32577         LDKPeerManager this_arg_conv;
32578         this_arg_conv.inner = (void*)(this_arg & (~1));
32579         this_arg_conv.is_owned = false;
32580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32581         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
32582         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32583         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32584         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
32585 }
32586
32587 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) {
32588         LDKPeerManager this_arg_conv;
32589         this_arg_conv.inner = (void*)(this_arg & (~1));
32590         this_arg_conv.is_owned = false;
32591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32592         LDKPublicKey node_id_ref;
32593         CHECK((*env)->GetArrayLength(env, node_id) == 33);
32594         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
32595         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
32596 }
32597
32598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
32599         LDKPeerManager this_arg_conv;
32600         this_arg_conv.inner = (void*)(this_arg & (~1));
32601         this_arg_conv.is_owned = false;
32602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32603         PeerManager_disconnect_all_peers(&this_arg_conv);
32604 }
32605
32606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
32607         LDKPeerManager this_arg_conv;
32608         this_arg_conv.inner = (void*)(this_arg & (~1));
32609         this_arg_conv.is_owned = false;
32610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32611         PeerManager_timer_tick_occurred(&this_arg_conv);
32612 }
32613
32614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
32615         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
32616         return ret_val;
32617 }
32618
32619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
32620         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
32621         return ret_val;
32622 }
32623
32624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
32625         unsigned char commitment_seed_arr[32];
32626         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
32627         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
32628         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
32629         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
32631         return ret_arr;
32632 }
32633
32634 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) {
32635         LDKCVec_u8Z to_holder_script_ref;
32636         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
32637         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
32638         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
32639         LDKCVec_u8Z to_counterparty_script_ref;
32640         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
32641         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
32642         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
32643         LDKOutPoint funding_outpoint_conv;
32644         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
32645         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
32646         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
32647         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
32648         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);
32649         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32650         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32651         Transaction_free(ret_var);
32652         return ret_arr;
32653 }
32654
32655 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) {
32656         LDKPublicKey per_commitment_point_ref;
32657         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
32658         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
32659         unsigned char base_secret_arr[32];
32660         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
32661         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
32662         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
32663         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32664         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
32665         return (uint64_t)ret_conv;
32666 }
32667
32668 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) {
32669         LDKPublicKey per_commitment_point_ref;
32670         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
32671         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
32672         LDKPublicKey base_point_ref;
32673         CHECK((*env)->GetArrayLength(env, base_point) == 33);
32674         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
32675         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32676         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
32677         return (uint64_t)ret_conv;
32678 }
32679
32680 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) {
32681         unsigned char per_commitment_secret_arr[32];
32682         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
32683         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
32684         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
32685         unsigned char countersignatory_revocation_base_secret_arr[32];
32686         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
32687         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
32688         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
32689         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32690         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
32691         return (uint64_t)ret_conv;
32692 }
32693
32694 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) {
32695         LDKPublicKey per_commitment_point_ref;
32696         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
32697         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
32698         LDKPublicKey countersignatory_revocation_base_point_ref;
32699         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
32700         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
32701         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32702         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
32703         return (uint64_t)ret_conv;
32704 }
32705
32706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32707         LDKTxCreationKeys this_obj_conv;
32708         this_obj_conv.inner = (void*)(this_obj & (~1));
32709         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32711         TxCreationKeys_free(this_obj_conv);
32712 }
32713
32714 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32715         LDKTxCreationKeys this_ptr_conv;
32716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32717         this_ptr_conv.is_owned = false;
32718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32719         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32720         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
32721         return ret_arr;
32722 }
32723
32724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32725         LDKTxCreationKeys this_ptr_conv;
32726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32727         this_ptr_conv.is_owned = false;
32728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32729         LDKPublicKey val_ref;
32730         CHECK((*env)->GetArrayLength(env, val) == 33);
32731         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32732         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
32733 }
32734
32735 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
32736         LDKTxCreationKeys this_ptr_conv;
32737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32738         this_ptr_conv.is_owned = false;
32739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32740         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32741         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
32742         return ret_arr;
32743 }
32744
32745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32746         LDKTxCreationKeys this_ptr_conv;
32747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32748         this_ptr_conv.is_owned = false;
32749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32750         LDKPublicKey val_ref;
32751         CHECK((*env)->GetArrayLength(env, val) == 33);
32752         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32753         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
32754 }
32755
32756 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
32757         LDKTxCreationKeys this_ptr_conv;
32758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32759         this_ptr_conv.is_owned = false;
32760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32761         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32762         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
32763         return ret_arr;
32764 }
32765
32766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32767         LDKTxCreationKeys this_ptr_conv;
32768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32769         this_ptr_conv.is_owned = false;
32770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32771         LDKPublicKey val_ref;
32772         CHECK((*env)->GetArrayLength(env, val) == 33);
32773         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32774         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
32775 }
32776
32777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
32778         LDKTxCreationKeys this_ptr_conv;
32779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32780         this_ptr_conv.is_owned = false;
32781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32782         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32783         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
32784         return ret_arr;
32785 }
32786
32787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32788         LDKTxCreationKeys this_ptr_conv;
32789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32790         this_ptr_conv.is_owned = false;
32791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32792         LDKPublicKey val_ref;
32793         CHECK((*env)->GetArrayLength(env, val) == 33);
32794         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32795         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
32796 }
32797
32798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
32799         LDKTxCreationKeys this_ptr_conv;
32800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32801         this_ptr_conv.is_owned = false;
32802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32803         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32804         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
32805         return ret_arr;
32806 }
32807
32808 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) {
32809         LDKTxCreationKeys this_ptr_conv;
32810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32811         this_ptr_conv.is_owned = false;
32812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32813         LDKPublicKey val_ref;
32814         CHECK((*env)->GetArrayLength(env, val) == 33);
32815         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32816         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
32817 }
32818
32819 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) {
32820         LDKPublicKey per_commitment_point_arg_ref;
32821         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
32822         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
32823         LDKPublicKey revocation_key_arg_ref;
32824         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
32825         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
32826         LDKPublicKey broadcaster_htlc_key_arg_ref;
32827         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
32828         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
32829         LDKPublicKey countersignatory_htlc_key_arg_ref;
32830         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
32831         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
32832         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
32833         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
32834         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
32835         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);
32836         uint64_t ret_ref = 0;
32837         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32838         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32840         ret_ref = (uint64_t)ret_var.inner;
32841         if (ret_var.is_owned) {
32842                 ret_ref |= 1;
32843         }
32844         return ret_ref;
32845 }
32846
32847 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
32848         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
32849 uint64_t ret_ref = 0;
32850 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32851 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32852 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32853 ret_ref = (uint64_t)ret_var.inner;
32854 if (ret_var.is_owned) {
32855         ret_ref |= 1;
32856 }
32857         return ret_ref;
32858 }
32859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32860         LDKTxCreationKeys arg_conv;
32861         arg_conv.inner = (void*)(arg & (~1));
32862         arg_conv.is_owned = false;
32863         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32864         int64_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
32865         return ret_val;
32866 }
32867
32868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32869         LDKTxCreationKeys orig_conv;
32870         orig_conv.inner = (void*)(orig & (~1));
32871         orig_conv.is_owned = false;
32872         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32873         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
32874         uint64_t ret_ref = 0;
32875         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32876         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32878         ret_ref = (uint64_t)ret_var.inner;
32879         if (ret_var.is_owned) {
32880                 ret_ref |= 1;
32881         }
32882         return ret_ref;
32883 }
32884
32885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
32886         LDKTxCreationKeys obj_conv;
32887         obj_conv.inner = (void*)(obj & (~1));
32888         obj_conv.is_owned = false;
32889         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32890         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
32891         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32892         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32893         CVec_u8Z_free(ret_var);
32894         return ret_arr;
32895 }
32896
32897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32898         LDKu8slice ser_ref;
32899         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32900         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32901         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
32902         *ret_conv = TxCreationKeys_read(ser_ref);
32903         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32904         return (uint64_t)ret_conv;
32905 }
32906
32907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32908         LDKChannelPublicKeys this_obj_conv;
32909         this_obj_conv.inner = (void*)(this_obj & (~1));
32910         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32912         ChannelPublicKeys_free(this_obj_conv);
32913 }
32914
32915 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32916         LDKChannelPublicKeys this_ptr_conv;
32917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32918         this_ptr_conv.is_owned = false;
32919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32920         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32921         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
32922         return ret_arr;
32923 }
32924
32925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32926         LDKChannelPublicKeys this_ptr_conv;
32927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32928         this_ptr_conv.is_owned = false;
32929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32930         LDKPublicKey val_ref;
32931         CHECK((*env)->GetArrayLength(env, val) == 33);
32932         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32933         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
32934 }
32935
32936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32937         LDKChannelPublicKeys this_ptr_conv;
32938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32939         this_ptr_conv.is_owned = false;
32940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32941         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32942         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32943         return ret_arr;
32944 }
32945
32946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32947         LDKChannelPublicKeys this_ptr_conv;
32948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32949         this_ptr_conv.is_owned = false;
32950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32951         LDKPublicKey val_ref;
32952         CHECK((*env)->GetArrayLength(env, val) == 33);
32953         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32954         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
32955 }
32956
32957 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32958         LDKChannelPublicKeys this_ptr_conv;
32959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32960         this_ptr_conv.is_owned = false;
32961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32962         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32963         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
32964         return ret_arr;
32965 }
32966
32967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32968         LDKChannelPublicKeys this_ptr_conv;
32969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32970         this_ptr_conv.is_owned = false;
32971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32972         LDKPublicKey val_ref;
32973         CHECK((*env)->GetArrayLength(env, val) == 33);
32974         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32975         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
32976 }
32977
32978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32979         LDKChannelPublicKeys this_ptr_conv;
32980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32981         this_ptr_conv.is_owned = false;
32982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32983         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32984         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32985         return ret_arr;
32986 }
32987
32988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32989         LDKChannelPublicKeys this_ptr_conv;
32990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32991         this_ptr_conv.is_owned = false;
32992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32993         LDKPublicKey val_ref;
32994         CHECK((*env)->GetArrayLength(env, val) == 33);
32995         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32996         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32997 }
32998
32999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33000         LDKChannelPublicKeys this_ptr_conv;
33001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33002         this_ptr_conv.is_owned = false;
33003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33004         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33005         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
33006         return ret_arr;
33007 }
33008
33009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33010         LDKChannelPublicKeys this_ptr_conv;
33011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33012         this_ptr_conv.is_owned = false;
33013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33014         LDKPublicKey val_ref;
33015         CHECK((*env)->GetArrayLength(env, val) == 33);
33016         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33017         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
33018 }
33019
33020 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) {
33021         LDKPublicKey funding_pubkey_arg_ref;
33022         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
33023         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
33024         LDKPublicKey revocation_basepoint_arg_ref;
33025         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
33026         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
33027         LDKPublicKey payment_point_arg_ref;
33028         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
33029         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
33030         LDKPublicKey delayed_payment_basepoint_arg_ref;
33031         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
33032         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
33033         LDKPublicKey htlc_basepoint_arg_ref;
33034         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
33035         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
33036         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);
33037         uint64_t ret_ref = 0;
33038         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33039         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33041         ret_ref = (uint64_t)ret_var.inner;
33042         if (ret_var.is_owned) {
33043                 ret_ref |= 1;
33044         }
33045         return ret_ref;
33046 }
33047
33048 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
33049         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
33050 uint64_t ret_ref = 0;
33051 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33052 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33053 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33054 ret_ref = (uint64_t)ret_var.inner;
33055 if (ret_var.is_owned) {
33056         ret_ref |= 1;
33057 }
33058         return ret_ref;
33059 }
33060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33061         LDKChannelPublicKeys arg_conv;
33062         arg_conv.inner = (void*)(arg & (~1));
33063         arg_conv.is_owned = false;
33064         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33065         int64_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
33066         return ret_val;
33067 }
33068
33069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33070         LDKChannelPublicKeys orig_conv;
33071         orig_conv.inner = (void*)(orig & (~1));
33072         orig_conv.is_owned = false;
33073         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33074         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
33075         uint64_t ret_ref = 0;
33076         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33077         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33079         ret_ref = (uint64_t)ret_var.inner;
33080         if (ret_var.is_owned) {
33081                 ret_ref |= 1;
33082         }
33083         return ret_ref;
33084 }
33085
33086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
33087         LDKChannelPublicKeys obj_conv;
33088         obj_conv.inner = (void*)(obj & (~1));
33089         obj_conv.is_owned = false;
33090         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33091         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
33092         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33093         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33094         CVec_u8Z_free(ret_var);
33095         return ret_arr;
33096 }
33097
33098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33099         LDKu8slice ser_ref;
33100         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33101         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33102         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
33103         *ret_conv = ChannelPublicKeys_read(ser_ref);
33104         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33105         return (uint64_t)ret_conv;
33106 }
33107
33108 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) {
33109         LDKPublicKey per_commitment_point_ref;
33110         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
33111         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
33112         LDKPublicKey broadcaster_delayed_payment_base_ref;
33113         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
33114         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
33115         LDKPublicKey broadcaster_htlc_base_ref;
33116         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
33117         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
33118         LDKPublicKey countersignatory_revocation_base_ref;
33119         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
33120         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
33121         LDKPublicKey countersignatory_htlc_base_ref;
33122         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
33123         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
33124         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33125         *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);
33126         return (uint64_t)ret_conv;
33127 }
33128
33129 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) {
33130         LDKPublicKey per_commitment_point_ref;
33131         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
33132         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
33133         LDKChannelPublicKeys broadcaster_keys_conv;
33134         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
33135         broadcaster_keys_conv.is_owned = false;
33136         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
33137         LDKChannelPublicKeys countersignatory_keys_conv;
33138         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
33139         countersignatory_keys_conv.is_owned = false;
33140         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
33141         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33142         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
33143         return (uint64_t)ret_conv;
33144 }
33145
33146 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) {
33147         LDKPublicKey revocation_key_ref;
33148         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
33149         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
33150         LDKPublicKey broadcaster_delayed_payment_key_ref;
33151         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
33152         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
33153         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
33154         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33155         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33156         CVec_u8Z_free(ret_var);
33157         return ret_arr;
33158 }
33159
33160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33161         LDKHTLCOutputInCommitment this_obj_conv;
33162         this_obj_conv.inner = (void*)(this_obj & (~1));
33163         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33165         HTLCOutputInCommitment_free(this_obj_conv);
33166 }
33167
33168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
33169         LDKHTLCOutputInCommitment this_ptr_conv;
33170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33171         this_ptr_conv.is_owned = false;
33172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33173         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
33174         return ret_val;
33175 }
33176
33177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
33178         LDKHTLCOutputInCommitment this_ptr_conv;
33179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33180         this_ptr_conv.is_owned = false;
33181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33182         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
33183 }
33184
33185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33186         LDKHTLCOutputInCommitment this_ptr_conv;
33187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33188         this_ptr_conv.is_owned = false;
33189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33190         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
33191         return ret_val;
33192 }
33193
33194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33195         LDKHTLCOutputInCommitment this_ptr_conv;
33196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33197         this_ptr_conv.is_owned = false;
33198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33199         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
33200 }
33201
33202 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
33203         LDKHTLCOutputInCommitment this_ptr_conv;
33204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33205         this_ptr_conv.is_owned = false;
33206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33207         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
33208         return ret_val;
33209 }
33210
33211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33212         LDKHTLCOutputInCommitment this_ptr_conv;
33213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33214         this_ptr_conv.is_owned = false;
33215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33216         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
33217 }
33218
33219 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33220         LDKHTLCOutputInCommitment this_ptr_conv;
33221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33222         this_ptr_conv.is_owned = false;
33223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33224         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33225         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
33226         return ret_arr;
33227 }
33228
33229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33230         LDKHTLCOutputInCommitment this_ptr_conv;
33231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33232         this_ptr_conv.is_owned = false;
33233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33234         LDKThirtyTwoBytes val_ref;
33235         CHECK((*env)->GetArrayLength(env, val) == 32);
33236         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33237         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
33238 }
33239
33240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
33241         LDKHTLCOutputInCommitment this_ptr_conv;
33242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33243         this_ptr_conv.is_owned = false;
33244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33245         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
33246         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
33247         uint64_t ret_ref = (uint64_t)ret_copy;
33248         return ret_ref;
33249 }
33250
33251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33252         LDKHTLCOutputInCommitment this_ptr_conv;
33253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33254         this_ptr_conv.is_owned = false;
33255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33256         void* val_ptr = (void*)(((uint64_t)val) & ~1);
33257         CHECK_ACCESS(val_ptr);
33258         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
33259         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
33260         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
33261 }
33262
33263 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) {
33264         LDKThirtyTwoBytes payment_hash_arg_ref;
33265         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
33266         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
33267         void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
33268         CHECK_ACCESS(transaction_output_index_arg_ptr);
33269         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
33270         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
33271         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
33272         uint64_t ret_ref = 0;
33273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33276         ret_ref = (uint64_t)ret_var.inner;
33277         if (ret_var.is_owned) {
33278                 ret_ref |= 1;
33279         }
33280         return ret_ref;
33281 }
33282
33283 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
33284         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
33285 uint64_t ret_ref = 0;
33286 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33287 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33288 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33289 ret_ref = (uint64_t)ret_var.inner;
33290 if (ret_var.is_owned) {
33291         ret_ref |= 1;
33292 }
33293         return ret_ref;
33294 }
33295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33296         LDKHTLCOutputInCommitment arg_conv;
33297         arg_conv.inner = (void*)(arg & (~1));
33298         arg_conv.is_owned = false;
33299         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33300         int64_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
33301         return ret_val;
33302 }
33303
33304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33305         LDKHTLCOutputInCommitment orig_conv;
33306         orig_conv.inner = (void*)(orig & (~1));
33307         orig_conv.is_owned = false;
33308         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33309         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
33310         uint64_t ret_ref = 0;
33311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33314         ret_ref = (uint64_t)ret_var.inner;
33315         if (ret_var.is_owned) {
33316                 ret_ref |= 1;
33317         }
33318         return ret_ref;
33319 }
33320
33321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
33322         LDKHTLCOutputInCommitment obj_conv;
33323         obj_conv.inner = (void*)(obj & (~1));
33324         obj_conv.is_owned = false;
33325         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33326         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
33327         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33328         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33329         CVec_u8Z_free(ret_var);
33330         return ret_arr;
33331 }
33332
33333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33334         LDKu8slice ser_ref;
33335         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33336         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33337         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
33338         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
33339         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33340         return (uint64_t)ret_conv;
33341 }
33342
33343 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) {
33344         LDKHTLCOutputInCommitment htlc_conv;
33345         htlc_conv.inner = (void*)(htlc & (~1));
33346         htlc_conv.is_owned = false;
33347         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33348         LDKTxCreationKeys keys_conv;
33349         keys_conv.inner = (void*)(keys & (~1));
33350         keys_conv.is_owned = false;
33351         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33352         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
33353         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33354         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33355         CVec_u8Z_free(ret_var);
33356         return ret_arr;
33357 }
33358
33359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
33360         LDKPublicKey broadcaster_ref;
33361         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
33362         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
33363         LDKPublicKey countersignatory_ref;
33364         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
33365         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
33366         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
33367         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33368         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33369         CVec_u8Z_free(ret_var);
33370         return ret_arr;
33371 }
33372
33373 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) {
33374         unsigned char commitment_txid_arr[32];
33375         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
33376         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
33377         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
33378         LDKHTLCOutputInCommitment htlc_conv;
33379         htlc_conv.inner = (void*)(htlc & (~1));
33380         htlc_conv.is_owned = false;
33381         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33382         LDKPublicKey broadcaster_delayed_payment_key_ref;
33383         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
33384         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
33385         LDKPublicKey revocation_key_ref;
33386         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
33387         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
33388         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);
33389         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33390         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33391         Transaction_free(ret_var);
33392         return ret_arr;
33393 }
33394
33395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
33396         LDKPublicKey funding_pubkey_ref;
33397         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
33398         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
33399         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
33400         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33401         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33402         CVec_u8Z_free(ret_var);
33403         return ret_arr;
33404 }
33405
33406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33407         LDKChannelTransactionParameters this_obj_conv;
33408         this_obj_conv.inner = (void*)(this_obj & (~1));
33409         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33411         ChannelTransactionParameters_free(this_obj_conv);
33412 }
33413
33414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
33415         LDKChannelTransactionParameters this_ptr_conv;
33416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33417         this_ptr_conv.is_owned = false;
33418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33419         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
33420         uint64_t ret_ref = 0;
33421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33424         ret_ref = (uint64_t)ret_var.inner;
33425         if (ret_var.is_owned) {
33426                 ret_ref |= 1;
33427         }
33428         return ret_ref;
33429 }
33430
33431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33432         LDKChannelTransactionParameters this_ptr_conv;
33433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33434         this_ptr_conv.is_owned = false;
33435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33436         LDKChannelPublicKeys val_conv;
33437         val_conv.inner = (void*)(val & (~1));
33438         val_conv.is_owned = (val & 1) || (val == 0);
33439         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33440         val_conv = ChannelPublicKeys_clone(&val_conv);
33441         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
33442 }
33443
33444 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
33445         LDKChannelTransactionParameters this_ptr_conv;
33446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33447         this_ptr_conv.is_owned = false;
33448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33449         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
33450         return ret_val;
33451 }
33452
33453 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) {
33454         LDKChannelTransactionParameters 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         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
33459 }
33460
33461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
33462         LDKChannelTransactionParameters this_ptr_conv;
33463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33464         this_ptr_conv.is_owned = false;
33465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33466         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
33467         return ret_val;
33468 }
33469
33470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
33471         LDKChannelTransactionParameters this_ptr_conv;
33472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33473         this_ptr_conv.is_owned = false;
33474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33475         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
33476 }
33477
33478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
33479         LDKChannelTransactionParameters this_ptr_conv;
33480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33481         this_ptr_conv.is_owned = false;
33482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33483         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
33484         uint64_t ret_ref = 0;
33485         if ((uint64_t)ret_var.inner > 4096) {
33486                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33487                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33489                 ret_ref = (uint64_t)ret_var.inner;
33490                 if (ret_var.is_owned) {
33491                         ret_ref |= 1;
33492                 }
33493         }
33494         return ret_ref;
33495 }
33496
33497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33498         LDKChannelTransactionParameters this_ptr_conv;
33499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33500         this_ptr_conv.is_owned = false;
33501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33502         LDKCounterpartyChannelTransactionParameters val_conv;
33503         val_conv.inner = (void*)(val & (~1));
33504         val_conv.is_owned = (val & 1) || (val == 0);
33505         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33506         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
33507         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
33508 }
33509
33510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33511         LDKChannelTransactionParameters this_ptr_conv;
33512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33513         this_ptr_conv.is_owned = false;
33514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33515         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
33516         uint64_t ret_ref = 0;
33517         if ((uint64_t)ret_var.inner > 4096) {
33518                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33519                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33521                 ret_ref = (uint64_t)ret_var.inner;
33522                 if (ret_var.is_owned) {
33523                         ret_ref |= 1;
33524                 }
33525         }
33526         return ret_ref;
33527 }
33528
33529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33530         LDKChannelTransactionParameters this_ptr_conv;
33531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33532         this_ptr_conv.is_owned = false;
33533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33534         LDKOutPoint val_conv;
33535         val_conv.inner = (void*)(val & (~1));
33536         val_conv.is_owned = (val & 1) || (val == 0);
33537         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33538         val_conv = OutPoint_clone(&val_conv);
33539         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
33540 }
33541
33542 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
33543         LDKChannelTransactionParameters this_ptr_conv;
33544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33545         this_ptr_conv.is_owned = false;
33546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33547         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
33548         return ret_conv;
33549 }
33550
33551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
33552         LDKChannelTransactionParameters this_ptr_conv;
33553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33554         this_ptr_conv.is_owned = false;
33555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33556         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
33557         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
33558 }
33559
33560 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) {
33561         LDKChannelPublicKeys holder_pubkeys_arg_conv;
33562         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
33563         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
33564         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
33565         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
33566         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
33567         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
33568         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
33569         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
33570         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
33571         LDKOutPoint funding_outpoint_arg_conv;
33572         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
33573         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
33574         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
33575         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
33576         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
33577         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);
33578         uint64_t ret_ref = 0;
33579         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33580         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33582         ret_ref = (uint64_t)ret_var.inner;
33583         if (ret_var.is_owned) {
33584                 ret_ref |= 1;
33585         }
33586         return ret_ref;
33587 }
33588
33589 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
33590         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
33591 uint64_t ret_ref = 0;
33592 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33593 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33594 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33595 ret_ref = (uint64_t)ret_var.inner;
33596 if (ret_var.is_owned) {
33597         ret_ref |= 1;
33598 }
33599         return ret_ref;
33600 }
33601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33602         LDKChannelTransactionParameters arg_conv;
33603         arg_conv.inner = (void*)(arg & (~1));
33604         arg_conv.is_owned = false;
33605         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33606         int64_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
33607         return ret_val;
33608 }
33609
33610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33611         LDKChannelTransactionParameters orig_conv;
33612         orig_conv.inner = (void*)(orig & (~1));
33613         orig_conv.is_owned = false;
33614         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33615         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
33616         uint64_t ret_ref = 0;
33617         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33618         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33620         ret_ref = (uint64_t)ret_var.inner;
33621         if (ret_var.is_owned) {
33622                 ret_ref |= 1;
33623         }
33624         return ret_ref;
33625 }
33626
33627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33628         LDKCounterpartyChannelTransactionParameters this_obj_conv;
33629         this_obj_conv.inner = (void*)(this_obj & (~1));
33630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33632         CounterpartyChannelTransactionParameters_free(this_obj_conv);
33633 }
33634
33635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
33636         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33638         this_ptr_conv.is_owned = false;
33639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33640         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
33641         uint64_t ret_ref = 0;
33642         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33643         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33645         ret_ref = (uint64_t)ret_var.inner;
33646         if (ret_var.is_owned) {
33647                 ret_ref |= 1;
33648         }
33649         return ret_ref;
33650 }
33651
33652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33653         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33655         this_ptr_conv.is_owned = false;
33656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33657         LDKChannelPublicKeys val_conv;
33658         val_conv.inner = (void*)(val & (~1));
33659         val_conv.is_owned = (val & 1) || (val == 0);
33660         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33661         val_conv = ChannelPublicKeys_clone(&val_conv);
33662         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
33663 }
33664
33665 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
33666         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33668         this_ptr_conv.is_owned = false;
33669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33670         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
33671         return ret_val;
33672 }
33673
33674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33675         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33677         this_ptr_conv.is_owned = false;
33678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33679         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
33680 }
33681
33682 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) {
33683         LDKChannelPublicKeys pubkeys_arg_conv;
33684         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
33685         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
33686         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
33687         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
33688         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
33689         uint64_t ret_ref = 0;
33690         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33691         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33693         ret_ref = (uint64_t)ret_var.inner;
33694         if (ret_var.is_owned) {
33695                 ret_ref |= 1;
33696         }
33697         return ret_ref;
33698 }
33699
33700 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
33701         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
33702 uint64_t ret_ref = 0;
33703 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33704 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33705 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33706 ret_ref = (uint64_t)ret_var.inner;
33707 if (ret_var.is_owned) {
33708         ret_ref |= 1;
33709 }
33710         return ret_ref;
33711 }
33712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33713         LDKCounterpartyChannelTransactionParameters arg_conv;
33714         arg_conv.inner = (void*)(arg & (~1));
33715         arg_conv.is_owned = false;
33716         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33717         int64_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
33718         return ret_val;
33719 }
33720
33721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33722         LDKCounterpartyChannelTransactionParameters orig_conv;
33723         orig_conv.inner = (void*)(orig & (~1));
33724         orig_conv.is_owned = false;
33725         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33726         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
33727         uint64_t ret_ref = 0;
33728         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33729         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33731         ret_ref = (uint64_t)ret_var.inner;
33732         if (ret_var.is_owned) {
33733                 ret_ref |= 1;
33734         }
33735         return ret_ref;
33736 }
33737
33738 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
33739         LDKChannelTransactionParameters this_arg_conv;
33740         this_arg_conv.inner = (void*)(this_arg & (~1));
33741         this_arg_conv.is_owned = false;
33742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33743         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
33744         return ret_val;
33745 }
33746
33747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
33748         LDKChannelTransactionParameters this_arg_conv;
33749         this_arg_conv.inner = (void*)(this_arg & (~1));
33750         this_arg_conv.is_owned = false;
33751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33752         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
33753         uint64_t ret_ref = 0;
33754         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33755         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33757         ret_ref = (uint64_t)ret_var.inner;
33758         if (ret_var.is_owned) {
33759                 ret_ref |= 1;
33760         }
33761         return ret_ref;
33762 }
33763
33764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
33765         LDKChannelTransactionParameters this_arg_conv;
33766         this_arg_conv.inner = (void*)(this_arg & (~1));
33767         this_arg_conv.is_owned = false;
33768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33769         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
33770         uint64_t ret_ref = 0;
33771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33774         ret_ref = (uint64_t)ret_var.inner;
33775         if (ret_var.is_owned) {
33776                 ret_ref |= 1;
33777         }
33778         return ret_ref;
33779 }
33780
33781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
33782         LDKCounterpartyChannelTransactionParameters obj_conv;
33783         obj_conv.inner = (void*)(obj & (~1));
33784         obj_conv.is_owned = false;
33785         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33786         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
33787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33789         CVec_u8Z_free(ret_var);
33790         return ret_arr;
33791 }
33792
33793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33794         LDKu8slice ser_ref;
33795         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33796         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33797         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
33798         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
33799         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33800         return (uint64_t)ret_conv;
33801 }
33802
33803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
33804         LDKChannelTransactionParameters obj_conv;
33805         obj_conv.inner = (void*)(obj & (~1));
33806         obj_conv.is_owned = false;
33807         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33808         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
33809         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33810         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33811         CVec_u8Z_free(ret_var);
33812         return ret_arr;
33813 }
33814
33815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33816         LDKu8slice ser_ref;
33817         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33818         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33819         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
33820         *ret_conv = ChannelTransactionParameters_read(ser_ref);
33821         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33822         return (uint64_t)ret_conv;
33823 }
33824
33825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33826         LDKDirectedChannelTransactionParameters this_obj_conv;
33827         this_obj_conv.inner = (void*)(this_obj & (~1));
33828         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33830         DirectedChannelTransactionParameters_free(this_obj_conv);
33831 }
33832
33833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
33834         LDKDirectedChannelTransactionParameters this_arg_conv;
33835         this_arg_conv.inner = (void*)(this_arg & (~1));
33836         this_arg_conv.is_owned = false;
33837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33838         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
33839         uint64_t ret_ref = 0;
33840         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33841         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33843         ret_ref = (uint64_t)ret_var.inner;
33844         if (ret_var.is_owned) {
33845                 ret_ref |= 1;
33846         }
33847         return ret_ref;
33848 }
33849
33850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
33851         LDKDirectedChannelTransactionParameters this_arg_conv;
33852         this_arg_conv.inner = (void*)(this_arg & (~1));
33853         this_arg_conv.is_owned = false;
33854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33855         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
33856         uint64_t ret_ref = 0;
33857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33860         ret_ref = (uint64_t)ret_var.inner;
33861         if (ret_var.is_owned) {
33862                 ret_ref |= 1;
33863         }
33864         return ret_ref;
33865 }
33866
33867 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
33868         LDKDirectedChannelTransactionParameters this_arg_conv;
33869         this_arg_conv.inner = (void*)(this_arg & (~1));
33870         this_arg_conv.is_owned = false;
33871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33872         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
33873         return ret_val;
33874 }
33875
33876 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
33877         LDKDirectedChannelTransactionParameters this_arg_conv;
33878         this_arg_conv.inner = (void*)(this_arg & (~1));
33879         this_arg_conv.is_owned = false;
33880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33881         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
33882         return ret_val;
33883 }
33884
33885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
33886         LDKDirectedChannelTransactionParameters this_arg_conv;
33887         this_arg_conv.inner = (void*)(this_arg & (~1));
33888         this_arg_conv.is_owned = false;
33889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33890         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
33891         uint64_t ret_ref = 0;
33892         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33893         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33895         ret_ref = (uint64_t)ret_var.inner;
33896         if (ret_var.is_owned) {
33897                 ret_ref |= 1;
33898         }
33899         return ret_ref;
33900 }
33901
33902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
33903         LDKDirectedChannelTransactionParameters this_arg_conv;
33904         this_arg_conv.inner = (void*)(this_arg & (~1));
33905         this_arg_conv.is_owned = false;
33906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33907         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
33908         return ret_val;
33909 }
33910
33911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33912         LDKHolderCommitmentTransaction this_obj_conv;
33913         this_obj_conv.inner = (void*)(this_obj & (~1));
33914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33916         HolderCommitmentTransaction_free(this_obj_conv);
33917 }
33918
33919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
33920         LDKHolderCommitmentTransaction this_ptr_conv;
33921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33922         this_ptr_conv.is_owned = false;
33923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33924         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33925         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
33926         return ret_arr;
33927 }
33928
33929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33930         LDKHolderCommitmentTransaction this_ptr_conv;
33931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33932         this_ptr_conv.is_owned = false;
33933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33934         LDKSignature val_ref;
33935         CHECK((*env)->GetArrayLength(env, val) == 64);
33936         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33937         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
33938 }
33939
33940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
33941         LDKHolderCommitmentTransaction this_ptr_conv;
33942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33943         this_ptr_conv.is_owned = false;
33944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33945         LDKCVec_SignatureZ val_constr;
33946         val_constr.datalen = (*env)->GetArrayLength(env, val);
33947         if (val_constr.datalen > 0)
33948                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33949         else
33950                 val_constr.data = NULL;
33951         for (size_t i = 0; i < val_constr.datalen; i++) {
33952                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
33953                 LDKSignature val_conv_8_ref;
33954                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
33955                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
33956                 val_constr.data[i] = val_conv_8_ref;
33957         }
33958         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
33959 }
33960
33961 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
33962         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
33963 uint64_t ret_ref = 0;
33964 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33965 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33966 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33967 ret_ref = (uint64_t)ret_var.inner;
33968 if (ret_var.is_owned) {
33969         ret_ref |= 1;
33970 }
33971         return ret_ref;
33972 }
33973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33974         LDKHolderCommitmentTransaction arg_conv;
33975         arg_conv.inner = (void*)(arg & (~1));
33976         arg_conv.is_owned = false;
33977         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33978         int64_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
33979         return ret_val;
33980 }
33981
33982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33983         LDKHolderCommitmentTransaction orig_conv;
33984         orig_conv.inner = (void*)(orig & (~1));
33985         orig_conv.is_owned = false;
33986         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33987         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
33988         uint64_t ret_ref = 0;
33989         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33990         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
33993         if (ret_var.is_owned) {
33994                 ret_ref |= 1;
33995         }
33996         return ret_ref;
33997 }
33998
33999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
34000         LDKHolderCommitmentTransaction obj_conv;
34001         obj_conv.inner = (void*)(obj & (~1));
34002         obj_conv.is_owned = false;
34003         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34004         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
34005         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34006         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34007         CVec_u8Z_free(ret_var);
34008         return ret_arr;
34009 }
34010
34011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34012         LDKu8slice ser_ref;
34013         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34014         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34015         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
34016         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
34017         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34018         return (uint64_t)ret_conv;
34019 }
34020
34021 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) {
34022         LDKCommitmentTransaction commitment_tx_conv;
34023         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
34024         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
34025         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
34026         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
34027         LDKSignature counterparty_sig_ref;
34028         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
34029         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
34030         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
34031         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
34032         if (counterparty_htlc_sigs_constr.datalen > 0)
34033                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34034         else
34035                 counterparty_htlc_sigs_constr.data = NULL;
34036         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
34037                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
34038                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
34039                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
34040                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
34041                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
34042         }
34043         LDKPublicKey holder_funding_key_ref;
34044         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
34045         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
34046         LDKPublicKey counterparty_funding_key_ref;
34047         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
34048         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
34049         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
34050         uint64_t ret_ref = 0;
34051         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34052         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34054         ret_ref = (uint64_t)ret_var.inner;
34055         if (ret_var.is_owned) {
34056                 ret_ref |= 1;
34057         }
34058         return ret_ref;
34059 }
34060
34061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34062         LDKBuiltCommitmentTransaction this_obj_conv;
34063         this_obj_conv.inner = (void*)(this_obj & (~1));
34064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34066         BuiltCommitmentTransaction_free(this_obj_conv);
34067 }
34068
34069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
34070         LDKBuiltCommitmentTransaction this_ptr_conv;
34071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34072         this_ptr_conv.is_owned = false;
34073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34074         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
34075         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34076         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34077         Transaction_free(ret_var);
34078         return ret_arr;
34079 }
34080
34081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34082         LDKBuiltCommitmentTransaction this_ptr_conv;
34083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34084         this_ptr_conv.is_owned = false;
34085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34086         LDKTransaction val_ref;
34087         val_ref.datalen = (*env)->GetArrayLength(env, val);
34088         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
34089         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
34090         val_ref.data_is_owned = true;
34091         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
34092 }
34093
34094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
34095         LDKBuiltCommitmentTransaction this_ptr_conv;
34096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34097         this_ptr_conv.is_owned = false;
34098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34099         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34100         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
34101         return ret_arr;
34102 }
34103
34104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34105         LDKBuiltCommitmentTransaction this_ptr_conv;
34106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34107         this_ptr_conv.is_owned = false;
34108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34109         LDKThirtyTwoBytes val_ref;
34110         CHECK((*env)->GetArrayLength(env, val) == 32);
34111         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34112         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
34113 }
34114
34115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
34116         LDKTransaction transaction_arg_ref;
34117         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
34118         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
34119         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
34120         transaction_arg_ref.data_is_owned = true;
34121         LDKThirtyTwoBytes txid_arg_ref;
34122         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
34123         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
34124         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
34125         uint64_t ret_ref = 0;
34126         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34127         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34129         ret_ref = (uint64_t)ret_var.inner;
34130         if (ret_var.is_owned) {
34131                 ret_ref |= 1;
34132         }
34133         return ret_ref;
34134 }
34135
34136 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
34137         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
34138 uint64_t ret_ref = 0;
34139 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34140 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34141 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34142 ret_ref = (uint64_t)ret_var.inner;
34143 if (ret_var.is_owned) {
34144         ret_ref |= 1;
34145 }
34146         return ret_ref;
34147 }
34148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34149         LDKBuiltCommitmentTransaction arg_conv;
34150         arg_conv.inner = (void*)(arg & (~1));
34151         arg_conv.is_owned = false;
34152         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34153         int64_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
34154         return ret_val;
34155 }
34156
34157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34158         LDKBuiltCommitmentTransaction orig_conv;
34159         orig_conv.inner = (void*)(orig & (~1));
34160         orig_conv.is_owned = false;
34161         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34162         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
34163         uint64_t ret_ref = 0;
34164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34167         ret_ref = (uint64_t)ret_var.inner;
34168         if (ret_var.is_owned) {
34169                 ret_ref |= 1;
34170         }
34171         return ret_ref;
34172 }
34173
34174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
34175         LDKBuiltCommitmentTransaction obj_conv;
34176         obj_conv.inner = (void*)(obj & (~1));
34177         obj_conv.is_owned = false;
34178         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34179         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
34180         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34181         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34182         CVec_u8Z_free(ret_var);
34183         return ret_arr;
34184 }
34185
34186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34187         LDKu8slice ser_ref;
34188         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34189         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34190         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
34191         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
34192         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34193         return (uint64_t)ret_conv;
34194 }
34195
34196 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) {
34197         LDKBuiltCommitmentTransaction this_arg_conv;
34198         this_arg_conv.inner = (void*)(this_arg & (~1));
34199         this_arg_conv.is_owned = false;
34200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34201         LDKu8slice funding_redeemscript_ref;
34202         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
34203         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
34204         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34205         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
34206         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
34207         return ret_arr;
34208 }
34209
34210 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) {
34211         LDKBuiltCommitmentTransaction this_arg_conv;
34212         this_arg_conv.inner = (void*)(this_arg & (~1));
34213         this_arg_conv.is_owned = false;
34214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34215         unsigned char funding_key_arr[32];
34216         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
34217         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
34218         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34219         LDKu8slice funding_redeemscript_ref;
34220         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
34221         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
34222         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34223         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
34224         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
34225         return ret_arr;
34226 }
34227
34228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34229         LDKClosingTransaction this_obj_conv;
34230         this_obj_conv.inner = (void*)(this_obj & (~1));
34231         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34233         ClosingTransaction_free(this_obj_conv);
34234 }
34235
34236 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
34237         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
34238 uint64_t ret_ref = 0;
34239 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34240 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34241 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34242 ret_ref = (uint64_t)ret_var.inner;
34243 if (ret_var.is_owned) {
34244         ret_ref |= 1;
34245 }
34246         return ret_ref;
34247 }
34248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34249         LDKClosingTransaction arg_conv;
34250         arg_conv.inner = (void*)(arg & (~1));
34251         arg_conv.is_owned = false;
34252         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34253         int64_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
34254         return ret_val;
34255 }
34256
34257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34258         LDKClosingTransaction orig_conv;
34259         orig_conv.inner = (void*)(orig & (~1));
34260         orig_conv.is_owned = false;
34261         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34262         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
34263         uint64_t ret_ref = 0;
34264         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34265         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34267         ret_ref = (uint64_t)ret_var.inner;
34268         if (ret_var.is_owned) {
34269                 ret_ref |= 1;
34270         }
34271         return ret_ref;
34272 }
34273
34274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
34275         LDKClosingTransaction o_conv;
34276         o_conv.inner = (void*)(o & (~1));
34277         o_conv.is_owned = false;
34278         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34279         int64_t ret_val = ClosingTransaction_hash(&o_conv);
34280         return ret_val;
34281 }
34282
34283 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) {
34284         LDKCVec_u8Z to_holder_script_ref;
34285         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
34286         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34287         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
34288         LDKCVec_u8Z to_counterparty_script_ref;
34289         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
34290         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34291         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
34292         LDKOutPoint funding_outpoint_conv;
34293         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34294         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34295         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34296         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34297         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
34298         uint64_t ret_ref = 0;
34299         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34300         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34302         ret_ref = (uint64_t)ret_var.inner;
34303         if (ret_var.is_owned) {
34304                 ret_ref |= 1;
34305         }
34306         return ret_ref;
34307 }
34308
34309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
34310         LDKClosingTransaction this_arg_conv;
34311         this_arg_conv.inner = (void*)(this_arg & (~1));
34312         this_arg_conv.is_owned = false;
34313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34314         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
34315         uint64_t ret_ref = 0;
34316         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34317         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34319         ret_ref = (uint64_t)ret_var.inner;
34320         if (ret_var.is_owned) {
34321                 ret_ref |= 1;
34322         }
34323         return ret_ref;
34324 }
34325
34326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
34327         LDKClosingTransaction this_arg_conv;
34328         this_arg_conv.inner = (void*)(this_arg & (~1));
34329         this_arg_conv.is_owned = false;
34330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34331         LDKOutPoint funding_outpoint_conv;
34332         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34333         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34334         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34335         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34336         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
34337         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
34338         return (uint64_t)ret_conv;
34339 }
34340
34341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
34342         LDKClosingTransaction this_arg_conv;
34343         this_arg_conv.inner = (void*)(this_arg & (~1));
34344         this_arg_conv.is_owned = false;
34345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34346         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
34347         return ret_val;
34348 }
34349
34350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
34351         LDKClosingTransaction this_arg_conv;
34352         this_arg_conv.inner = (void*)(this_arg & (~1));
34353         this_arg_conv.is_owned = false;
34354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34355         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
34356         return ret_val;
34357 }
34358
34359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
34360         LDKClosingTransaction this_arg_conv;
34361         this_arg_conv.inner = (void*)(this_arg & (~1));
34362         this_arg_conv.is_owned = false;
34363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34364         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
34365         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34366         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34367         return ret_arr;
34368 }
34369
34370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
34371         LDKClosingTransaction this_arg_conv;
34372         this_arg_conv.inner = (void*)(this_arg & (~1));
34373         this_arg_conv.is_owned = false;
34374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34375         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
34376         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34377         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34378         return ret_arr;
34379 }
34380
34381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34382         LDKTrustedClosingTransaction this_obj_conv;
34383         this_obj_conv.inner = (void*)(this_obj & (~1));
34384         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34386         TrustedClosingTransaction_free(this_obj_conv);
34387 }
34388
34389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
34390         LDKTrustedClosingTransaction this_arg_conv;
34391         this_arg_conv.inner = (void*)(this_arg & (~1));
34392         this_arg_conv.is_owned = false;
34393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34394         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
34395         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34396         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34397         Transaction_free(ret_var);
34398         return ret_arr;
34399 }
34400
34401 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) {
34402         LDKTrustedClosingTransaction this_arg_conv;
34403         this_arg_conv.inner = (void*)(this_arg & (~1));
34404         this_arg_conv.is_owned = false;
34405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34406         LDKu8slice funding_redeemscript_ref;
34407         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
34408         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
34409         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34410         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
34411         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
34412         return ret_arr;
34413 }
34414
34415 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) {
34416         LDKTrustedClosingTransaction this_arg_conv;
34417         this_arg_conv.inner = (void*)(this_arg & (~1));
34418         this_arg_conv.is_owned = false;
34419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34420         unsigned char funding_key_arr[32];
34421         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
34422         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
34423         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34424         LDKu8slice funding_redeemscript_ref;
34425         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
34426         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
34427         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34428         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
34429         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
34430         return ret_arr;
34431 }
34432
34433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34434         LDKCommitmentTransaction this_obj_conv;
34435         this_obj_conv.inner = (void*)(this_obj & (~1));
34436         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34438         CommitmentTransaction_free(this_obj_conv);
34439 }
34440
34441 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
34442         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
34443 uint64_t ret_ref = 0;
34444 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34445 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34446 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34447 ret_ref = (uint64_t)ret_var.inner;
34448 if (ret_var.is_owned) {
34449         ret_ref |= 1;
34450 }
34451         return ret_ref;
34452 }
34453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34454         LDKCommitmentTransaction arg_conv;
34455         arg_conv.inner = (void*)(arg & (~1));
34456         arg_conv.is_owned = false;
34457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34458         int64_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
34459         return ret_val;
34460 }
34461
34462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34463         LDKCommitmentTransaction orig_conv;
34464         orig_conv.inner = (void*)(orig & (~1));
34465         orig_conv.is_owned = false;
34466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34467         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
34468         uint64_t ret_ref = 0;
34469         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34470         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34472         ret_ref = (uint64_t)ret_var.inner;
34473         if (ret_var.is_owned) {
34474                 ret_ref |= 1;
34475         }
34476         return ret_ref;
34477 }
34478
34479 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
34480         LDKCommitmentTransaction obj_conv;
34481         obj_conv.inner = (void*)(obj & (~1));
34482         obj_conv.is_owned = false;
34483         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34484         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
34485         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34486         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34487         CVec_u8Z_free(ret_var);
34488         return ret_arr;
34489 }
34490
34491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34492         LDKu8slice ser_ref;
34493         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34494         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34495         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
34496         *ret_conv = CommitmentTransaction_read(ser_ref);
34497         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34498         return (uint64_t)ret_conv;
34499 }
34500
34501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
34502         LDKCommitmentTransaction this_arg_conv;
34503         this_arg_conv.inner = (void*)(this_arg & (~1));
34504         this_arg_conv.is_owned = false;
34505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34506         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
34507         return ret_val;
34508 }
34509
34510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
34511         LDKCommitmentTransaction this_arg_conv;
34512         this_arg_conv.inner = (void*)(this_arg & (~1));
34513         this_arg_conv.is_owned = false;
34514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34515         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
34516         return ret_val;
34517 }
34518
34519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
34520         LDKCommitmentTransaction this_arg_conv;
34521         this_arg_conv.inner = (void*)(this_arg & (~1));
34522         this_arg_conv.is_owned = false;
34523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34524         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
34525         return ret_val;
34526 }
34527
34528 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
34529         LDKCommitmentTransaction this_arg_conv;
34530         this_arg_conv.inner = (void*)(this_arg & (~1));
34531         this_arg_conv.is_owned = false;
34532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34533         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
34534         return ret_val;
34535 }
34536
34537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
34538         LDKCommitmentTransaction this_arg_conv;
34539         this_arg_conv.inner = (void*)(this_arg & (~1));
34540         this_arg_conv.is_owned = false;
34541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34542         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
34543         uint64_t ret_ref = 0;
34544         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34545         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34547         ret_ref = (uint64_t)ret_var.inner;
34548         if (ret_var.is_owned) {
34549                 ret_ref |= 1;
34550         }
34551         return ret_ref;
34552 }
34553
34554 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) {
34555         LDKCommitmentTransaction this_arg_conv;
34556         this_arg_conv.inner = (void*)(this_arg & (~1));
34557         this_arg_conv.is_owned = false;
34558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34559         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34560         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34561         channel_parameters_conv.is_owned = false;
34562         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34563         LDKChannelPublicKeys broadcaster_keys_conv;
34564         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34565         broadcaster_keys_conv.is_owned = false;
34566         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34567         LDKChannelPublicKeys countersignatory_keys_conv;
34568         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34569         countersignatory_keys_conv.is_owned = false;
34570         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34571         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
34572         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
34573         return (uint64_t)ret_conv;
34574 }
34575
34576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34577         LDKTrustedCommitmentTransaction this_obj_conv;
34578         this_obj_conv.inner = (void*)(this_obj & (~1));
34579         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34581         TrustedCommitmentTransaction_free(this_obj_conv);
34582 }
34583
34584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
34585         LDKTrustedCommitmentTransaction this_arg_conv;
34586         this_arg_conv.inner = (void*)(this_arg & (~1));
34587         this_arg_conv.is_owned = false;
34588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34589         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34590         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
34591         return ret_arr;
34592 }
34593
34594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
34595         LDKTrustedCommitmentTransaction this_arg_conv;
34596         this_arg_conv.inner = (void*)(this_arg & (~1));
34597         this_arg_conv.is_owned = false;
34598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34599         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
34600         uint64_t ret_ref = 0;
34601         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34602         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34604         ret_ref = (uint64_t)ret_var.inner;
34605         if (ret_var.is_owned) {
34606                 ret_ref |= 1;
34607         }
34608         return ret_ref;
34609 }
34610
34611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
34612         LDKTrustedCommitmentTransaction this_arg_conv;
34613         this_arg_conv.inner = (void*)(this_arg & (~1));
34614         this_arg_conv.is_owned = false;
34615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34616         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
34617         uint64_t ret_ref = 0;
34618         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34619         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34621         ret_ref = (uint64_t)ret_var.inner;
34622         if (ret_var.is_owned) {
34623                 ret_ref |= 1;
34624         }
34625         return ret_ref;
34626 }
34627
34628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
34629         LDKTrustedCommitmentTransaction this_arg_conv;
34630         this_arg_conv.inner = (void*)(this_arg & (~1));
34631         this_arg_conv.is_owned = false;
34632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34633         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
34634         return ret_val;
34635 }
34636
34637 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) {
34638         LDKTrustedCommitmentTransaction this_arg_conv;
34639         this_arg_conv.inner = (void*)(this_arg & (~1));
34640         this_arg_conv.is_owned = false;
34641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34642         unsigned char htlc_base_key_arr[32];
34643         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
34644         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
34645         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
34646         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34647         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34648         channel_parameters_conv.is_owned = false;
34649         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34650         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
34651         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
34652         return (uint64_t)ret_conv;
34653 }
34654
34655 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) {
34656         LDKPublicKey broadcaster_payment_basepoint_ref;
34657         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
34658         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
34659         LDKPublicKey countersignatory_payment_basepoint_ref;
34660         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
34661         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
34662         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
34663         return ret_val;
34664 }
34665
34666 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34667         LDKInitFeatures a_conv;
34668         a_conv.inner = (void*)(a & (~1));
34669         a_conv.is_owned = false;
34670         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34671         LDKInitFeatures b_conv;
34672         b_conv.inner = (void*)(b & (~1));
34673         b_conv.is_owned = false;
34674         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34675         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
34676         return ret_val;
34677 }
34678
34679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34680         LDKNodeFeatures a_conv;
34681         a_conv.inner = (void*)(a & (~1));
34682         a_conv.is_owned = false;
34683         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34684         LDKNodeFeatures b_conv;
34685         b_conv.inner = (void*)(b & (~1));
34686         b_conv.is_owned = false;
34687         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34688         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
34689         return ret_val;
34690 }
34691
34692 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34693         LDKChannelFeatures a_conv;
34694         a_conv.inner = (void*)(a & (~1));
34695         a_conv.is_owned = false;
34696         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34697         LDKChannelFeatures b_conv;
34698         b_conv.inner = (void*)(b & (~1));
34699         b_conv.is_owned = false;
34700         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34701         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
34702         return ret_val;
34703 }
34704
34705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34706         LDKInvoiceFeatures a_conv;
34707         a_conv.inner = (void*)(a & (~1));
34708         a_conv.is_owned = false;
34709         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34710         LDKInvoiceFeatures b_conv;
34711         b_conv.inner = (void*)(b & (~1));
34712         b_conv.is_owned = false;
34713         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34714         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
34715         return ret_val;
34716 }
34717
34718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34719         LDKChannelTypeFeatures a_conv;
34720         a_conv.inner = (void*)(a & (~1));
34721         a_conv.is_owned = false;
34722         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34723         LDKChannelTypeFeatures b_conv;
34724         b_conv.inner = (void*)(b & (~1));
34725         b_conv.is_owned = false;
34726         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34727         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
34728         return ret_val;
34729 }
34730
34731 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
34732         LDKInitFeatures ret_var = InitFeatures_clone(arg);
34733 uint64_t ret_ref = 0;
34734 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34735 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34736 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34737 ret_ref = (uint64_t)ret_var.inner;
34738 if (ret_var.is_owned) {
34739         ret_ref |= 1;
34740 }
34741         return ret_ref;
34742 }
34743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34744         LDKInitFeatures arg_conv;
34745         arg_conv.inner = (void*)(arg & (~1));
34746         arg_conv.is_owned = false;
34747         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34748         int64_t ret_val = InitFeatures_clone_ptr(&arg_conv);
34749         return ret_val;
34750 }
34751
34752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34753         LDKInitFeatures orig_conv;
34754         orig_conv.inner = (void*)(orig & (~1));
34755         orig_conv.is_owned = false;
34756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34757         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
34758         uint64_t ret_ref = 0;
34759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34762         ret_ref = (uint64_t)ret_var.inner;
34763         if (ret_var.is_owned) {
34764                 ret_ref |= 1;
34765         }
34766         return ret_ref;
34767 }
34768
34769 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
34770         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
34771 uint64_t ret_ref = 0;
34772 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34773 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34774 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34775 ret_ref = (uint64_t)ret_var.inner;
34776 if (ret_var.is_owned) {
34777         ret_ref |= 1;
34778 }
34779         return ret_ref;
34780 }
34781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34782         LDKNodeFeatures arg_conv;
34783         arg_conv.inner = (void*)(arg & (~1));
34784         arg_conv.is_owned = false;
34785         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34786         int64_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
34787         return ret_val;
34788 }
34789
34790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34791         LDKNodeFeatures orig_conv;
34792         orig_conv.inner = (void*)(orig & (~1));
34793         orig_conv.is_owned = false;
34794         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34795         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
34796         uint64_t ret_ref = 0;
34797         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34798         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34800         ret_ref = (uint64_t)ret_var.inner;
34801         if (ret_var.is_owned) {
34802                 ret_ref |= 1;
34803         }
34804         return ret_ref;
34805 }
34806
34807 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
34808         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
34809 uint64_t ret_ref = 0;
34810 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34811 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34812 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34813 ret_ref = (uint64_t)ret_var.inner;
34814 if (ret_var.is_owned) {
34815         ret_ref |= 1;
34816 }
34817         return ret_ref;
34818 }
34819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34820         LDKChannelFeatures arg_conv;
34821         arg_conv.inner = (void*)(arg & (~1));
34822         arg_conv.is_owned = false;
34823         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34824         int64_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
34825         return ret_val;
34826 }
34827
34828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34829         LDKChannelFeatures orig_conv;
34830         orig_conv.inner = (void*)(orig & (~1));
34831         orig_conv.is_owned = false;
34832         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34833         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
34834         uint64_t ret_ref = 0;
34835         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34836         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34838         ret_ref = (uint64_t)ret_var.inner;
34839         if (ret_var.is_owned) {
34840                 ret_ref |= 1;
34841         }
34842         return ret_ref;
34843 }
34844
34845 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
34846         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
34847 uint64_t ret_ref = 0;
34848 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34849 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34850 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34851 ret_ref = (uint64_t)ret_var.inner;
34852 if (ret_var.is_owned) {
34853         ret_ref |= 1;
34854 }
34855         return ret_ref;
34856 }
34857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34858         LDKInvoiceFeatures arg_conv;
34859         arg_conv.inner = (void*)(arg & (~1));
34860         arg_conv.is_owned = false;
34861         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34862         int64_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
34863         return ret_val;
34864 }
34865
34866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34867         LDKInvoiceFeatures orig_conv;
34868         orig_conv.inner = (void*)(orig & (~1));
34869         orig_conv.is_owned = false;
34870         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34871         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
34872         uint64_t ret_ref = 0;
34873         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34874         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34876         ret_ref = (uint64_t)ret_var.inner;
34877         if (ret_var.is_owned) {
34878                 ret_ref |= 1;
34879         }
34880         return ret_ref;
34881 }
34882
34883 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
34884         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
34885 uint64_t ret_ref = 0;
34886 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34887 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34888 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34889 ret_ref = (uint64_t)ret_var.inner;
34890 if (ret_var.is_owned) {
34891         ret_ref |= 1;
34892 }
34893         return ret_ref;
34894 }
34895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34896         LDKChannelTypeFeatures arg_conv;
34897         arg_conv.inner = (void*)(arg & (~1));
34898         arg_conv.is_owned = false;
34899         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34900         int64_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
34901         return ret_val;
34902 }
34903
34904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34905         LDKChannelTypeFeatures orig_conv;
34906         orig_conv.inner = (void*)(orig & (~1));
34907         orig_conv.is_owned = false;
34908         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34909         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
34910         uint64_t ret_ref = 0;
34911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34914         ret_ref = (uint64_t)ret_var.inner;
34915         if (ret_var.is_owned) {
34916                 ret_ref |= 1;
34917         }
34918         return ret_ref;
34919 }
34920
34921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34922         LDKInitFeatures this_obj_conv;
34923         this_obj_conv.inner = (void*)(this_obj & (~1));
34924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34926         InitFeatures_free(this_obj_conv);
34927 }
34928
34929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34930         LDKNodeFeatures this_obj_conv;
34931         this_obj_conv.inner = (void*)(this_obj & (~1));
34932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34934         NodeFeatures_free(this_obj_conv);
34935 }
34936
34937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34938         LDKChannelFeatures this_obj_conv;
34939         this_obj_conv.inner = (void*)(this_obj & (~1));
34940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34942         ChannelFeatures_free(this_obj_conv);
34943 }
34944
34945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34946         LDKInvoiceFeatures this_obj_conv;
34947         this_obj_conv.inner = (void*)(this_obj & (~1));
34948         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34950         InvoiceFeatures_free(this_obj_conv);
34951 }
34952
34953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34954         LDKChannelTypeFeatures this_obj_conv;
34955         this_obj_conv.inner = (void*)(this_obj & (~1));
34956         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34958         ChannelTypeFeatures_free(this_obj_conv);
34959 }
34960
34961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
34962         LDKInitFeatures ret_var = InitFeatures_empty();
34963         uint64_t ret_ref = 0;
34964         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34965         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34967         ret_ref = (uint64_t)ret_var.inner;
34968         if (ret_var.is_owned) {
34969                 ret_ref |= 1;
34970         }
34971         return ret_ref;
34972 }
34973
34974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
34975         LDKInitFeatures ret_var = InitFeatures_known();
34976         uint64_t ret_ref = 0;
34977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34980         ret_ref = (uint64_t)ret_var.inner;
34981         if (ret_var.is_owned) {
34982                 ret_ref |= 1;
34983         }
34984         return ret_ref;
34985 }
34986
34987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
34988         LDKInitFeatures this_arg_conv;
34989         this_arg_conv.inner = (void*)(this_arg & (~1));
34990         this_arg_conv.is_owned = false;
34991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34992         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
34993         return ret_val;
34994 }
34995
34996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
34997         LDKNodeFeatures ret_var = NodeFeatures_empty();
34998         uint64_t ret_ref = 0;
34999         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35000         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35002         ret_ref = (uint64_t)ret_var.inner;
35003         if (ret_var.is_owned) {
35004                 ret_ref |= 1;
35005         }
35006         return ret_ref;
35007 }
35008
35009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
35010         LDKNodeFeatures ret_var = NodeFeatures_known();
35011         uint64_t ret_ref = 0;
35012         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35013         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35015         ret_ref = (uint64_t)ret_var.inner;
35016         if (ret_var.is_owned) {
35017                 ret_ref |= 1;
35018         }
35019         return ret_ref;
35020 }
35021
35022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
35023         LDKNodeFeatures this_arg_conv;
35024         this_arg_conv.inner = (void*)(this_arg & (~1));
35025         this_arg_conv.is_owned = false;
35026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35027         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
35028         return ret_val;
35029 }
35030
35031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
35032         LDKChannelFeatures ret_var = ChannelFeatures_empty();
35033         uint64_t ret_ref = 0;
35034         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35035         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35037         ret_ref = (uint64_t)ret_var.inner;
35038         if (ret_var.is_owned) {
35039                 ret_ref |= 1;
35040         }
35041         return ret_ref;
35042 }
35043
35044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
35045         LDKChannelFeatures ret_var = ChannelFeatures_known();
35046         uint64_t ret_ref = 0;
35047         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35048         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35050         ret_ref = (uint64_t)ret_var.inner;
35051         if (ret_var.is_owned) {
35052                 ret_ref |= 1;
35053         }
35054         return ret_ref;
35055 }
35056
35057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
35058         LDKChannelFeatures this_arg_conv;
35059         this_arg_conv.inner = (void*)(this_arg & (~1));
35060         this_arg_conv.is_owned = false;
35061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35062         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
35063         return ret_val;
35064 }
35065
35066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
35067         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
35068         uint64_t ret_ref = 0;
35069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35072         ret_ref = (uint64_t)ret_var.inner;
35073         if (ret_var.is_owned) {
35074                 ret_ref |= 1;
35075         }
35076         return ret_ref;
35077 }
35078
35079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
35080         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
35081         uint64_t ret_ref = 0;
35082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35085         ret_ref = (uint64_t)ret_var.inner;
35086         if (ret_var.is_owned) {
35087                 ret_ref |= 1;
35088         }
35089         return ret_ref;
35090 }
35091
35092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
35093         LDKInvoiceFeatures this_arg_conv;
35094         this_arg_conv.inner = (void*)(this_arg & (~1));
35095         this_arg_conv.is_owned = false;
35096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35097         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
35098         return ret_val;
35099 }
35100
35101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
35102         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
35103         uint64_t ret_ref = 0;
35104         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35105         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35107         ret_ref = (uint64_t)ret_var.inner;
35108         if (ret_var.is_owned) {
35109                 ret_ref |= 1;
35110         }
35111         return ret_ref;
35112 }
35113
35114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
35115         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
35116         uint64_t ret_ref = 0;
35117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35120         ret_ref = (uint64_t)ret_var.inner;
35121         if (ret_var.is_owned) {
35122                 ret_ref |= 1;
35123         }
35124         return ret_ref;
35125 }
35126
35127 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
35128         LDKChannelTypeFeatures this_arg_conv;
35129         this_arg_conv.inner = (void*)(this_arg & (~1));
35130         this_arg_conv.is_owned = false;
35131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35132         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
35133         return ret_val;
35134 }
35135
35136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
35137         LDKInitFeatures obj_conv;
35138         obj_conv.inner = (void*)(obj & (~1));
35139         obj_conv.is_owned = false;
35140         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35141         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
35142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35144         CVec_u8Z_free(ret_var);
35145         return ret_arr;
35146 }
35147
35148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35149         LDKu8slice ser_ref;
35150         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35151         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35152         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
35153         *ret_conv = InitFeatures_read(ser_ref);
35154         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35155         return (uint64_t)ret_conv;
35156 }
35157
35158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
35159         LDKChannelFeatures obj_conv;
35160         obj_conv.inner = (void*)(obj & (~1));
35161         obj_conv.is_owned = false;
35162         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35163         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
35164         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35165         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35166         CVec_u8Z_free(ret_var);
35167         return ret_arr;
35168 }
35169
35170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35171         LDKu8slice ser_ref;
35172         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35173         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35174         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
35175         *ret_conv = ChannelFeatures_read(ser_ref);
35176         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35177         return (uint64_t)ret_conv;
35178 }
35179
35180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
35181         LDKNodeFeatures obj_conv;
35182         obj_conv.inner = (void*)(obj & (~1));
35183         obj_conv.is_owned = false;
35184         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35185         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
35186         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35187         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35188         CVec_u8Z_free(ret_var);
35189         return ret_arr;
35190 }
35191
35192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35193         LDKu8slice ser_ref;
35194         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35195         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35196         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
35197         *ret_conv = NodeFeatures_read(ser_ref);
35198         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35199         return (uint64_t)ret_conv;
35200 }
35201
35202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
35203         LDKInvoiceFeatures obj_conv;
35204         obj_conv.inner = (void*)(obj & (~1));
35205         obj_conv.is_owned = false;
35206         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35207         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
35208         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35209         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35210         CVec_u8Z_free(ret_var);
35211         return ret_arr;
35212 }
35213
35214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35215         LDKu8slice ser_ref;
35216         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35217         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35218         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
35219         *ret_conv = InvoiceFeatures_read(ser_ref);
35220         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35221         return (uint64_t)ret_conv;
35222 }
35223
35224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
35225         LDKChannelTypeFeatures obj_conv;
35226         obj_conv.inner = (void*)(obj & (~1));
35227         obj_conv.is_owned = false;
35228         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35229         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
35230         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35231         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35232         CVec_u8Z_free(ret_var);
35233         return ret_arr;
35234 }
35235
35236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35237         LDKu8slice ser_ref;
35238         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35239         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35240         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
35241         *ret_conv = ChannelTypeFeatures_read(ser_ref);
35242         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35243         return (uint64_t)ret_conv;
35244 }
35245
35246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35247         LDKShutdownScript this_obj_conv;
35248         this_obj_conv.inner = (void*)(this_obj & (~1));
35249         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35251         ShutdownScript_free(this_obj_conv);
35252 }
35253
35254 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
35255         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
35256 uint64_t ret_ref = 0;
35257 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35258 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35259 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35260 ret_ref = (uint64_t)ret_var.inner;
35261 if (ret_var.is_owned) {
35262         ret_ref |= 1;
35263 }
35264         return ret_ref;
35265 }
35266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35267         LDKShutdownScript arg_conv;
35268         arg_conv.inner = (void*)(arg & (~1));
35269         arg_conv.is_owned = false;
35270         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35271         int64_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
35272         return ret_val;
35273 }
35274
35275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35276         LDKShutdownScript orig_conv;
35277         orig_conv.inner = (void*)(orig & (~1));
35278         orig_conv.is_owned = false;
35279         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35280         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
35281         uint64_t ret_ref = 0;
35282         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35283         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35285         ret_ref = (uint64_t)ret_var.inner;
35286         if (ret_var.is_owned) {
35287                 ret_ref |= 1;
35288         }
35289         return ret_ref;
35290 }
35291
35292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35293         LDKInvalidShutdownScript this_obj_conv;
35294         this_obj_conv.inner = (void*)(this_obj & (~1));
35295         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35297         InvalidShutdownScript_free(this_obj_conv);
35298 }
35299
35300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
35301         LDKInvalidShutdownScript this_ptr_conv;
35302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35303         this_ptr_conv.is_owned = false;
35304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35305         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
35306         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35307         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35308         return ret_arr;
35309 }
35310
35311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35312         LDKInvalidShutdownScript this_ptr_conv;
35313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35314         this_ptr_conv.is_owned = false;
35315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35316         LDKCVec_u8Z val_ref;
35317         val_ref.datalen = (*env)->GetArrayLength(env, val);
35318         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35319         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
35320         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
35321 }
35322
35323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
35324         LDKCVec_u8Z script_arg_ref;
35325         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
35326         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35327         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
35328         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
35329         uint64_t ret_ref = 0;
35330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35333         ret_ref = (uint64_t)ret_var.inner;
35334         if (ret_var.is_owned) {
35335                 ret_ref |= 1;
35336         }
35337         return ret_ref;
35338 }
35339
35340 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
35341         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
35342 uint64_t ret_ref = 0;
35343 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35344 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35345 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35346 ret_ref = (uint64_t)ret_var.inner;
35347 if (ret_var.is_owned) {
35348         ret_ref |= 1;
35349 }
35350         return ret_ref;
35351 }
35352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35353         LDKInvalidShutdownScript arg_conv;
35354         arg_conv.inner = (void*)(arg & (~1));
35355         arg_conv.is_owned = false;
35356         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35357         int64_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
35358         return ret_val;
35359 }
35360
35361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35362         LDKInvalidShutdownScript orig_conv;
35363         orig_conv.inner = (void*)(orig & (~1));
35364         orig_conv.is_owned = false;
35365         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35366         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
35367         uint64_t ret_ref = 0;
35368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35371         ret_ref = (uint64_t)ret_var.inner;
35372         if (ret_var.is_owned) {
35373                 ret_ref |= 1;
35374         }
35375         return ret_ref;
35376 }
35377
35378 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
35379         LDKShutdownScript obj_conv;
35380         obj_conv.inner = (void*)(obj & (~1));
35381         obj_conv.is_owned = false;
35382         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35383         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
35384         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35385         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35386         CVec_u8Z_free(ret_var);
35387         return ret_arr;
35388 }
35389
35390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35391         LDKu8slice ser_ref;
35392         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35393         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35394         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
35395         *ret_conv = ShutdownScript_read(ser_ref);
35396         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35397         return (uint64_t)ret_conv;
35398 }
35399
35400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
35401         unsigned char pubkey_hash_arr[20];
35402         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
35403         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
35404         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
35405         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
35406         uint64_t ret_ref = 0;
35407         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35408         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35410         ret_ref = (uint64_t)ret_var.inner;
35411         if (ret_var.is_owned) {
35412                 ret_ref |= 1;
35413         }
35414         return ret_ref;
35415 }
35416
35417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
35418         unsigned char script_hash_arr[32];
35419         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
35420         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
35421         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
35422         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
35423         uint64_t ret_ref = 0;
35424         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35425         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35427         ret_ref = (uint64_t)ret_var.inner;
35428         if (ret_var.is_owned) {
35429                 ret_ref |= 1;
35430         }
35431         return ret_ref;
35432 }
35433
35434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
35435         LDKu8slice program_ref;
35436         program_ref.datalen = (*env)->GetArrayLength(env, program);
35437         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
35438         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
35439         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
35440         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
35441         return (uint64_t)ret_conv;
35442 }
35443
35444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
35445         LDKShutdownScript this_arg_conv;
35446         this_arg_conv.inner = (void*)(this_arg & (~1));
35447         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35449         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
35450         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
35451         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35452         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35453         CVec_u8Z_free(ret_var);
35454         return ret_arr;
35455 }
35456
35457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
35458         LDKShutdownScript this_arg_conv;
35459         this_arg_conv.inner = (void*)(this_arg & (~1));
35460         this_arg_conv.is_owned = false;
35461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35462         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35463         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
35464         return ret_arr;
35465 }
35466
35467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
35468         LDKShutdownScript this_arg_conv;
35469         this_arg_conv.inner = (void*)(this_arg & (~1));
35470         this_arg_conv.is_owned = false;
35471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35472         LDKInitFeatures features_conv;
35473         features_conv.inner = (void*)(features & (~1));
35474         features_conv.is_owned = false;
35475         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
35476         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
35477         return ret_val;
35478 }
35479
35480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35481         if ((this_ptr & 1) != 0) return;
35482         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
35483         CHECK_ACCESS(this_ptr_ptr);
35484         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
35485         FREE((void*)this_ptr);
35486         CustomMessageReader_free(this_ptr_conv);
35487 }
35488
35489 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
35490         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35491         *ret_ret = Type_clone(arg);
35492         return (uint64_t)ret_ret;
35493 }
35494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35495         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
35496         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35497         LDKType* arg_conv = (LDKType*)arg_ptr;
35498         int64_t ret_val = Type_clone_ptr(arg_conv);
35499         return ret_val;
35500 }
35501
35502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35503         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
35504         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35505         LDKType* orig_conv = (LDKType*)orig_ptr;
35506         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35507         *ret_ret = Type_clone(orig_conv);
35508         return (uint64_t)ret_ret;
35509 }
35510
35511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35512         if ((this_ptr & 1) != 0) return;
35513         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
35514         CHECK_ACCESS(this_ptr_ptr);
35515         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
35516         FREE((void*)this_ptr);
35517         Type_free(this_ptr_conv);
35518 }
35519
35520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35521         LDKNodeId this_obj_conv;
35522         this_obj_conv.inner = (void*)(this_obj & (~1));
35523         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35525         NodeId_free(this_obj_conv);
35526 }
35527
35528 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
35529         LDKNodeId ret_var = NodeId_clone(arg);
35530 uint64_t ret_ref = 0;
35531 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35532 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35533 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35534 ret_ref = (uint64_t)ret_var.inner;
35535 if (ret_var.is_owned) {
35536         ret_ref |= 1;
35537 }
35538         return ret_ref;
35539 }
35540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35541         LDKNodeId arg_conv;
35542         arg_conv.inner = (void*)(arg & (~1));
35543         arg_conv.is_owned = false;
35544         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35545         int64_t ret_val = NodeId_clone_ptr(&arg_conv);
35546         return ret_val;
35547 }
35548
35549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35550         LDKNodeId orig_conv;
35551         orig_conv.inner = (void*)(orig & (~1));
35552         orig_conv.is_owned = false;
35553         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35554         LDKNodeId ret_var = NodeId_clone(&orig_conv);
35555         uint64_t ret_ref = 0;
35556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35559         ret_ref = (uint64_t)ret_var.inner;
35560         if (ret_var.is_owned) {
35561                 ret_ref |= 1;
35562         }
35563         return ret_ref;
35564 }
35565
35566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
35567         LDKPublicKey pubkey_ref;
35568         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
35569         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
35570         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
35571         uint64_t ret_ref = 0;
35572         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35573         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35575         ret_ref = (uint64_t)ret_var.inner;
35576         if (ret_var.is_owned) {
35577                 ret_ref |= 1;
35578         }
35579         return ret_ref;
35580 }
35581
35582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
35583         LDKNodeId this_arg_conv;
35584         this_arg_conv.inner = (void*)(this_arg & (~1));
35585         this_arg_conv.is_owned = false;
35586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35587         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
35588         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35589         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35590         return ret_arr;
35591 }
35592
35593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
35594         LDKNodeId o_conv;
35595         o_conv.inner = (void*)(o & (~1));
35596         o_conv.is_owned = false;
35597         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35598         int64_t ret_val = NodeId_hash(&o_conv);
35599         return ret_val;
35600 }
35601
35602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
35603         LDKNodeId obj_conv;
35604         obj_conv.inner = (void*)(obj & (~1));
35605         obj_conv.is_owned = false;
35606         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35607         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
35608         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35609         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35610         CVec_u8Z_free(ret_var);
35611         return ret_arr;
35612 }
35613
35614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35615         LDKu8slice ser_ref;
35616         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35617         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35618         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
35619         *ret_conv = NodeId_read(ser_ref);
35620         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35621         return (uint64_t)ret_conv;
35622 }
35623
35624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35625         LDKNetworkGraph this_obj_conv;
35626         this_obj_conv.inner = (void*)(this_obj & (~1));
35627         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35629         NetworkGraph_free(this_obj_conv);
35630 }
35631
35632 static inline uint64_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
35633         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
35634 uint64_t ret_ref = 0;
35635 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35636 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35637 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35638 ret_ref = (uint64_t)ret_var.inner;
35639 if (ret_var.is_owned) {
35640         ret_ref |= 1;
35641 }
35642         return ret_ref;
35643 }
35644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35645         LDKNetworkGraph arg_conv;
35646         arg_conv.inner = (void*)(arg & (~1));
35647         arg_conv.is_owned = false;
35648         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35649         int64_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
35650         return ret_val;
35651 }
35652
35653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35654         LDKNetworkGraph orig_conv;
35655         orig_conv.inner = (void*)(orig & (~1));
35656         orig_conv.is_owned = false;
35657         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35658         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
35659         uint64_t ret_ref = 0;
35660         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35661         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35663         ret_ref = (uint64_t)ret_var.inner;
35664         if (ret_var.is_owned) {
35665                 ret_ref |= 1;
35666         }
35667         return ret_ref;
35668 }
35669
35670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35671         LDKReadOnlyNetworkGraph this_obj_conv;
35672         this_obj_conv.inner = (void*)(this_obj & (~1));
35673         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35675         ReadOnlyNetworkGraph_free(this_obj_conv);
35676 }
35677
35678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35679         if ((this_ptr & 1) != 0) return;
35680         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
35681         CHECK_ACCESS(this_ptr_ptr);
35682         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
35683         FREE((void*)this_ptr);
35684         NetworkUpdate_free(this_ptr_conv);
35685 }
35686
35687 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
35688         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35689         *ret_copy = NetworkUpdate_clone(arg);
35690 uint64_t ret_ref = (uint64_t)ret_copy;
35691         return ret_ref;
35692 }
35693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35694         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
35695         int64_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
35696         return ret_val;
35697 }
35698
35699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35700         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
35701         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35702         *ret_copy = NetworkUpdate_clone(orig_conv);
35703         uint64_t ret_ref = (uint64_t)ret_copy;
35704         return ret_ref;
35705 }
35706
35707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
35708         LDKChannelUpdate msg_conv;
35709         msg_conv.inner = (void*)(msg & (~1));
35710         msg_conv.is_owned = (msg & 1) || (msg == 0);
35711         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35712         msg_conv = ChannelUpdate_clone(&msg_conv);
35713         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35714         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
35715         uint64_t ret_ref = (uint64_t)ret_copy;
35716         return ret_ref;
35717 }
35718
35719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
35720         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35721         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
35722         uint64_t ret_ref = (uint64_t)ret_copy;
35723         return ret_ref;
35724 }
35725
35726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
35727         LDKPublicKey node_id_ref;
35728         CHECK((*env)->GetArrayLength(env, node_id) == 33);
35729         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
35730         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35731         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
35732         uint64_t ret_ref = (uint64_t)ret_copy;
35733         return ret_ref;
35734 }
35735
35736 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35737         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
35738         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
35739         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35740         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35741         CVec_u8Z_free(ret_var);
35742         return ret_arr;
35743 }
35744
35745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35746         LDKu8slice ser_ref;
35747         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35748         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35749         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
35750         *ret_conv = NetworkUpdate_read(ser_ref);
35751         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35752         return (uint64_t)ret_conv;
35753 }
35754
35755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
35756         LDKNetGraphMsgHandler this_arg_conv;
35757         this_arg_conv.inner = (void*)(this_arg & (~1));
35758         this_arg_conv.is_owned = false;
35759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35760         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
35761         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
35762         return (uint64_t)ret_ret;
35763 }
35764
35765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35766         LDKNetGraphMsgHandler this_obj_conv;
35767         this_obj_conv.inner = (void*)(this_obj & (~1));
35768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35770         NetGraphMsgHandler_free(this_obj_conv);
35771 }
35772
35773 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) {
35774         LDKNetworkGraph network_graph_conv;
35775         network_graph_conv.inner = (void*)(network_graph & (~1));
35776         network_graph_conv.is_owned = false;
35777         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
35778         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
35779         CHECK_ACCESS(chain_access_ptr);
35780         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
35781         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
35782         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
35783                 // Manually implement clone for Java trait instances
35784                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
35785                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35786                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
35787                 }
35788         }
35789         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
35790         CHECK_ACCESS(logger_ptr);
35791         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
35792         if (logger_conv.free == LDKLogger_JCalls_free) {
35793                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35794                 LDKLogger_JCalls_cloned(&logger_conv);
35795         }
35796         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
35797         uint64_t ret_ref = 0;
35798         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35799         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35801         ret_ref = (uint64_t)ret_var.inner;
35802         if (ret_var.is_owned) {
35803                 ret_ref |= 1;
35804         }
35805         return ret_ref;
35806 }
35807
35808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
35809         LDKNetGraphMsgHandler this_arg_conv;
35810         this_arg_conv.inner = (void*)(this_arg & (~1));
35811         this_arg_conv.is_owned = false;
35812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35813         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
35814         CHECK_ACCESS(chain_access_ptr);
35815         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
35816         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
35817         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
35818                 // Manually implement clone for Java trait instances
35819                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
35820                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35821                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
35822                 }
35823         }
35824         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
35825 }
35826
35827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
35828         LDKNetGraphMsgHandler this_arg_conv;
35829         this_arg_conv.inner = (void*)(this_arg & (~1));
35830         this_arg_conv.is_owned = false;
35831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35832         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
35833         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
35834         return (uint64_t)ret_ret;
35835 }
35836
35837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
35838         LDKNetGraphMsgHandler this_arg_conv;
35839         this_arg_conv.inner = (void*)(this_arg & (~1));
35840         this_arg_conv.is_owned = false;
35841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35842         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
35843         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
35844         return (uint64_t)ret_ret;
35845 }
35846
35847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35848         LDKDirectionalChannelInfo this_obj_conv;
35849         this_obj_conv.inner = (void*)(this_obj & (~1));
35850         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35852         DirectionalChannelInfo_free(this_obj_conv);
35853 }
35854
35855 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
35856         LDKDirectionalChannelInfo this_ptr_conv;
35857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35858         this_ptr_conv.is_owned = false;
35859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35860         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
35861         return ret_val;
35862 }
35863
35864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35865         LDKDirectionalChannelInfo this_ptr_conv;
35866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35867         this_ptr_conv.is_owned = false;
35868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35869         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
35870 }
35871
35872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
35873         LDKDirectionalChannelInfo this_ptr_conv;
35874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35875         this_ptr_conv.is_owned = false;
35876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35877         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
35878         return ret_val;
35879 }
35880
35881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35882         LDKDirectionalChannelInfo this_ptr_conv;
35883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35884         this_ptr_conv.is_owned = false;
35885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35886         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
35887 }
35888
35889 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
35890         LDKDirectionalChannelInfo this_ptr_conv;
35891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35892         this_ptr_conv.is_owned = false;
35893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35894         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
35895         return ret_val;
35896 }
35897
35898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35899         LDKDirectionalChannelInfo this_ptr_conv;
35900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35901         this_ptr_conv.is_owned = false;
35902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35903         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
35904 }
35905
35906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35907         LDKDirectionalChannelInfo this_ptr_conv;
35908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35909         this_ptr_conv.is_owned = false;
35910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35911         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
35912         return ret_val;
35913 }
35914
35915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35916         LDKDirectionalChannelInfo this_ptr_conv;
35917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35918         this_ptr_conv.is_owned = false;
35919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35920         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
35921 }
35922
35923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35924         LDKDirectionalChannelInfo this_ptr_conv;
35925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35926         this_ptr_conv.is_owned = false;
35927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35928         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35929         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
35930         uint64_t ret_ref = (uint64_t)ret_copy;
35931         return ret_ref;
35932 }
35933
35934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35935         LDKDirectionalChannelInfo this_ptr_conv;
35936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35937         this_ptr_conv.is_owned = false;
35938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35939         void* val_ptr = (void*)(((uint64_t)val) & ~1);
35940         CHECK_ACCESS(val_ptr);
35941         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35942         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
35943         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
35944 }
35945
35946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
35947         LDKDirectionalChannelInfo this_ptr_conv;
35948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35949         this_ptr_conv.is_owned = false;
35950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35951         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
35952         uint64_t ret_ref = 0;
35953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35956         ret_ref = (uint64_t)ret_var.inner;
35957         if (ret_var.is_owned) {
35958                 ret_ref |= 1;
35959         }
35960         return ret_ref;
35961 }
35962
35963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35964         LDKDirectionalChannelInfo this_ptr_conv;
35965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35966         this_ptr_conv.is_owned = false;
35967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35968         LDKRoutingFees val_conv;
35969         val_conv.inner = (void*)(val & (~1));
35970         val_conv.is_owned = (val & 1) || (val == 0);
35971         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35972         val_conv = RoutingFees_clone(&val_conv);
35973         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
35974 }
35975
35976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
35977         LDKDirectionalChannelInfo this_ptr_conv;
35978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35979         this_ptr_conv.is_owned = false;
35980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35981         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
35982         uint64_t ret_ref = 0;
35983         if ((uint64_t)ret_var.inner > 4096) {
35984                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35985                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35987                 ret_ref = (uint64_t)ret_var.inner;
35988                 if (ret_var.is_owned) {
35989                         ret_ref |= 1;
35990                 }
35991         }
35992         return ret_ref;
35993 }
35994
35995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35996         LDKDirectionalChannelInfo this_ptr_conv;
35997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35998         this_ptr_conv.is_owned = false;
35999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36000         LDKChannelUpdate val_conv;
36001         val_conv.inner = (void*)(val & (~1));
36002         val_conv.is_owned = (val & 1) || (val == 0);
36003         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36004         val_conv = ChannelUpdate_clone(&val_conv);
36005         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
36006 }
36007
36008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_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) {
36009         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
36010         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
36011         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
36012         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
36013         LDKRoutingFees fees_arg_conv;
36014         fees_arg_conv.inner = (void*)(fees_arg & (~1));
36015         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
36016         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
36017         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
36018         LDKChannelUpdate last_update_message_arg_conv;
36019         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
36020         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
36021         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
36022         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
36023         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_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);
36024         uint64_t ret_ref = 0;
36025         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36026         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36028         ret_ref = (uint64_t)ret_var.inner;
36029         if (ret_var.is_owned) {
36030                 ret_ref |= 1;
36031         }
36032         return ret_ref;
36033 }
36034
36035 static inline uint64_t DirectionalChannelInfo_clone_ptr(LDKDirectionalChannelInfo *NONNULL_PTR arg) {
36036         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(arg);
36037 uint64_t ret_ref = 0;
36038 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36039 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36040 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36041 ret_ref = (uint64_t)ret_var.inner;
36042 if (ret_var.is_owned) {
36043         ret_ref |= 1;
36044 }
36045         return ret_ref;
36046 }
36047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36048         LDKDirectionalChannelInfo arg_conv;
36049         arg_conv.inner = (void*)(arg & (~1));
36050         arg_conv.is_owned = false;
36051         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36052         int64_t ret_val = DirectionalChannelInfo_clone_ptr(&arg_conv);
36053         return ret_val;
36054 }
36055
36056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36057         LDKDirectionalChannelInfo orig_conv;
36058         orig_conv.inner = (void*)(orig & (~1));
36059         orig_conv.is_owned = false;
36060         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36061         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
36062         uint64_t ret_ref = 0;
36063         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36064         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36066         ret_ref = (uint64_t)ret_var.inner;
36067         if (ret_var.is_owned) {
36068                 ret_ref |= 1;
36069         }
36070         return ret_ref;
36071 }
36072
36073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
36074         LDKDirectionalChannelInfo obj_conv;
36075         obj_conv.inner = (void*)(obj & (~1));
36076         obj_conv.is_owned = false;
36077         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36078         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
36079         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36080         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36081         CVec_u8Z_free(ret_var);
36082         return ret_arr;
36083 }
36084
36085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36086         LDKu8slice ser_ref;
36087         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36088         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36089         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
36090         *ret_conv = DirectionalChannelInfo_read(ser_ref);
36091         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36092         return (uint64_t)ret_conv;
36093 }
36094
36095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36096         LDKChannelInfo this_obj_conv;
36097         this_obj_conv.inner = (void*)(this_obj & (~1));
36098         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36100         ChannelInfo_free(this_obj_conv);
36101 }
36102
36103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36104         LDKChannelInfo this_ptr_conv;
36105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36106         this_ptr_conv.is_owned = false;
36107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36108         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
36109         uint64_t ret_ref = 0;
36110         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36111         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36113         ret_ref = (uint64_t)ret_var.inner;
36114         if (ret_var.is_owned) {
36115                 ret_ref |= 1;
36116         }
36117         return ret_ref;
36118 }
36119
36120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36121         LDKChannelInfo this_ptr_conv;
36122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36123         this_ptr_conv.is_owned = false;
36124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36125         LDKChannelFeatures val_conv;
36126         val_conv.inner = (void*)(val & (~1));
36127         val_conv.is_owned = (val & 1) || (val == 0);
36128         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36129         val_conv = ChannelFeatures_clone(&val_conv);
36130         ChannelInfo_set_features(&this_ptr_conv, val_conv);
36131 }
36132
36133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
36134         LDKChannelInfo this_ptr_conv;
36135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36136         this_ptr_conv.is_owned = false;
36137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36138         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
36139         uint64_t ret_ref = 0;
36140         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36141         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36143         ret_ref = (uint64_t)ret_var.inner;
36144         if (ret_var.is_owned) {
36145                 ret_ref |= 1;
36146         }
36147         return ret_ref;
36148 }
36149
36150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36151         LDKChannelInfo this_ptr_conv;
36152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36153         this_ptr_conv.is_owned = false;
36154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36155         LDKNodeId val_conv;
36156         val_conv.inner = (void*)(val & (~1));
36157         val_conv.is_owned = (val & 1) || (val == 0);
36158         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36159         val_conv = NodeId_clone(&val_conv);
36160         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
36161 }
36162
36163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
36164         LDKChannelInfo this_ptr_conv;
36165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36166         this_ptr_conv.is_owned = false;
36167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36168         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
36169         uint64_t ret_ref = 0;
36170         if ((uint64_t)ret_var.inner > 4096) {
36171                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36172                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36174                 ret_ref = (uint64_t)ret_var.inner;
36175                 if (ret_var.is_owned) {
36176                         ret_ref |= 1;
36177                 }
36178         }
36179         return ret_ref;
36180 }
36181
36182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36183         LDKChannelInfo this_ptr_conv;
36184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36185         this_ptr_conv.is_owned = false;
36186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36187         LDKDirectionalChannelInfo val_conv;
36188         val_conv.inner = (void*)(val & (~1));
36189         val_conv.is_owned = (val & 1) || (val == 0);
36190         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36191         val_conv = DirectionalChannelInfo_clone(&val_conv);
36192         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
36193 }
36194
36195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
36196         LDKChannelInfo this_ptr_conv;
36197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36198         this_ptr_conv.is_owned = false;
36199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36200         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
36201         uint64_t ret_ref = 0;
36202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36205         ret_ref = (uint64_t)ret_var.inner;
36206         if (ret_var.is_owned) {
36207                 ret_ref |= 1;
36208         }
36209         return ret_ref;
36210 }
36211
36212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36213         LDKChannelInfo this_ptr_conv;
36214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36215         this_ptr_conv.is_owned = false;
36216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36217         LDKNodeId val_conv;
36218         val_conv.inner = (void*)(val & (~1));
36219         val_conv.is_owned = (val & 1) || (val == 0);
36220         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36221         val_conv = NodeId_clone(&val_conv);
36222         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
36223 }
36224
36225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
36226         LDKChannelInfo this_ptr_conv;
36227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36228         this_ptr_conv.is_owned = false;
36229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36230         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
36231         uint64_t ret_ref = 0;
36232         if ((uint64_t)ret_var.inner > 4096) {
36233                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36234                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36236                 ret_ref = (uint64_t)ret_var.inner;
36237                 if (ret_var.is_owned) {
36238                         ret_ref |= 1;
36239                 }
36240         }
36241         return ret_ref;
36242 }
36243
36244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36245         LDKChannelInfo this_ptr_conv;
36246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36247         this_ptr_conv.is_owned = false;
36248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36249         LDKDirectionalChannelInfo val_conv;
36250         val_conv.inner = (void*)(val & (~1));
36251         val_conv.is_owned = (val & 1) || (val == 0);
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36253         val_conv = DirectionalChannelInfo_clone(&val_conv);
36254         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
36255 }
36256
36257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
36258         LDKChannelInfo this_ptr_conv;
36259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36260         this_ptr_conv.is_owned = false;
36261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36262         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36263         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
36264         uint64_t ret_ref = (uint64_t)ret_copy;
36265         return ret_ref;
36266 }
36267
36268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36269         LDKChannelInfo this_ptr_conv;
36270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36271         this_ptr_conv.is_owned = false;
36272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36273         void* val_ptr = (void*)(((uint64_t)val) & ~1);
36274         CHECK_ACCESS(val_ptr);
36275         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36276         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
36277         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
36278 }
36279
36280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
36281         LDKChannelInfo this_ptr_conv;
36282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36283         this_ptr_conv.is_owned = false;
36284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36285         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
36286         uint64_t ret_ref = 0;
36287         if ((uint64_t)ret_var.inner > 4096) {
36288                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36289                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36291                 ret_ref = (uint64_t)ret_var.inner;
36292                 if (ret_var.is_owned) {
36293                         ret_ref |= 1;
36294                 }
36295         }
36296         return ret_ref;
36297 }
36298
36299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36300         LDKChannelInfo this_ptr_conv;
36301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36302         this_ptr_conv.is_owned = false;
36303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36304         LDKChannelAnnouncement val_conv;
36305         val_conv.inner = (void*)(val & (~1));
36306         val_conv.is_owned = (val & 1) || (val == 0);
36307         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36308         val_conv = ChannelAnnouncement_clone(&val_conv);
36309         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
36310 }
36311
36312 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
36313         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
36314 uint64_t ret_ref = 0;
36315 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36316 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36317 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36318 ret_ref = (uint64_t)ret_var.inner;
36319 if (ret_var.is_owned) {
36320         ret_ref |= 1;
36321 }
36322         return ret_ref;
36323 }
36324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36325         LDKChannelInfo arg_conv;
36326         arg_conv.inner = (void*)(arg & (~1));
36327         arg_conv.is_owned = false;
36328         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36329         int64_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
36330         return ret_val;
36331 }
36332
36333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36334         LDKChannelInfo orig_conv;
36335         orig_conv.inner = (void*)(orig & (~1));
36336         orig_conv.is_owned = false;
36337         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36338         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
36339         uint64_t ret_ref = 0;
36340         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36341         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36343         ret_ref = (uint64_t)ret_var.inner;
36344         if (ret_var.is_owned) {
36345                 ret_ref |= 1;
36346         }
36347         return ret_ref;
36348 }
36349
36350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
36351         LDKChannelInfo obj_conv;
36352         obj_conv.inner = (void*)(obj & (~1));
36353         obj_conv.is_owned = false;
36354         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36355         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
36356         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36357         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36358         CVec_u8Z_free(ret_var);
36359         return ret_arr;
36360 }
36361
36362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36363         LDKu8slice ser_ref;
36364         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36365         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36366         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
36367         *ret_conv = ChannelInfo_read(ser_ref);
36368         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36369         return (uint64_t)ret_conv;
36370 }
36371
36372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36373         LDKRoutingFees this_obj_conv;
36374         this_obj_conv.inner = (void*)(this_obj & (~1));
36375         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36377         RoutingFees_free(this_obj_conv);
36378 }
36379
36380 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36381         LDKRoutingFees this_ptr_conv;
36382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36383         this_ptr_conv.is_owned = false;
36384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36385         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
36386         return ret_val;
36387 }
36388
36389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36390         LDKRoutingFees this_ptr_conv;
36391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36392         this_ptr_conv.is_owned = false;
36393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36394         RoutingFees_set_base_msat(&this_ptr_conv, val);
36395 }
36396
36397 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
36398         LDKRoutingFees this_ptr_conv;
36399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36400         this_ptr_conv.is_owned = false;
36401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36402         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
36403         return ret_val;
36404 }
36405
36406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36407         LDKRoutingFees this_ptr_conv;
36408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36409         this_ptr_conv.is_owned = false;
36410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36411         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
36412 }
36413
36414 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) {
36415         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
36416         uint64_t ret_ref = 0;
36417         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36418         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36420         ret_ref = (uint64_t)ret_var.inner;
36421         if (ret_var.is_owned) {
36422                 ret_ref |= 1;
36423         }
36424         return ret_ref;
36425 }
36426
36427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36428         LDKRoutingFees a_conv;
36429         a_conv.inner = (void*)(a & (~1));
36430         a_conv.is_owned = false;
36431         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36432         LDKRoutingFees b_conv;
36433         b_conv.inner = (void*)(b & (~1));
36434         b_conv.is_owned = false;
36435         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36436         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
36437         return ret_val;
36438 }
36439
36440 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
36441         LDKRoutingFees ret_var = RoutingFees_clone(arg);
36442 uint64_t ret_ref = 0;
36443 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36444 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36445 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36446 ret_ref = (uint64_t)ret_var.inner;
36447 if (ret_var.is_owned) {
36448         ret_ref |= 1;
36449 }
36450         return ret_ref;
36451 }
36452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36453         LDKRoutingFees arg_conv;
36454         arg_conv.inner = (void*)(arg & (~1));
36455         arg_conv.is_owned = false;
36456         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36457         int64_t ret_val = RoutingFees_clone_ptr(&arg_conv);
36458         return ret_val;
36459 }
36460
36461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36462         LDKRoutingFees orig_conv;
36463         orig_conv.inner = (void*)(orig & (~1));
36464         orig_conv.is_owned = false;
36465         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36466         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
36467         uint64_t ret_ref = 0;
36468         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36469         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36471         ret_ref = (uint64_t)ret_var.inner;
36472         if (ret_var.is_owned) {
36473                 ret_ref |= 1;
36474         }
36475         return ret_ref;
36476 }
36477
36478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
36479         LDKRoutingFees o_conv;
36480         o_conv.inner = (void*)(o & (~1));
36481         o_conv.is_owned = false;
36482         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36483         int64_t ret_val = RoutingFees_hash(&o_conv);
36484         return ret_val;
36485 }
36486
36487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
36488         LDKRoutingFees obj_conv;
36489         obj_conv.inner = (void*)(obj & (~1));
36490         obj_conv.is_owned = false;
36491         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36492         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
36493         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36494         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36495         CVec_u8Z_free(ret_var);
36496         return ret_arr;
36497 }
36498
36499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36500         LDKu8slice ser_ref;
36501         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36502         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36503         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
36504         *ret_conv = RoutingFees_read(ser_ref);
36505         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36506         return (uint64_t)ret_conv;
36507 }
36508
36509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36510         LDKNodeAnnouncementInfo this_obj_conv;
36511         this_obj_conv.inner = (void*)(this_obj & (~1));
36512         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36514         NodeAnnouncementInfo_free(this_obj_conv);
36515 }
36516
36517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36518         LDKNodeAnnouncementInfo this_ptr_conv;
36519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36520         this_ptr_conv.is_owned = false;
36521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36522         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
36523         uint64_t ret_ref = 0;
36524         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36525         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36527         ret_ref = (uint64_t)ret_var.inner;
36528         if (ret_var.is_owned) {
36529                 ret_ref |= 1;
36530         }
36531         return ret_ref;
36532 }
36533
36534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36535         LDKNodeAnnouncementInfo this_ptr_conv;
36536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36537         this_ptr_conv.is_owned = false;
36538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36539         LDKNodeFeatures val_conv;
36540         val_conv.inner = (void*)(val & (~1));
36541         val_conv.is_owned = (val & 1) || (val == 0);
36542         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36543         val_conv = NodeFeatures_clone(&val_conv);
36544         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
36545 }
36546
36547 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
36548         LDKNodeAnnouncementInfo this_ptr_conv;
36549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36550         this_ptr_conv.is_owned = false;
36551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36552         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
36553         return ret_val;
36554 }
36555
36556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36557         LDKNodeAnnouncementInfo this_ptr_conv;
36558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36559         this_ptr_conv.is_owned = false;
36560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36561         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
36562 }
36563
36564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
36565         LDKNodeAnnouncementInfo this_ptr_conv;
36566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36567         this_ptr_conv.is_owned = false;
36568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36569         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
36570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
36571         return ret_arr;
36572 }
36573
36574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36575         LDKNodeAnnouncementInfo this_ptr_conv;
36576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36577         this_ptr_conv.is_owned = false;
36578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36579         LDKThreeBytes val_ref;
36580         CHECK((*env)->GetArrayLength(env, val) == 3);
36581         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
36582         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
36583 }
36584
36585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
36586         LDKNodeAnnouncementInfo this_ptr_conv;
36587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36588         this_ptr_conv.is_owned = false;
36589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36590         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
36592         return ret_arr;
36593 }
36594
36595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36596         LDKNodeAnnouncementInfo this_ptr_conv;
36597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36598         this_ptr_conv.is_owned = false;
36599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36600         LDKThirtyTwoBytes val_ref;
36601         CHECK((*env)->GetArrayLength(env, val) == 32);
36602         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36603         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
36604 }
36605
36606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36607         LDKNodeAnnouncementInfo this_ptr_conv;
36608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36609         this_ptr_conv.is_owned = false;
36610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36611         LDKCVec_NetAddressZ val_constr;
36612         val_constr.datalen = (*env)->GetArrayLength(env, val);
36613         if (val_constr.datalen > 0)
36614                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36615         else
36616                 val_constr.data = NULL;
36617         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36618         for (size_t m = 0; m < val_constr.datalen; m++) {
36619                 int64_t val_conv_12 = val_vals[m];
36620                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
36621                 CHECK_ACCESS(val_conv_12_ptr);
36622                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
36623                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
36624                 val_constr.data[m] = val_conv_12_conv;
36625         }
36626         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36627         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
36628 }
36629
36630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
36631         LDKNodeAnnouncementInfo this_ptr_conv;
36632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36633         this_ptr_conv.is_owned = false;
36634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36635         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
36636         uint64_t ret_ref = 0;
36637         if ((uint64_t)ret_var.inner > 4096) {
36638                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36639                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36641                 ret_ref = (uint64_t)ret_var.inner;
36642                 if (ret_var.is_owned) {
36643                         ret_ref |= 1;
36644                 }
36645         }
36646         return ret_ref;
36647 }
36648
36649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36650         LDKNodeAnnouncementInfo this_ptr_conv;
36651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36652         this_ptr_conv.is_owned = false;
36653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36654         LDKNodeAnnouncement val_conv;
36655         val_conv.inner = (void*)(val & (~1));
36656         val_conv.is_owned = (val & 1) || (val == 0);
36657         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36658         val_conv = NodeAnnouncement_clone(&val_conv);
36659         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
36660 }
36661
36662 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) {
36663         LDKNodeFeatures features_arg_conv;
36664         features_arg_conv.inner = (void*)(features_arg & (~1));
36665         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
36666         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
36667         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
36668         LDKThreeBytes rgb_arg_ref;
36669         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
36670         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
36671         LDKThirtyTwoBytes alias_arg_ref;
36672         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
36673         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
36674         LDKCVec_NetAddressZ addresses_arg_constr;
36675         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
36676         if (addresses_arg_constr.datalen > 0)
36677                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36678         else
36679                 addresses_arg_constr.data = NULL;
36680         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
36681         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
36682                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
36683                 void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
36684                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
36685                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
36686                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
36687         }
36688         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
36689         LDKNodeAnnouncement announcement_message_arg_conv;
36690         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
36691         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
36692         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
36693         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
36694         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
36695         uint64_t ret_ref = 0;
36696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36699         ret_ref = (uint64_t)ret_var.inner;
36700         if (ret_var.is_owned) {
36701                 ret_ref |= 1;
36702         }
36703         return ret_ref;
36704 }
36705
36706 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
36707         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
36708 uint64_t ret_ref = 0;
36709 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36710 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36711 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36712 ret_ref = (uint64_t)ret_var.inner;
36713 if (ret_var.is_owned) {
36714         ret_ref |= 1;
36715 }
36716         return ret_ref;
36717 }
36718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36719         LDKNodeAnnouncementInfo arg_conv;
36720         arg_conv.inner = (void*)(arg & (~1));
36721         arg_conv.is_owned = false;
36722         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36723         int64_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
36724         return ret_val;
36725 }
36726
36727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36728         LDKNodeAnnouncementInfo orig_conv;
36729         orig_conv.inner = (void*)(orig & (~1));
36730         orig_conv.is_owned = false;
36731         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36732         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
36733         uint64_t ret_ref = 0;
36734         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36735         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36737         ret_ref = (uint64_t)ret_var.inner;
36738         if (ret_var.is_owned) {
36739                 ret_ref |= 1;
36740         }
36741         return ret_ref;
36742 }
36743
36744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
36745         LDKNodeAnnouncementInfo obj_conv;
36746         obj_conv.inner = (void*)(obj & (~1));
36747         obj_conv.is_owned = false;
36748         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36749         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
36750         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36751         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36752         CVec_u8Z_free(ret_var);
36753         return ret_arr;
36754 }
36755
36756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36757         LDKu8slice ser_ref;
36758         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36759         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36760         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
36761         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
36762         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36763         return (uint64_t)ret_conv;
36764 }
36765
36766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36767         LDKNodeInfo this_obj_conv;
36768         this_obj_conv.inner = (void*)(this_obj & (~1));
36769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36771         NodeInfo_free(this_obj_conv);
36772 }
36773
36774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36775         LDKNodeInfo this_ptr_conv;
36776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36777         this_ptr_conv.is_owned = false;
36778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36779         LDKCVec_u64Z val_constr;
36780         val_constr.datalen = (*env)->GetArrayLength(env, val);
36781         if (val_constr.datalen > 0)
36782                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36783         else
36784                 val_constr.data = NULL;
36785         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36786         for (size_t g = 0; g < val_constr.datalen; g++) {
36787                 int64_t val_conv_6 = val_vals[g];
36788                 val_constr.data[g] = val_conv_6;
36789         }
36790         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36791         NodeInfo_set_channels(&this_ptr_conv, val_constr);
36792 }
36793
36794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
36795         LDKNodeInfo this_ptr_conv;
36796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36797         this_ptr_conv.is_owned = false;
36798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36799         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
36800         uint64_t ret_ref = 0;
36801         if ((uint64_t)ret_var.inner > 4096) {
36802                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36803                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36805                 ret_ref = (uint64_t)ret_var.inner;
36806                 if (ret_var.is_owned) {
36807                         ret_ref |= 1;
36808                 }
36809         }
36810         return ret_ref;
36811 }
36812
36813 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) {
36814         LDKNodeInfo 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         LDKRoutingFees val_conv;
36819         val_conv.inner = (void*)(val & (~1));
36820         val_conv.is_owned = (val & 1) || (val == 0);
36821         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36822         val_conv = RoutingFees_clone(&val_conv);
36823         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
36824 }
36825
36826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
36827         LDKNodeInfo this_ptr_conv;
36828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36829         this_ptr_conv.is_owned = false;
36830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36831         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
36832         uint64_t ret_ref = 0;
36833         if ((uint64_t)ret_var.inner > 4096) {
36834                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36835                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36837                 ret_ref = (uint64_t)ret_var.inner;
36838                 if (ret_var.is_owned) {
36839                         ret_ref |= 1;
36840                 }
36841         }
36842         return ret_ref;
36843 }
36844
36845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36846         LDKNodeInfo this_ptr_conv;
36847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36848         this_ptr_conv.is_owned = false;
36849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36850         LDKNodeAnnouncementInfo val_conv;
36851         val_conv.inner = (void*)(val & (~1));
36852         val_conv.is_owned = (val & 1) || (val == 0);
36853         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36854         val_conv = NodeAnnouncementInfo_clone(&val_conv);
36855         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
36856 }
36857
36858 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) {
36859         LDKCVec_u64Z channels_arg_constr;
36860         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
36861         if (channels_arg_constr.datalen > 0)
36862                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36863         else
36864                 channels_arg_constr.data = NULL;
36865         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
36866         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
36867                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
36868                 channels_arg_constr.data[g] = channels_arg_conv_6;
36869         }
36870         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
36871         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
36872         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
36873         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
36874         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
36875         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
36876         LDKNodeAnnouncementInfo announcement_info_arg_conv;
36877         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
36878         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
36879         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
36880         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
36881         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
36882         uint64_t ret_ref = 0;
36883         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36884         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36886         ret_ref = (uint64_t)ret_var.inner;
36887         if (ret_var.is_owned) {
36888                 ret_ref |= 1;
36889         }
36890         return ret_ref;
36891 }
36892
36893 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
36894         LDKNodeInfo ret_var = NodeInfo_clone(arg);
36895 uint64_t ret_ref = 0;
36896 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36897 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36898 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36899 ret_ref = (uint64_t)ret_var.inner;
36900 if (ret_var.is_owned) {
36901         ret_ref |= 1;
36902 }
36903         return ret_ref;
36904 }
36905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36906         LDKNodeInfo arg_conv;
36907         arg_conv.inner = (void*)(arg & (~1));
36908         arg_conv.is_owned = false;
36909         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36910         int64_t ret_val = NodeInfo_clone_ptr(&arg_conv);
36911         return ret_val;
36912 }
36913
36914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36915         LDKNodeInfo orig_conv;
36916         orig_conv.inner = (void*)(orig & (~1));
36917         orig_conv.is_owned = false;
36918         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36919         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
36920         uint64_t ret_ref = 0;
36921         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36922         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36924         ret_ref = (uint64_t)ret_var.inner;
36925         if (ret_var.is_owned) {
36926                 ret_ref |= 1;
36927         }
36928         return ret_ref;
36929 }
36930
36931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
36932         LDKNodeInfo obj_conv;
36933         obj_conv.inner = (void*)(obj & (~1));
36934         obj_conv.is_owned = false;
36935         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36936         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
36937         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36938         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36939         CVec_u8Z_free(ret_var);
36940         return ret_arr;
36941 }
36942
36943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36944         LDKu8slice ser_ref;
36945         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36946         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36947         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
36948         *ret_conv = NodeInfo_read(ser_ref);
36949         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36950         return (uint64_t)ret_conv;
36951 }
36952
36953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
36954         LDKNetworkGraph obj_conv;
36955         obj_conv.inner = (void*)(obj & (~1));
36956         obj_conv.is_owned = false;
36957         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36958         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
36959         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36960         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36961         CVec_u8Z_free(ret_var);
36962         return ret_arr;
36963 }
36964
36965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36966         LDKu8slice ser_ref;
36967         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36968         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36969         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
36970         *ret_conv = NetworkGraph_read(ser_ref);
36971         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36972         return (uint64_t)ret_conv;
36973 }
36974
36975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
36976         LDKThirtyTwoBytes genesis_hash_ref;
36977         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
36978         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
36979         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
36980         uint64_t ret_ref = 0;
36981         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36982         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36984         ret_ref = (uint64_t)ret_var.inner;
36985         if (ret_var.is_owned) {
36986                 ret_ref |= 1;
36987         }
36988         return ret_ref;
36989 }
36990
36991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
36992         LDKNetworkGraph this_arg_conv;
36993         this_arg_conv.inner = (void*)(this_arg & (~1));
36994         this_arg_conv.is_owned = false;
36995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36996         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
36997         uint64_t ret_ref = 0;
36998         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36999         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37001         ret_ref = (uint64_t)ret_var.inner;
37002         if (ret_var.is_owned) {
37003                 ret_ref |= 1;
37004         }
37005         return ret_ref;
37006 }
37007
37008 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) {
37009         LDKNetworkGraph this_arg_conv;
37010         this_arg_conv.inner = (void*)(this_arg & (~1));
37011         this_arg_conv.is_owned = false;
37012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37013         LDKNodeAnnouncement msg_conv;
37014         msg_conv.inner = (void*)(msg & (~1));
37015         msg_conv.is_owned = false;
37016         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37017         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37018         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
37019         return (uint64_t)ret_conv;
37020 }
37021
37022 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) {
37023         LDKNetworkGraph this_arg_conv;
37024         this_arg_conv.inner = (void*)(this_arg & (~1));
37025         this_arg_conv.is_owned = false;
37026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37027         LDKUnsignedNodeAnnouncement msg_conv;
37028         msg_conv.inner = (void*)(msg & (~1));
37029         msg_conv.is_owned = false;
37030         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37031         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37032         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
37033         return (uint64_t)ret_conv;
37034 }
37035
37036 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) {
37037         LDKNetworkGraph this_arg_conv;
37038         this_arg_conv.inner = (void*)(this_arg & (~1));
37039         this_arg_conv.is_owned = false;
37040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37041         LDKChannelAnnouncement msg_conv;
37042         msg_conv.inner = (void*)(msg & (~1));
37043         msg_conv.is_owned = false;
37044         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37045         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
37046         CHECK_ACCESS(chain_access_ptr);
37047         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37048         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
37049         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37050                 // Manually implement clone for Java trait instances
37051                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37052                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37053                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37054                 }
37055         }
37056         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37057         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37058         return (uint64_t)ret_conv;
37059 }
37060
37061 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) {
37062         LDKNetworkGraph this_arg_conv;
37063         this_arg_conv.inner = (void*)(this_arg & (~1));
37064         this_arg_conv.is_owned = false;
37065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37066         LDKUnsignedChannelAnnouncement msg_conv;
37067         msg_conv.inner = (void*)(msg & (~1));
37068         msg_conv.is_owned = false;
37069         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37070         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
37071         CHECK_ACCESS(chain_access_ptr);
37072         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37073         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
37074         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37075                 // Manually implement clone for Java trait instances
37076                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37077                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37078                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37079                 }
37080         }
37081         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37082         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37083         return (uint64_t)ret_conv;
37084 }
37085
37086 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) {
37087         LDKNetworkGraph this_arg_conv;
37088         this_arg_conv.inner = (void*)(this_arg & (~1));
37089         this_arg_conv.is_owned = false;
37090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37091         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
37092 }
37093
37094 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) {
37095         LDKNetworkGraph this_arg_conv;
37096         this_arg_conv.inner = (void*)(this_arg & (~1));
37097         this_arg_conv.is_owned = false;
37098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37099         LDKPublicKey _node_id_ref;
37100         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
37101         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
37102         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
37103 }
37104
37105 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) {
37106         LDKNetworkGraph this_arg_conv;
37107         this_arg_conv.inner = (void*)(this_arg & (~1));
37108         this_arg_conv.is_owned = false;
37109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37110         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
37111 }
37112
37113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
37114         LDKNetworkGraph this_arg_conv;
37115         this_arg_conv.inner = (void*)(this_arg & (~1));
37116         this_arg_conv.is_owned = false;
37117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37118         LDKChannelUpdate msg_conv;
37119         msg_conv.inner = (void*)(msg & (~1));
37120         msg_conv.is_owned = false;
37121         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37122         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37123         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
37124         return (uint64_t)ret_conv;
37125 }
37126
37127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
37128         LDKNetworkGraph this_arg_conv;
37129         this_arg_conv.inner = (void*)(this_arg & (~1));
37130         this_arg_conv.is_owned = false;
37131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37132         LDKUnsignedChannelUpdate msg_conv;
37133         msg_conv.inner = (void*)(msg & (~1));
37134         msg_conv.is_owned = false;
37135         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37136         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37137         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
37138         return (uint64_t)ret_conv;
37139 }
37140
37141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
37142         LDKReadOnlyNetworkGraph this_arg_conv;
37143         this_arg_conv.inner = (void*)(this_arg & (~1));
37144         this_arg_conv.is_owned = false;
37145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37146         LDKPublicKey pubkey_ref;
37147         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
37148         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
37149         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
37150         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
37151         uint64_t ret_ref = (uint64_t)ret_copy;
37152         return ret_ref;
37153 }
37154
37155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37156         LDKRouteHop this_obj_conv;
37157         this_obj_conv.inner = (void*)(this_obj & (~1));
37158         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37160         RouteHop_free(this_obj_conv);
37161 }
37162
37163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
37164         LDKRouteHop this_ptr_conv;
37165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37166         this_ptr_conv.is_owned = false;
37167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37168         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37169         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
37170         return ret_arr;
37171 }
37172
37173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37174         LDKRouteHop this_ptr_conv;
37175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37176         this_ptr_conv.is_owned = false;
37177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37178         LDKPublicKey val_ref;
37179         CHECK((*env)->GetArrayLength(env, val) == 33);
37180         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37181         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
37182 }
37183
37184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
37185         LDKRouteHop this_ptr_conv;
37186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37187         this_ptr_conv.is_owned = false;
37188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37189         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
37190         uint64_t ret_ref = 0;
37191         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37192         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37194         ret_ref = (uint64_t)ret_var.inner;
37195         if (ret_var.is_owned) {
37196                 ret_ref |= 1;
37197         }
37198         return ret_ref;
37199 }
37200
37201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37202         LDKRouteHop this_ptr_conv;
37203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37204         this_ptr_conv.is_owned = false;
37205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37206         LDKNodeFeatures val_conv;
37207         val_conv.inner = (void*)(val & (~1));
37208         val_conv.is_owned = (val & 1) || (val == 0);
37209         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37210         val_conv = NodeFeatures_clone(&val_conv);
37211         RouteHop_set_node_features(&this_ptr_conv, val_conv);
37212 }
37213
37214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37215         LDKRouteHop this_ptr_conv;
37216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37217         this_ptr_conv.is_owned = false;
37218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37219         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
37220         return ret_val;
37221 }
37222
37223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37224         LDKRouteHop this_ptr_conv;
37225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37226         this_ptr_conv.is_owned = false;
37227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37228         RouteHop_set_short_channel_id(&this_ptr_conv, val);
37229 }
37230
37231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
37232         LDKRouteHop this_ptr_conv;
37233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37234         this_ptr_conv.is_owned = false;
37235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37236         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
37237         uint64_t ret_ref = 0;
37238         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37239         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37241         ret_ref = (uint64_t)ret_var.inner;
37242         if (ret_var.is_owned) {
37243                 ret_ref |= 1;
37244         }
37245         return ret_ref;
37246 }
37247
37248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37249         LDKRouteHop this_ptr_conv;
37250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37251         this_ptr_conv.is_owned = false;
37252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37253         LDKChannelFeatures val_conv;
37254         val_conv.inner = (void*)(val & (~1));
37255         val_conv.is_owned = (val & 1) || (val == 0);
37256         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37257         val_conv = ChannelFeatures_clone(&val_conv);
37258         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
37259 }
37260
37261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37262         LDKRouteHop this_ptr_conv;
37263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37264         this_ptr_conv.is_owned = false;
37265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37266         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
37267         return ret_val;
37268 }
37269
37270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37271         LDKRouteHop this_ptr_conv;
37272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37273         this_ptr_conv.is_owned = false;
37274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37275         RouteHop_set_fee_msat(&this_ptr_conv, val);
37276 }
37277
37278 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
37279         LDKRouteHop this_ptr_conv;
37280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37281         this_ptr_conv.is_owned = false;
37282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37283         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
37284         return ret_val;
37285 }
37286
37287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37288         LDKRouteHop this_ptr_conv;
37289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37290         this_ptr_conv.is_owned = false;
37291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37292         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37293 }
37294
37295 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) {
37296         LDKPublicKey pubkey_arg_ref;
37297         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
37298         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
37299         LDKNodeFeatures node_features_arg_conv;
37300         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
37301         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
37302         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
37303         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
37304         LDKChannelFeatures channel_features_arg_conv;
37305         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
37306         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
37307         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
37308         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
37309         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);
37310         uint64_t ret_ref = 0;
37311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37314         ret_ref = (uint64_t)ret_var.inner;
37315         if (ret_var.is_owned) {
37316                 ret_ref |= 1;
37317         }
37318         return ret_ref;
37319 }
37320
37321 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
37322         LDKRouteHop ret_var = RouteHop_clone(arg);
37323 uint64_t ret_ref = 0;
37324 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37325 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37326 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37327 ret_ref = (uint64_t)ret_var.inner;
37328 if (ret_var.is_owned) {
37329         ret_ref |= 1;
37330 }
37331         return ret_ref;
37332 }
37333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37334         LDKRouteHop arg_conv;
37335         arg_conv.inner = (void*)(arg & (~1));
37336         arg_conv.is_owned = false;
37337         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37338         int64_t ret_val = RouteHop_clone_ptr(&arg_conv);
37339         return ret_val;
37340 }
37341
37342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37343         LDKRouteHop orig_conv;
37344         orig_conv.inner = (void*)(orig & (~1));
37345         orig_conv.is_owned = false;
37346         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37347         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
37348         uint64_t ret_ref = 0;
37349         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37350         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37352         ret_ref = (uint64_t)ret_var.inner;
37353         if (ret_var.is_owned) {
37354                 ret_ref |= 1;
37355         }
37356         return ret_ref;
37357 }
37358
37359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
37360         LDKRouteHop o_conv;
37361         o_conv.inner = (void*)(o & (~1));
37362         o_conv.is_owned = false;
37363         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37364         int64_t ret_val = RouteHop_hash(&o_conv);
37365         return ret_val;
37366 }
37367
37368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37369         LDKRouteHop a_conv;
37370         a_conv.inner = (void*)(a & (~1));
37371         a_conv.is_owned = false;
37372         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37373         LDKRouteHop b_conv;
37374         b_conv.inner = (void*)(b & (~1));
37375         b_conv.is_owned = false;
37376         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37377         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
37378         return ret_val;
37379 }
37380
37381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
37382         LDKRouteHop obj_conv;
37383         obj_conv.inner = (void*)(obj & (~1));
37384         obj_conv.is_owned = false;
37385         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37386         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
37387         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37388         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37389         CVec_u8Z_free(ret_var);
37390         return ret_arr;
37391 }
37392
37393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37394         LDKu8slice ser_ref;
37395         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37396         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37397         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
37398         *ret_conv = RouteHop_read(ser_ref);
37399         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37400         return (uint64_t)ret_conv;
37401 }
37402
37403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37404         LDKRoute this_obj_conv;
37405         this_obj_conv.inner = (void*)(this_obj & (~1));
37406         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37408         Route_free(this_obj_conv);
37409 }
37410
37411 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
37412         LDKRoute this_ptr_conv;
37413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37414         this_ptr_conv.is_owned = false;
37415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37416         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
37417         jobjectArray ret_arr = NULL;
37418         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
37419         ;
37420         for (size_t m = 0; m < ret_var.datalen; m++) {
37421                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
37422                 int64_tArray ret_conv_12_arr = NULL;
37423                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
37424                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
37425                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
37426                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
37427                         uint64_t ret_conv_12_conv_10_ref = 0;
37428                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37429                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37430                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
37431                         ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
37432                         if (ret_conv_12_conv_10_var.is_owned) {
37433                                 ret_conv_12_conv_10_ref |= 1;
37434                         }
37435                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
37436                 }
37437                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
37438                 FREE(ret_conv_12_var.data);
37439                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
37440         }
37441         
37442         FREE(ret_var.data);
37443         return ret_arr;
37444 }
37445
37446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
37447         LDKRoute this_ptr_conv;
37448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37449         this_ptr_conv.is_owned = false;
37450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37451         LDKCVec_CVec_RouteHopZZ val_constr;
37452         val_constr.datalen = (*env)->GetArrayLength(env, val);
37453         if (val_constr.datalen > 0)
37454                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37455         else
37456                 val_constr.data = NULL;
37457         for (size_t m = 0; m < val_constr.datalen; m++) {
37458                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
37459                 LDKCVec_RouteHopZ val_conv_12_constr;
37460                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
37461                 if (val_conv_12_constr.datalen > 0)
37462                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37463                 else
37464                         val_conv_12_constr.data = NULL;
37465                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
37466                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
37467                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
37468                         LDKRouteHop val_conv_12_conv_10_conv;
37469                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
37470                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
37471                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
37472                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
37473                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
37474                 }
37475                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
37476                 val_constr.data[m] = val_conv_12_constr;
37477         }
37478         Route_set_paths(&this_ptr_conv, val_constr);
37479 }
37480
37481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
37482         LDKRoute this_ptr_conv;
37483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37484         this_ptr_conv.is_owned = false;
37485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37486         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
37487         uint64_t ret_ref = 0;
37488         if ((uint64_t)ret_var.inner > 4096) {
37489                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37490                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37492                 ret_ref = (uint64_t)ret_var.inner;
37493                 if (ret_var.is_owned) {
37494                         ret_ref |= 1;
37495                 }
37496         }
37497         return ret_ref;
37498 }
37499
37500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37501         LDKRoute this_ptr_conv;
37502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37503         this_ptr_conv.is_owned = false;
37504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37505         LDKPayee val_conv;
37506         val_conv.inner = (void*)(val & (~1));
37507         val_conv.is_owned = (val & 1) || (val == 0);
37508         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37509         val_conv = Payee_clone(&val_conv);
37510         Route_set_payee(&this_ptr_conv, val_conv);
37511 }
37512
37513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payee_arg) {
37514         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
37515         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
37516         if (paths_arg_constr.datalen > 0)
37517                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37518         else
37519                 paths_arg_constr.data = NULL;
37520         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
37521                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
37522                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
37523                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
37524                 if (paths_arg_conv_12_constr.datalen > 0)
37525                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37526                 else
37527                         paths_arg_conv_12_constr.data = NULL;
37528                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
37529                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
37530                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
37531                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
37532                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
37533                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
37534                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
37535                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
37536                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
37537                 }
37538                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
37539                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
37540         }
37541         LDKPayee payee_arg_conv;
37542         payee_arg_conv.inner = (void*)(payee_arg & (~1));
37543         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
37544         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
37545         payee_arg_conv = Payee_clone(&payee_arg_conv);
37546         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
37547         uint64_t ret_ref = 0;
37548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37551         ret_ref = (uint64_t)ret_var.inner;
37552         if (ret_var.is_owned) {
37553                 ret_ref |= 1;
37554         }
37555         return ret_ref;
37556 }
37557
37558 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
37559         LDKRoute ret_var = Route_clone(arg);
37560 uint64_t ret_ref = 0;
37561 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37562 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37563 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37564 ret_ref = (uint64_t)ret_var.inner;
37565 if (ret_var.is_owned) {
37566         ret_ref |= 1;
37567 }
37568         return ret_ref;
37569 }
37570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37571         LDKRoute arg_conv;
37572         arg_conv.inner = (void*)(arg & (~1));
37573         arg_conv.is_owned = false;
37574         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37575         int64_t ret_val = Route_clone_ptr(&arg_conv);
37576         return ret_val;
37577 }
37578
37579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37580         LDKRoute orig_conv;
37581         orig_conv.inner = (void*)(orig & (~1));
37582         orig_conv.is_owned = false;
37583         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37584         LDKRoute ret_var = Route_clone(&orig_conv);
37585         uint64_t ret_ref = 0;
37586         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37587         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37589         ret_ref = (uint64_t)ret_var.inner;
37590         if (ret_var.is_owned) {
37591                 ret_ref |= 1;
37592         }
37593         return ret_ref;
37594 }
37595
37596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
37597         LDKRoute o_conv;
37598         o_conv.inner = (void*)(o & (~1));
37599         o_conv.is_owned = false;
37600         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37601         int64_t ret_val = Route_hash(&o_conv);
37602         return ret_val;
37603 }
37604
37605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37606         LDKRoute a_conv;
37607         a_conv.inner = (void*)(a & (~1));
37608         a_conv.is_owned = false;
37609         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37610         LDKRoute b_conv;
37611         b_conv.inner = (void*)(b & (~1));
37612         b_conv.is_owned = false;
37613         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37614         jboolean ret_val = Route_eq(&a_conv, &b_conv);
37615         return ret_val;
37616 }
37617
37618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
37619         LDKRoute this_arg_conv;
37620         this_arg_conv.inner = (void*)(this_arg & (~1));
37621         this_arg_conv.is_owned = false;
37622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37623         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
37624         return ret_val;
37625 }
37626
37627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
37628         LDKRoute this_arg_conv;
37629         this_arg_conv.inner = (void*)(this_arg & (~1));
37630         this_arg_conv.is_owned = false;
37631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37632         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
37633         return ret_val;
37634 }
37635
37636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
37637         LDKRoute obj_conv;
37638         obj_conv.inner = (void*)(obj & (~1));
37639         obj_conv.is_owned = false;
37640         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37641         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
37642         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37643         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37644         CVec_u8Z_free(ret_var);
37645         return ret_arr;
37646 }
37647
37648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37649         LDKu8slice ser_ref;
37650         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37651         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37652         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
37653         *ret_conv = Route_read(ser_ref);
37654         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37655         return (uint64_t)ret_conv;
37656 }
37657
37658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37659         LDKRouteParameters this_obj_conv;
37660         this_obj_conv.inner = (void*)(this_obj & (~1));
37661         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37663         RouteParameters_free(this_obj_conv);
37664 }
37665
37666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
37667         LDKRouteParameters this_ptr_conv;
37668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37669         this_ptr_conv.is_owned = false;
37670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37671         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
37672         uint64_t ret_ref = 0;
37673         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37674         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37676         ret_ref = (uint64_t)ret_var.inner;
37677         if (ret_var.is_owned) {
37678                 ret_ref |= 1;
37679         }
37680         return ret_ref;
37681 }
37682
37683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37684         LDKRouteParameters this_ptr_conv;
37685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37686         this_ptr_conv.is_owned = false;
37687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37688         LDKPayee val_conv;
37689         val_conv.inner = (void*)(val & (~1));
37690         val_conv.is_owned = (val & 1) || (val == 0);
37691         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37692         val_conv = Payee_clone(&val_conv);
37693         RouteParameters_set_payee(&this_ptr_conv, val_conv);
37694 }
37695
37696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37697         LDKRouteParameters this_ptr_conv;
37698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37699         this_ptr_conv.is_owned = false;
37700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37701         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
37702         return ret_val;
37703 }
37704
37705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37706         LDKRouteParameters this_ptr_conv;
37707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37708         this_ptr_conv.is_owned = false;
37709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37710         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
37711 }
37712
37713 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
37714         LDKRouteParameters this_ptr_conv;
37715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37716         this_ptr_conv.is_owned = false;
37717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37718         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
37719         return ret_val;
37720 }
37721
37722 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) {
37723         LDKRouteParameters this_ptr_conv;
37724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37725         this_ptr_conv.is_owned = false;
37726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37727         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
37728 }
37729
37730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new(JNIEnv *env, jclass clz, int64_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
37731         LDKPayee payee_arg_conv;
37732         payee_arg_conv.inner = (void*)(payee_arg & (~1));
37733         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
37734         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
37735         payee_arg_conv = Payee_clone(&payee_arg_conv);
37736         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
37737         uint64_t ret_ref = 0;
37738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37741         ret_ref = (uint64_t)ret_var.inner;
37742         if (ret_var.is_owned) {
37743                 ret_ref |= 1;
37744         }
37745         return ret_ref;
37746 }
37747
37748 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
37749         LDKRouteParameters ret_var = RouteParameters_clone(arg);
37750 uint64_t ret_ref = 0;
37751 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37752 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37753 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37754 ret_ref = (uint64_t)ret_var.inner;
37755 if (ret_var.is_owned) {
37756         ret_ref |= 1;
37757 }
37758         return ret_ref;
37759 }
37760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37761         LDKRouteParameters arg_conv;
37762         arg_conv.inner = (void*)(arg & (~1));
37763         arg_conv.is_owned = false;
37764         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37765         int64_t ret_val = RouteParameters_clone_ptr(&arg_conv);
37766         return ret_val;
37767 }
37768
37769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37770         LDKRouteParameters orig_conv;
37771         orig_conv.inner = (void*)(orig & (~1));
37772         orig_conv.is_owned = false;
37773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37774         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
37775         uint64_t ret_ref = 0;
37776         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37777         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37779         ret_ref = (uint64_t)ret_var.inner;
37780         if (ret_var.is_owned) {
37781                 ret_ref |= 1;
37782         }
37783         return ret_ref;
37784 }
37785
37786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37787         LDKRouteParameters obj_conv;
37788         obj_conv.inner = (void*)(obj & (~1));
37789         obj_conv.is_owned = false;
37790         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37791         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
37792         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37793         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37794         CVec_u8Z_free(ret_var);
37795         return ret_arr;
37796 }
37797
37798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37799         LDKu8slice ser_ref;
37800         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37801         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37802         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
37803         *ret_conv = RouteParameters_read(ser_ref);
37804         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37805         return (uint64_t)ret_conv;
37806 }
37807
37808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37809         LDKPayee this_obj_conv;
37810         this_obj_conv.inner = (void*)(this_obj & (~1));
37811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37813         Payee_free(this_obj_conv);
37814 }
37815
37816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
37817         LDKPayee this_ptr_conv;
37818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37819         this_ptr_conv.is_owned = false;
37820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37821         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37822         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Payee_get_pubkey(&this_ptr_conv).compressed_form);
37823         return ret_arr;
37824 }
37825
37826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37827         LDKPayee this_ptr_conv;
37828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37829         this_ptr_conv.is_owned = false;
37830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37831         LDKPublicKey val_ref;
37832         CHECK((*env)->GetArrayLength(env, val) == 33);
37833         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37834         Payee_set_pubkey(&this_ptr_conv, val_ref);
37835 }
37836
37837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
37838         LDKPayee this_ptr_conv;
37839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37840         this_ptr_conv.is_owned = false;
37841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37842         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
37843         uint64_t ret_ref = 0;
37844         if ((uint64_t)ret_var.inner > 4096) {
37845                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37846                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37848                 ret_ref = (uint64_t)ret_var.inner;
37849                 if (ret_var.is_owned) {
37850                         ret_ref |= 1;
37851                 }
37852         }
37853         return ret_ref;
37854 }
37855
37856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37857         LDKPayee this_ptr_conv;
37858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37859         this_ptr_conv.is_owned = false;
37860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37861         LDKInvoiceFeatures val_conv;
37862         val_conv.inner = (void*)(val & (~1));
37863         val_conv.is_owned = (val & 1) || (val == 0);
37864         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37865         val_conv = InvoiceFeatures_clone(&val_conv);
37866         Payee_set_features(&this_ptr_conv, val_conv);
37867 }
37868
37869 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
37870         LDKPayee this_ptr_conv;
37871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37872         this_ptr_conv.is_owned = false;
37873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37874         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
37875         int64_tArray ret_arr = NULL;
37876         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37877         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37878         for (size_t l = 0; l < ret_var.datalen; l++) {
37879                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
37880                 uint64_t ret_conv_11_ref = 0;
37881                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37882                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37883                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
37884                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
37885                 if (ret_conv_11_var.is_owned) {
37886                         ret_conv_11_ref |= 1;
37887                 }
37888                 ret_arr_ptr[l] = ret_conv_11_ref;
37889         }
37890         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37891         FREE(ret_var.data);
37892         return ret_arr;
37893 }
37894
37895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37896         LDKPayee this_ptr_conv;
37897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37898         this_ptr_conv.is_owned = false;
37899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37900         LDKCVec_RouteHintZ val_constr;
37901         val_constr.datalen = (*env)->GetArrayLength(env, val);
37902         if (val_constr.datalen > 0)
37903                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37904         else
37905                 val_constr.data = NULL;
37906         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37907         for (size_t l = 0; l < val_constr.datalen; l++) {
37908                 int64_t val_conv_11 = val_vals[l];
37909                 LDKRouteHint val_conv_11_conv;
37910                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
37911                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
37912                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
37913                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
37914                 val_constr.data[l] = val_conv_11_conv;
37915         }
37916         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37917         Payee_set_route_hints(&this_ptr_conv, val_constr);
37918 }
37919
37920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
37921         LDKPayee this_ptr_conv;
37922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37923         this_ptr_conv.is_owned = false;
37924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37925         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37926         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
37927         uint64_t ret_ref = (uint64_t)ret_copy;
37928         return ret_ref;
37929 }
37930
37931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37932         LDKPayee this_ptr_conv;
37933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37934         this_ptr_conv.is_owned = false;
37935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37936         void* val_ptr = (void*)(((uint64_t)val) & ~1);
37937         CHECK_ACCESS(val_ptr);
37938         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37939         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
37940         Payee_set_expiry_time(&this_ptr_conv, val_conv);
37941 }
37942
37943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1new(JNIEnv *env, jclass clz, int8_tArray pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg) {
37944         LDKPublicKey pubkey_arg_ref;
37945         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
37946         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
37947         LDKInvoiceFeatures features_arg_conv;
37948         features_arg_conv.inner = (void*)(features_arg & (~1));
37949         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37950         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37951         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
37952         LDKCVec_RouteHintZ route_hints_arg_constr;
37953         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
37954         if (route_hints_arg_constr.datalen > 0)
37955                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37956         else
37957                 route_hints_arg_constr.data = NULL;
37958         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
37959         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
37960                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
37961                 LDKRouteHint route_hints_arg_conv_11_conv;
37962                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
37963                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
37964                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
37965                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
37966                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
37967         }
37968         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
37969         void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
37970         CHECK_ACCESS(expiry_time_arg_ptr);
37971         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
37972         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
37973         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
37974         uint64_t ret_ref = 0;
37975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37978         ret_ref = (uint64_t)ret_var.inner;
37979         if (ret_var.is_owned) {
37980                 ret_ref |= 1;
37981         }
37982         return ret_ref;
37983 }
37984
37985 static inline uint64_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
37986         LDKPayee ret_var = Payee_clone(arg);
37987 uint64_t ret_ref = 0;
37988 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37989 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37990 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37991 ret_ref = (uint64_t)ret_var.inner;
37992 if (ret_var.is_owned) {
37993         ret_ref |= 1;
37994 }
37995         return ret_ref;
37996 }
37997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37998         LDKPayee arg_conv;
37999         arg_conv.inner = (void*)(arg & (~1));
38000         arg_conv.is_owned = false;
38001         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38002         int64_t ret_val = Payee_clone_ptr(&arg_conv);
38003         return ret_val;
38004 }
38005
38006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38007         LDKPayee orig_conv;
38008         orig_conv.inner = (void*)(orig & (~1));
38009         orig_conv.is_owned = false;
38010         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38011         LDKPayee ret_var = Payee_clone(&orig_conv);
38012         uint64_t ret_ref = 0;
38013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38016         ret_ref = (uint64_t)ret_var.inner;
38017         if (ret_var.is_owned) {
38018                 ret_ref |= 1;
38019         }
38020         return ret_ref;
38021 }
38022
38023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1hash(JNIEnv *env, jclass clz, int64_t o) {
38024         LDKPayee o_conv;
38025         o_conv.inner = (void*)(o & (~1));
38026         o_conv.is_owned = false;
38027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38028         int64_t ret_val = Payee_hash(&o_conv);
38029         return ret_val;
38030 }
38031
38032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Payee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38033         LDKPayee a_conv;
38034         a_conv.inner = (void*)(a & (~1));
38035         a_conv.is_owned = false;
38036         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38037         LDKPayee b_conv;
38038         b_conv.inner = (void*)(b & (~1));
38039         b_conv.is_owned = false;
38040         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38041         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
38042         return ret_val;
38043 }
38044
38045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1write(JNIEnv *env, jclass clz, int64_t obj) {
38046         LDKPayee obj_conv;
38047         obj_conv.inner = (void*)(obj & (~1));
38048         obj_conv.is_owned = false;
38049         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38050         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
38051         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38052         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38053         CVec_u8Z_free(ret_var);
38054         return ret_arr;
38055 }
38056
38057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38058         LDKu8slice ser_ref;
38059         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38060         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38061         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
38062         *ret_conv = Payee_read(ser_ref);
38063         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38064         return (uint64_t)ret_conv;
38065 }
38066
38067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray pubkey) {
38068         LDKPublicKey pubkey_ref;
38069         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
38070         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
38071         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
38072         uint64_t ret_ref = 0;
38073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38076         ret_ref = (uint64_t)ret_var.inner;
38077         if (ret_var.is_owned) {
38078                 ret_ref |= 1;
38079         }
38080         return ret_ref;
38081 }
38082
38083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray pubkey) {
38084         LDKPublicKey pubkey_ref;
38085         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
38086         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
38087         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
38088         uint64_t ret_ref = 0;
38089         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38090         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38092         ret_ref = (uint64_t)ret_var.inner;
38093         if (ret_var.is_owned) {
38094                 ret_ref |= 1;
38095         }
38096         return ret_ref;
38097 }
38098
38099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38100         LDKRouteHint this_obj_conv;
38101         this_obj_conv.inner = (void*)(this_obj & (~1));
38102         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38104         RouteHint_free(this_obj_conv);
38105 }
38106
38107 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
38108         LDKRouteHint this_ptr_conv;
38109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38110         this_ptr_conv.is_owned = false;
38111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38112         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
38113         int64_tArray ret_arr = NULL;
38114         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38115         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38116         for (size_t o = 0; o < ret_var.datalen; o++) {
38117                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
38118                 uint64_t ret_conv_14_ref = 0;
38119                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38120                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38121                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
38122                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
38123                 if (ret_conv_14_var.is_owned) {
38124                         ret_conv_14_ref |= 1;
38125                 }
38126                 ret_arr_ptr[o] = ret_conv_14_ref;
38127         }
38128         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38129         FREE(ret_var.data);
38130         return ret_arr;
38131 }
38132
38133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38134         LDKRouteHint this_ptr_conv;
38135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38136         this_ptr_conv.is_owned = false;
38137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38138         LDKCVec_RouteHintHopZ val_constr;
38139         val_constr.datalen = (*env)->GetArrayLength(env, val);
38140         if (val_constr.datalen > 0)
38141                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38142         else
38143                 val_constr.data = NULL;
38144         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38145         for (size_t o = 0; o < val_constr.datalen; o++) {
38146                 int64_t val_conv_14 = val_vals[o];
38147                 LDKRouteHintHop val_conv_14_conv;
38148                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
38149                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
38150                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
38151                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
38152                 val_constr.data[o] = val_conv_14_conv;
38153         }
38154         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38155         RouteHint_set_a(&this_ptr_conv, val_constr);
38156 }
38157
38158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
38159         LDKCVec_RouteHintHopZ a_arg_constr;
38160         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
38161         if (a_arg_constr.datalen > 0)
38162                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38163         else
38164                 a_arg_constr.data = NULL;
38165         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
38166         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
38167                 int64_t a_arg_conv_14 = a_arg_vals[o];
38168                 LDKRouteHintHop a_arg_conv_14_conv;
38169                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
38170                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
38171                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
38172                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
38173                 a_arg_constr.data[o] = a_arg_conv_14_conv;
38174         }
38175         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
38176         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
38177         uint64_t ret_ref = 0;
38178         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38179         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38181         ret_ref = (uint64_t)ret_var.inner;
38182         if (ret_var.is_owned) {
38183                 ret_ref |= 1;
38184         }
38185         return ret_ref;
38186 }
38187
38188 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
38189         LDKRouteHint ret_var = RouteHint_clone(arg);
38190 uint64_t ret_ref = 0;
38191 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38192 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
38195 if (ret_var.is_owned) {
38196         ret_ref |= 1;
38197 }
38198         return ret_ref;
38199 }
38200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38201         LDKRouteHint arg_conv;
38202         arg_conv.inner = (void*)(arg & (~1));
38203         arg_conv.is_owned = false;
38204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38205         int64_t ret_val = RouteHint_clone_ptr(&arg_conv);
38206         return ret_val;
38207 }
38208
38209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38210         LDKRouteHint orig_conv;
38211         orig_conv.inner = (void*)(orig & (~1));
38212         orig_conv.is_owned = false;
38213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38214         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
38215         uint64_t ret_ref = 0;
38216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38219         ret_ref = (uint64_t)ret_var.inner;
38220         if (ret_var.is_owned) {
38221                 ret_ref |= 1;
38222         }
38223         return ret_ref;
38224 }
38225
38226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
38227         LDKRouteHint o_conv;
38228         o_conv.inner = (void*)(o & (~1));
38229         o_conv.is_owned = false;
38230         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38231         int64_t ret_val = RouteHint_hash(&o_conv);
38232         return ret_val;
38233 }
38234
38235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38236         LDKRouteHint a_conv;
38237         a_conv.inner = (void*)(a & (~1));
38238         a_conv.is_owned = false;
38239         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38240         LDKRouteHint b_conv;
38241         b_conv.inner = (void*)(b & (~1));
38242         b_conv.is_owned = false;
38243         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38244         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
38245         return ret_val;
38246 }
38247
38248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
38249         LDKRouteHint obj_conv;
38250         obj_conv.inner = (void*)(obj & (~1));
38251         obj_conv.is_owned = false;
38252         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38253         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
38254         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38255         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38256         CVec_u8Z_free(ret_var);
38257         return ret_arr;
38258 }
38259
38260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38261         LDKu8slice ser_ref;
38262         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38263         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38264         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
38265         *ret_conv = RouteHint_read(ser_ref);
38266         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38267         return (uint64_t)ret_conv;
38268 }
38269
38270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38271         LDKRouteHintHop this_obj_conv;
38272         this_obj_conv.inner = (void*)(this_obj & (~1));
38273         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38275         RouteHintHop_free(this_obj_conv);
38276 }
38277
38278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38279         LDKRouteHintHop this_ptr_conv;
38280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38281         this_ptr_conv.is_owned = false;
38282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38283         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38284         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
38285         return ret_arr;
38286 }
38287
38288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38289         LDKRouteHintHop this_ptr_conv;
38290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38291         this_ptr_conv.is_owned = false;
38292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38293         LDKPublicKey val_ref;
38294         CHECK((*env)->GetArrayLength(env, val) == 33);
38295         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38296         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
38297 }
38298
38299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38300         LDKRouteHintHop this_ptr_conv;
38301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38302         this_ptr_conv.is_owned = false;
38303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38304         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
38305         return ret_val;
38306 }
38307
38308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38309         LDKRouteHintHop this_ptr_conv;
38310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38311         this_ptr_conv.is_owned = false;
38312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38313         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
38314 }
38315
38316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
38317         LDKRouteHintHop this_ptr_conv;
38318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38319         this_ptr_conv.is_owned = false;
38320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38321         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
38322         uint64_t ret_ref = 0;
38323         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38324         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38326         ret_ref = (uint64_t)ret_var.inner;
38327         if (ret_var.is_owned) {
38328                 ret_ref |= 1;
38329         }
38330         return ret_ref;
38331 }
38332
38333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38334         LDKRouteHintHop this_ptr_conv;
38335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38336         this_ptr_conv.is_owned = false;
38337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38338         LDKRoutingFees val_conv;
38339         val_conv.inner = (void*)(val & (~1));
38340         val_conv.is_owned = (val & 1) || (val == 0);
38341         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38342         val_conv = RoutingFees_clone(&val_conv);
38343         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
38344 }
38345
38346 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
38347         LDKRouteHintHop this_ptr_conv;
38348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38349         this_ptr_conv.is_owned = false;
38350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38351         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
38352         return ret_val;
38353 }
38354
38355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
38356         LDKRouteHintHop this_ptr_conv;
38357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38358         this_ptr_conv.is_owned = false;
38359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38360         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
38361 }
38362
38363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38364         LDKRouteHintHop this_ptr_conv;
38365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38366         this_ptr_conv.is_owned = false;
38367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38368         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38369         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
38370         uint64_t ret_ref = (uint64_t)ret_copy;
38371         return ret_ref;
38372 }
38373
38374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38375         LDKRouteHintHop this_ptr_conv;
38376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38377         this_ptr_conv.is_owned = false;
38378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38379         void* val_ptr = (void*)(((uint64_t)val) & ~1);
38380         CHECK_ACCESS(val_ptr);
38381         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38382         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
38383         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
38384 }
38385
38386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38387         LDKRouteHintHop this_ptr_conv;
38388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38389         this_ptr_conv.is_owned = false;
38390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38391         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38392         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
38393         uint64_t ret_ref = (uint64_t)ret_copy;
38394         return ret_ref;
38395 }
38396
38397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38398         LDKRouteHintHop this_ptr_conv;
38399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38400         this_ptr_conv.is_owned = false;
38401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38402         void* val_ptr = (void*)(((uint64_t)val) & ~1);
38403         CHECK_ACCESS(val_ptr);
38404         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38405         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
38406         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38407 }
38408
38409 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) {
38410         LDKPublicKey src_node_id_arg_ref;
38411         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
38412         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
38413         LDKRoutingFees fees_arg_conv;
38414         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38415         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38416         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38417         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38418         void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
38419         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
38420         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
38421         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
38422         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
38423         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38424         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38425         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
38426         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);
38427         uint64_t ret_ref = 0;
38428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38431         ret_ref = (uint64_t)ret_var.inner;
38432         if (ret_var.is_owned) {
38433                 ret_ref |= 1;
38434         }
38435         return ret_ref;
38436 }
38437
38438 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
38439         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
38440 uint64_t ret_ref = 0;
38441 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38442 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38443 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38444 ret_ref = (uint64_t)ret_var.inner;
38445 if (ret_var.is_owned) {
38446         ret_ref |= 1;
38447 }
38448         return ret_ref;
38449 }
38450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38451         LDKRouteHintHop arg_conv;
38452         arg_conv.inner = (void*)(arg & (~1));
38453         arg_conv.is_owned = false;
38454         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38455         int64_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
38456         return ret_val;
38457 }
38458
38459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38460         LDKRouteHintHop orig_conv;
38461         orig_conv.inner = (void*)(orig & (~1));
38462         orig_conv.is_owned = false;
38463         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38464         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
38465         uint64_t ret_ref = 0;
38466         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38467         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38469         ret_ref = (uint64_t)ret_var.inner;
38470         if (ret_var.is_owned) {
38471                 ret_ref |= 1;
38472         }
38473         return ret_ref;
38474 }
38475
38476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
38477         LDKRouteHintHop o_conv;
38478         o_conv.inner = (void*)(o & (~1));
38479         o_conv.is_owned = false;
38480         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38481         int64_t ret_val = RouteHintHop_hash(&o_conv);
38482         return ret_val;
38483 }
38484
38485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38486         LDKRouteHintHop a_conv;
38487         a_conv.inner = (void*)(a & (~1));
38488         a_conv.is_owned = false;
38489         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38490         LDKRouteHintHop b_conv;
38491         b_conv.inner = (void*)(b & (~1));
38492         b_conv.is_owned = false;
38493         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38494         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
38495         return ret_val;
38496 }
38497
38498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
38499         LDKRouteHintHop obj_conv;
38500         obj_conv.inner = (void*)(obj & (~1));
38501         obj_conv.is_owned = false;
38502         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38503         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
38504         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38505         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38506         CVec_u8Z_free(ret_var);
38507         return ret_arr;
38508 }
38509
38510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38511         LDKu8slice ser_ref;
38512         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38513         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38514         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
38515         *ret_conv = RouteHintHop_read(ser_ref);
38516         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38517         return (uint64_t)ret_conv;
38518 }
38519
38520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer) {
38521         LDKPublicKey our_node_pubkey_ref;
38522         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
38523         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
38524         LDKRouteParameters params_conv;
38525         params_conv.inner = (void*)(params & (~1));
38526         params_conv.is_owned = false;
38527         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
38528         LDKNetworkGraph network_conv;
38529         network_conv.inner = (void*)(network & (~1));
38530         network_conv.is_owned = false;
38531         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
38532         LDKCVec_ChannelDetailsZ first_hops_constr;
38533         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
38534         if (first_hops != NULL) {
38535                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
38536                 if (first_hops_constr.datalen > 0)
38537                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
38538                 else
38539                         first_hops_constr.data = NULL;
38540                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
38541                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
38542                         int64_t first_hops_conv_16 = first_hops_vals[q];
38543                         LDKChannelDetails first_hops_conv_16_conv;
38544                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
38545                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
38546                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
38547                         first_hops_constr.data[q] = first_hops_conv_16_conv;
38548                 }
38549                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
38550                 first_hops_ptr = &first_hops_constr;
38551         }
38552         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
38553         CHECK_ACCESS(logger_ptr);
38554         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38555         if (logger_conv.free == LDKLogger_JCalls_free) {
38556                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38557                 LDKLogger_JCalls_cloned(&logger_conv);
38558         }
38559         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
38560         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
38561         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
38562         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
38563         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
38564         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
38565         return (uint64_t)ret_conv;
38566 }
38567
38568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38569         if ((this_ptr & 1) != 0) return;
38570         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
38571         CHECK_ACCESS(this_ptr_ptr);
38572         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
38573         FREE((void*)this_ptr);
38574         Score_free(this_ptr_conv);
38575 }
38576
38577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38578         if ((this_ptr & 1) != 0) return;
38579         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
38580         CHECK_ACCESS(this_ptr_ptr);
38581         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
38582         FREE((void*)this_ptr);
38583         LockableScore_free(this_ptr_conv);
38584 }
38585
38586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38587         LDKMultiThreadedLockableScore this_obj_conv;
38588         this_obj_conv.inner = (void*)(this_obj & (~1));
38589         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38591         MultiThreadedLockableScore_free(this_obj_conv);
38592 }
38593
38594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
38595         void* score_ptr = (void*)(((uint64_t)score) & ~1);
38596         CHECK_ACCESS(score_ptr);
38597         LDKScore score_conv = *(LDKScore*)(score_ptr);
38598         if (score_conv.free == LDKScore_JCalls_free) {
38599                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38600                 LDKScore_JCalls_cloned(&score_conv);
38601         }
38602         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
38603         uint64_t ret_ref = 0;
38604         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38605         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38607         ret_ref = (uint64_t)ret_var.inner;
38608         if (ret_var.is_owned) {
38609                 ret_ref |= 1;
38610         }
38611         return ret_ref;
38612 }
38613
38614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38615         LDKScorer this_obj_conv;
38616         this_obj_conv.inner = (void*)(this_obj & (~1));
38617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38619         Scorer_free(this_obj_conv);
38620 }
38621
38622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38623         LDKScoringParameters this_obj_conv;
38624         this_obj_conv.inner = (void*)(this_obj & (~1));
38625         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38627         ScoringParameters_free(this_obj_conv);
38628 }
38629
38630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38631         LDKScoringParameters this_ptr_conv;
38632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38633         this_ptr_conv.is_owned = false;
38634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38635         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
38636         return ret_val;
38637 }
38638
38639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38640         LDKScoringParameters this_ptr_conv;
38641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38642         this_ptr_conv.is_owned = false;
38643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38644         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
38645 }
38646
38647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38648         LDKScoringParameters this_ptr_conv;
38649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38650         this_ptr_conv.is_owned = false;
38651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38652         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
38653         return ret_val;
38654 }
38655
38656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38657         LDKScoringParameters this_ptr_conv;
38658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38659         this_ptr_conv.is_owned = false;
38660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38661         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
38662 }
38663
38664 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
38665         LDKScoringParameters this_ptr_conv;
38666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38667         this_ptr_conv.is_owned = false;
38668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38669         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
38670         return ret_val;
38671 }
38672
38673 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) {
38674         LDKScoringParameters this_ptr_conv;
38675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38676         this_ptr_conv.is_owned = false;
38677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38678         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
38679 }
38680
38681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
38682         LDKScoringParameters this_ptr_conv;
38683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38684         this_ptr_conv.is_owned = false;
38685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38686         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
38687         return ret_val;
38688 }
38689
38690 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) {
38691         LDKScoringParameters this_ptr_conv;
38692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38693         this_ptr_conv.is_owned = false;
38694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38695         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
38696 }
38697
38698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
38699         LDKScoringParameters this_ptr_conv;
38700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38701         this_ptr_conv.is_owned = false;
38702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38703         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
38704         return ret_val;
38705 }
38706
38707 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) {
38708         LDKScoringParameters this_ptr_conv;
38709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38710         this_ptr_conv.is_owned = false;
38711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38712         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
38713 }
38714
38715 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) {
38716         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);
38717         uint64_t ret_ref = 0;
38718         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38719         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38721         ret_ref = (uint64_t)ret_var.inner;
38722         if (ret_var.is_owned) {
38723                 ret_ref |= 1;
38724         }
38725         return ret_ref;
38726 }
38727
38728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
38729         LDKScoringParameters obj_conv;
38730         obj_conv.inner = (void*)(obj & (~1));
38731         obj_conv.is_owned = false;
38732         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38733         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
38734         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38735         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38736         CVec_u8Z_free(ret_var);
38737         return ret_arr;
38738 }
38739
38740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38741         LDKu8slice ser_ref;
38742         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38743         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38744         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
38745         *ret_conv = ScoringParameters_read(ser_ref);
38746         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38747         return (uint64_t)ret_conv;
38748 }
38749
38750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
38751         LDKScoringParameters params_conv;
38752         params_conv.inner = (void*)(params & (~1));
38753         params_conv.is_owned = (params & 1) || (params == 0);
38754         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
38755         // Warning: we need a move here but no clone is available for LDKScoringParameters
38756         LDKScorer ret_var = Scorer_new(params_conv);
38757         uint64_t ret_ref = 0;
38758         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38759         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38761         ret_ref = (uint64_t)ret_var.inner;
38762         if (ret_var.is_owned) {
38763                 ret_ref |= 1;
38764         }
38765         return ret_ref;
38766 }
38767
38768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
38769         LDKScorer ret_var = Scorer_default();
38770         uint64_t ret_ref = 0;
38771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38774         ret_ref = (uint64_t)ret_var.inner;
38775         if (ret_var.is_owned) {
38776                 ret_ref |= 1;
38777         }
38778         return ret_ref;
38779 }
38780
38781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
38782         LDKScoringParameters ret_var = ScoringParameters_default();
38783         uint64_t ret_ref = 0;
38784         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38785         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38787         ret_ref = (uint64_t)ret_var.inner;
38788         if (ret_var.is_owned) {
38789                 ret_ref |= 1;
38790         }
38791         return ret_ref;
38792 }
38793
38794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
38795         LDKScorer this_arg_conv;
38796         this_arg_conv.inner = (void*)(this_arg & (~1));
38797         this_arg_conv.is_owned = false;
38798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38799         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
38800         *ret_ret = Scorer_as_Score(&this_arg_conv);
38801         return (uint64_t)ret_ret;
38802 }
38803
38804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
38805         LDKScorer obj_conv;
38806         obj_conv.inner = (void*)(obj & (~1));
38807         obj_conv.is_owned = false;
38808         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38809         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
38810         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38811         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38812         CVec_u8Z_free(ret_var);
38813         return ret_arr;
38814 }
38815
38816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38817         LDKu8slice ser_ref;
38818         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38819         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38820         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
38821         *ret_conv = Scorer_read(ser_ref);
38822         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38823         return (uint64_t)ret_conv;
38824 }
38825
38826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38827         LDKFilesystemPersister this_obj_conv;
38828         this_obj_conv.inner = (void*)(this_obj & (~1));
38829         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38831         FilesystemPersister_free(this_obj_conv);
38832 }
38833
38834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
38835         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
38836         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
38837         uint64_t ret_ref = 0;
38838         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38839         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38841         ret_ref = (uint64_t)ret_var.inner;
38842         if (ret_var.is_owned) {
38843                 ret_ref |= 1;
38844         }
38845         return ret_ref;
38846 }
38847
38848 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
38849         LDKFilesystemPersister this_arg_conv;
38850         this_arg_conv.inner = (void*)(this_arg & (~1));
38851         this_arg_conv.is_owned = false;
38852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38853         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
38854         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
38855         Str_free(ret_str);
38856         return ret_conv;
38857 }
38858
38859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
38860         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
38861         LDKChannelManager manager_conv;
38862         manager_conv.inner = (void*)(manager & (~1));
38863         manager_conv.is_owned = false;
38864         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
38865         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
38866         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
38867         return (uint64_t)ret_conv;
38868 }
38869
38870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
38871         LDKFilesystemPersister this_arg_conv;
38872         this_arg_conv.inner = (void*)(this_arg & (~1));
38873         this_arg_conv.is_owned = false;
38874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38875         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
38876         CHECK_ACCESS(keys_manager_ptr);
38877         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
38878         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
38879                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38880                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
38881         }
38882         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
38883         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
38884         return (uint64_t)ret_conv;
38885 }
38886
38887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
38888         LDKFilesystemPersister this_arg_conv;
38889         this_arg_conv.inner = (void*)(this_arg & (~1));
38890         this_arg_conv.is_owned = false;
38891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38892         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
38893         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
38894         return (uint64_t)ret_ret;
38895 }
38896
38897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38898         LDKBackgroundProcessor this_obj_conv;
38899         this_obj_conv.inner = (void*)(this_obj & (~1));
38900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38902         BackgroundProcessor_free(this_obj_conv);
38903 }
38904
38905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38906         if ((this_ptr & 1) != 0) return;
38907         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
38908         CHECK_ACCESS(this_ptr_ptr);
38909         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
38910         FREE((void*)this_ptr);
38911         ChannelManagerPersister_free(this_ptr_conv);
38912 }
38913
38914 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) {
38915         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
38916         CHECK_ACCESS(persister_ptr);
38917         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
38918         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
38919                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38920                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
38921         }
38922         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
38923         CHECK_ACCESS(event_handler_ptr);
38924         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
38925         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
38926                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38927                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
38928         }
38929         LDKChainMonitor chain_monitor_conv;
38930         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
38931         chain_monitor_conv.is_owned = false;
38932         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
38933         LDKChannelManager channel_manager_conv;
38934         channel_manager_conv.inner = (void*)(channel_manager & (~1));
38935         channel_manager_conv.is_owned = false;
38936         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
38937         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
38938         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
38939         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
38940         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
38941         LDKPeerManager peer_manager_conv;
38942         peer_manager_conv.inner = (void*)(peer_manager & (~1));
38943         peer_manager_conv.is_owned = false;
38944         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
38945         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
38946         CHECK_ACCESS(logger_ptr);
38947         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38948         if (logger_conv.free == LDKLogger_JCalls_free) {
38949                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38950                 LDKLogger_JCalls_cloned(&logger_conv);
38951         }
38952         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);
38953         uint64_t ret_ref = 0;
38954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38957         ret_ref = (uint64_t)ret_var.inner;
38958         if (ret_var.is_owned) {
38959                 ret_ref |= 1;
38960         }
38961         return ret_ref;
38962 }
38963
38964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
38965         LDKBackgroundProcessor this_arg_conv;
38966         this_arg_conv.inner = (void*)(this_arg & (~1));
38967         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
38968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38969         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
38970         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
38971         *ret_conv = BackgroundProcessor_join(this_arg_conv);
38972         return (uint64_t)ret_conv;
38973 }
38974
38975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
38976         LDKBackgroundProcessor this_arg_conv;
38977         this_arg_conv.inner = (void*)(this_arg & (~1));
38978         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
38979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38980         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
38981         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
38982         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
38983         return (uint64_t)ret_conv;
38984 }
38985
38986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
38987         check_platform();
38988 }
38989
38990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38991         LDKInvoice this_obj_conv;
38992         this_obj_conv.inner = (void*)(this_obj & (~1));
38993         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38995         Invoice_free(this_obj_conv);
38996 }
38997
38998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38999         LDKInvoice a_conv;
39000         a_conv.inner = (void*)(a & (~1));
39001         a_conv.is_owned = false;
39002         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39003         LDKInvoice b_conv;
39004         b_conv.inner = (void*)(b & (~1));
39005         b_conv.is_owned = false;
39006         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39007         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
39008         return ret_val;
39009 }
39010
39011 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
39012         LDKInvoice ret_var = Invoice_clone(arg);
39013 uint64_t ret_ref = 0;
39014 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39015 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39016 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39017 ret_ref = (uint64_t)ret_var.inner;
39018 if (ret_var.is_owned) {
39019         ret_ref |= 1;
39020 }
39021         return ret_ref;
39022 }
39023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39024         LDKInvoice arg_conv;
39025         arg_conv.inner = (void*)(arg & (~1));
39026         arg_conv.is_owned = false;
39027         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39028         int64_t ret_val = Invoice_clone_ptr(&arg_conv);
39029         return ret_val;
39030 }
39031
39032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39033         LDKInvoice orig_conv;
39034         orig_conv.inner = (void*)(orig & (~1));
39035         orig_conv.is_owned = false;
39036         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39037         LDKInvoice ret_var = Invoice_clone(&orig_conv);
39038         uint64_t ret_ref = 0;
39039         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39040         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39042         ret_ref = (uint64_t)ret_var.inner;
39043         if (ret_var.is_owned) {
39044                 ret_ref |= 1;
39045         }
39046         return ret_ref;
39047 }
39048
39049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39050         LDKSignedRawInvoice this_obj_conv;
39051         this_obj_conv.inner = (void*)(this_obj & (~1));
39052         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39054         SignedRawInvoice_free(this_obj_conv);
39055 }
39056
39057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39058         LDKSignedRawInvoice a_conv;
39059         a_conv.inner = (void*)(a & (~1));
39060         a_conv.is_owned = false;
39061         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39062         LDKSignedRawInvoice b_conv;
39063         b_conv.inner = (void*)(b & (~1));
39064         b_conv.is_owned = false;
39065         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39066         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
39067         return ret_val;
39068 }
39069
39070 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
39071         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
39072 uint64_t ret_ref = 0;
39073 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39074 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39075 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39076 ret_ref = (uint64_t)ret_var.inner;
39077 if (ret_var.is_owned) {
39078         ret_ref |= 1;
39079 }
39080         return ret_ref;
39081 }
39082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39083         LDKSignedRawInvoice arg_conv;
39084         arg_conv.inner = (void*)(arg & (~1));
39085         arg_conv.is_owned = false;
39086         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39087         int64_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
39088         return ret_val;
39089 }
39090
39091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39092         LDKSignedRawInvoice orig_conv;
39093         orig_conv.inner = (void*)(orig & (~1));
39094         orig_conv.is_owned = false;
39095         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39096         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
39097         uint64_t ret_ref = 0;
39098         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39099         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39101         ret_ref = (uint64_t)ret_var.inner;
39102         if (ret_var.is_owned) {
39103                 ret_ref |= 1;
39104         }
39105         return ret_ref;
39106 }
39107
39108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39109         LDKRawInvoice this_obj_conv;
39110         this_obj_conv.inner = (void*)(this_obj & (~1));
39111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39113         RawInvoice_free(this_obj_conv);
39114 }
39115
39116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
39117         LDKRawInvoice this_ptr_conv;
39118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39119         this_ptr_conv.is_owned = false;
39120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39121         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
39122         uint64_t ret_ref = 0;
39123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39126         ret_ref = (uint64_t)ret_var.inner;
39127         if (ret_var.is_owned) {
39128                 ret_ref |= 1;
39129         }
39130         return ret_ref;
39131 }
39132
39133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39134         LDKRawInvoice this_ptr_conv;
39135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39136         this_ptr_conv.is_owned = false;
39137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39138         LDKRawDataPart val_conv;
39139         val_conv.inner = (void*)(val & (~1));
39140         val_conv.is_owned = (val & 1) || (val == 0);
39141         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39142         val_conv = RawDataPart_clone(&val_conv);
39143         RawInvoice_set_data(&this_ptr_conv, val_conv);
39144 }
39145
39146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39147         LDKRawInvoice a_conv;
39148         a_conv.inner = (void*)(a & (~1));
39149         a_conv.is_owned = false;
39150         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39151         LDKRawInvoice b_conv;
39152         b_conv.inner = (void*)(b & (~1));
39153         b_conv.is_owned = false;
39154         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39155         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
39156         return ret_val;
39157 }
39158
39159 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
39160         LDKRawInvoice ret_var = RawInvoice_clone(arg);
39161 uint64_t ret_ref = 0;
39162 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39163 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39164 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39165 ret_ref = (uint64_t)ret_var.inner;
39166 if (ret_var.is_owned) {
39167         ret_ref |= 1;
39168 }
39169         return ret_ref;
39170 }
39171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39172         LDKRawInvoice arg_conv;
39173         arg_conv.inner = (void*)(arg & (~1));
39174         arg_conv.is_owned = false;
39175         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39176         int64_t ret_val = RawInvoice_clone_ptr(&arg_conv);
39177         return ret_val;
39178 }
39179
39180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39181         LDKRawInvoice orig_conv;
39182         orig_conv.inner = (void*)(orig & (~1));
39183         orig_conv.is_owned = false;
39184         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39185         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
39186         uint64_t ret_ref = 0;
39187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39190         ret_ref = (uint64_t)ret_var.inner;
39191         if (ret_var.is_owned) {
39192                 ret_ref |= 1;
39193         }
39194         return ret_ref;
39195 }
39196
39197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39198         LDKRawDataPart 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         RawDataPart_free(this_obj_conv);
39203 }
39204
39205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
39206         LDKRawDataPart this_ptr_conv;
39207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39208         this_ptr_conv.is_owned = false;
39209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39210         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
39211         uint64_t ret_ref = 0;
39212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39215         ret_ref = (uint64_t)ret_var.inner;
39216         if (ret_var.is_owned) {
39217                 ret_ref |= 1;
39218         }
39219         return ret_ref;
39220 }
39221
39222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39223         LDKRawDataPart this_ptr_conv;
39224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39225         this_ptr_conv.is_owned = false;
39226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39227         LDKPositiveTimestamp val_conv;
39228         val_conv.inner = (void*)(val & (~1));
39229         val_conv.is_owned = (val & 1) || (val == 0);
39230         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39231         val_conv = PositiveTimestamp_clone(&val_conv);
39232         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
39233 }
39234
39235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39236         LDKRawDataPart a_conv;
39237         a_conv.inner = (void*)(a & (~1));
39238         a_conv.is_owned = false;
39239         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39240         LDKRawDataPart b_conv;
39241         b_conv.inner = (void*)(b & (~1));
39242         b_conv.is_owned = false;
39243         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39244         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
39245         return ret_val;
39246 }
39247
39248 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
39249         LDKRawDataPart ret_var = RawDataPart_clone(arg);
39250 uint64_t ret_ref = 0;
39251 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39252 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39253 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39254 ret_ref = (uint64_t)ret_var.inner;
39255 if (ret_var.is_owned) {
39256         ret_ref |= 1;
39257 }
39258         return ret_ref;
39259 }
39260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39261         LDKRawDataPart arg_conv;
39262         arg_conv.inner = (void*)(arg & (~1));
39263         arg_conv.is_owned = false;
39264         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39265         int64_t ret_val = RawDataPart_clone_ptr(&arg_conv);
39266         return ret_val;
39267 }
39268
39269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39270         LDKRawDataPart orig_conv;
39271         orig_conv.inner = (void*)(orig & (~1));
39272         orig_conv.is_owned = false;
39273         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39274         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
39275         uint64_t ret_ref = 0;
39276         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39277         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39279         ret_ref = (uint64_t)ret_var.inner;
39280         if (ret_var.is_owned) {
39281                 ret_ref |= 1;
39282         }
39283         return ret_ref;
39284 }
39285
39286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39287         LDKPositiveTimestamp this_obj_conv;
39288         this_obj_conv.inner = (void*)(this_obj & (~1));
39289         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39291         PositiveTimestamp_free(this_obj_conv);
39292 }
39293
39294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39295         LDKPositiveTimestamp a_conv;
39296         a_conv.inner = (void*)(a & (~1));
39297         a_conv.is_owned = false;
39298         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39299         LDKPositiveTimestamp b_conv;
39300         b_conv.inner = (void*)(b & (~1));
39301         b_conv.is_owned = false;
39302         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39303         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
39304         return ret_val;
39305 }
39306
39307 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
39308         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
39309 uint64_t ret_ref = 0;
39310 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39311 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39312 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39313 ret_ref = (uint64_t)ret_var.inner;
39314 if (ret_var.is_owned) {
39315         ret_ref |= 1;
39316 }
39317         return ret_ref;
39318 }
39319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39320         LDKPositiveTimestamp arg_conv;
39321         arg_conv.inner = (void*)(arg & (~1));
39322         arg_conv.is_owned = false;
39323         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39324         int64_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
39325         return ret_val;
39326 }
39327
39328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39329         LDKPositiveTimestamp orig_conv;
39330         orig_conv.inner = (void*)(orig & (~1));
39331         orig_conv.is_owned = false;
39332         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39333         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
39334         uint64_t ret_ref = 0;
39335         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39336         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39338         ret_ref = (uint64_t)ret_var.inner;
39339         if (ret_var.is_owned) {
39340                 ret_ref |= 1;
39341         }
39342         return ret_ref;
39343 }
39344
39345 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39346         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
39347         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
39348         return ret_conv;
39349 }
39350
39351 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
39352         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
39353         return ret_conv;
39354 }
39355
39356 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
39357         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
39358         return ret_conv;
39359 }
39360
39361 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
39362         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
39363         return ret_conv;
39364 }
39365
39366 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
39367         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
39368         return ret_conv;
39369 }
39370
39371 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39372         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
39373         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
39374         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
39375         return ret_val;
39376 }
39377
39378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
39379         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
39380         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
39381         return ret_val;
39382 }
39383
39384 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39385         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
39386         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
39387         return ret_conv;
39388 }
39389
39390 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
39391         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
39392         return ret_conv;
39393 }
39394
39395 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
39396         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
39397         return ret_conv;
39398 }
39399
39400 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
39401         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
39402         return ret_conv;
39403 }
39404
39405 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
39406         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
39407         return ret_conv;
39408 }
39409
39410 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
39411         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
39412         return ret_conv;
39413 }
39414
39415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
39416         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
39417         int64_t ret_val = Currency_hash(o_conv);
39418         return ret_val;
39419 }
39420
39421 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39422         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
39423         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
39424         jboolean ret_val = Currency_eq(a_conv, b_conv);
39425         return ret_val;
39426 }
39427
39428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39429         LDKSha256 this_obj_conv;
39430         this_obj_conv.inner = (void*)(this_obj & (~1));
39431         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39433         Sha256_free(this_obj_conv);
39434 }
39435
39436 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
39437         LDKSha256 ret_var = Sha256_clone(arg);
39438 uint64_t ret_ref = 0;
39439 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39440 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39441 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39442 ret_ref = (uint64_t)ret_var.inner;
39443 if (ret_var.is_owned) {
39444         ret_ref |= 1;
39445 }
39446         return ret_ref;
39447 }
39448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39449         LDKSha256 arg_conv;
39450         arg_conv.inner = (void*)(arg & (~1));
39451         arg_conv.is_owned = false;
39452         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39453         int64_t ret_val = Sha256_clone_ptr(&arg_conv);
39454         return ret_val;
39455 }
39456
39457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39458         LDKSha256 orig_conv;
39459         orig_conv.inner = (void*)(orig & (~1));
39460         orig_conv.is_owned = false;
39461         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39462         LDKSha256 ret_var = Sha256_clone(&orig_conv);
39463         uint64_t ret_ref = 0;
39464         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39465         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39467         ret_ref = (uint64_t)ret_var.inner;
39468         if (ret_var.is_owned) {
39469                 ret_ref |= 1;
39470         }
39471         return ret_ref;
39472 }
39473
39474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
39475         LDKSha256 o_conv;
39476         o_conv.inner = (void*)(o & (~1));
39477         o_conv.is_owned = false;
39478         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39479         int64_t ret_val = Sha256_hash(&o_conv);
39480         return ret_val;
39481 }
39482
39483 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39484         LDKSha256 a_conv;
39485         a_conv.inner = (void*)(a & (~1));
39486         a_conv.is_owned = false;
39487         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39488         LDKSha256 b_conv;
39489         b_conv.inner = (void*)(b & (~1));
39490         b_conv.is_owned = false;
39491         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39492         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
39493         return ret_val;
39494 }
39495
39496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39497         LDKDescription this_obj_conv;
39498         this_obj_conv.inner = (void*)(this_obj & (~1));
39499         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39501         Description_free(this_obj_conv);
39502 }
39503
39504 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
39505         LDKDescription ret_var = Description_clone(arg);
39506 uint64_t ret_ref = 0;
39507 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39508 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39509 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39510 ret_ref = (uint64_t)ret_var.inner;
39511 if (ret_var.is_owned) {
39512         ret_ref |= 1;
39513 }
39514         return ret_ref;
39515 }
39516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39517         LDKDescription arg_conv;
39518         arg_conv.inner = (void*)(arg & (~1));
39519         arg_conv.is_owned = false;
39520         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39521         int64_t ret_val = Description_clone_ptr(&arg_conv);
39522         return ret_val;
39523 }
39524
39525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39526         LDKDescription orig_conv;
39527         orig_conv.inner = (void*)(orig & (~1));
39528         orig_conv.is_owned = false;
39529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39530         LDKDescription ret_var = Description_clone(&orig_conv);
39531         uint64_t ret_ref = 0;
39532         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39533         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39535         ret_ref = (uint64_t)ret_var.inner;
39536         if (ret_var.is_owned) {
39537                 ret_ref |= 1;
39538         }
39539         return ret_ref;
39540 }
39541
39542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
39543         LDKDescription o_conv;
39544         o_conv.inner = (void*)(o & (~1));
39545         o_conv.is_owned = false;
39546         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39547         int64_t ret_val = Description_hash(&o_conv);
39548         return ret_val;
39549 }
39550
39551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39552         LDKDescription a_conv;
39553         a_conv.inner = (void*)(a & (~1));
39554         a_conv.is_owned = false;
39555         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39556         LDKDescription b_conv;
39557         b_conv.inner = (void*)(b & (~1));
39558         b_conv.is_owned = false;
39559         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39560         jboolean ret_val = Description_eq(&a_conv, &b_conv);
39561         return ret_val;
39562 }
39563
39564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39565         LDKPayeePubKey this_obj_conv;
39566         this_obj_conv.inner = (void*)(this_obj & (~1));
39567         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39569         PayeePubKey_free(this_obj_conv);
39570 }
39571
39572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
39573         LDKPayeePubKey this_ptr_conv;
39574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39575         this_ptr_conv.is_owned = false;
39576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39577         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39578         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
39579         return ret_arr;
39580 }
39581
39582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39583         LDKPayeePubKey this_ptr_conv;
39584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39585         this_ptr_conv.is_owned = false;
39586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39587         LDKPublicKey val_ref;
39588         CHECK((*env)->GetArrayLength(env, val) == 33);
39589         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39590         PayeePubKey_set_a(&this_ptr_conv, val_ref);
39591 }
39592
39593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
39594         LDKPublicKey a_arg_ref;
39595         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
39596         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
39597         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
39598         uint64_t ret_ref = 0;
39599         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39600         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39602         ret_ref = (uint64_t)ret_var.inner;
39603         if (ret_var.is_owned) {
39604                 ret_ref |= 1;
39605         }
39606         return ret_ref;
39607 }
39608
39609 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
39610         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
39611 uint64_t ret_ref = 0;
39612 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39613 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39614 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39615 ret_ref = (uint64_t)ret_var.inner;
39616 if (ret_var.is_owned) {
39617         ret_ref |= 1;
39618 }
39619         return ret_ref;
39620 }
39621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39622         LDKPayeePubKey arg_conv;
39623         arg_conv.inner = (void*)(arg & (~1));
39624         arg_conv.is_owned = false;
39625         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39626         int64_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
39627         return ret_val;
39628 }
39629
39630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39631         LDKPayeePubKey orig_conv;
39632         orig_conv.inner = (void*)(orig & (~1));
39633         orig_conv.is_owned = false;
39634         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39635         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
39636         uint64_t ret_ref = 0;
39637         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39638         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39640         ret_ref = (uint64_t)ret_var.inner;
39641         if (ret_var.is_owned) {
39642                 ret_ref |= 1;
39643         }
39644         return ret_ref;
39645 }
39646
39647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
39648         LDKPayeePubKey o_conv;
39649         o_conv.inner = (void*)(o & (~1));
39650         o_conv.is_owned = false;
39651         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39652         int64_t ret_val = PayeePubKey_hash(&o_conv);
39653         return ret_val;
39654 }
39655
39656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39657         LDKPayeePubKey a_conv;
39658         a_conv.inner = (void*)(a & (~1));
39659         a_conv.is_owned = false;
39660         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39661         LDKPayeePubKey b_conv;
39662         b_conv.inner = (void*)(b & (~1));
39663         b_conv.is_owned = false;
39664         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39665         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
39666         return ret_val;
39667 }
39668
39669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39670         LDKExpiryTime this_obj_conv;
39671         this_obj_conv.inner = (void*)(this_obj & (~1));
39672         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39674         ExpiryTime_free(this_obj_conv);
39675 }
39676
39677 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
39678         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
39679 uint64_t ret_ref = 0;
39680 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39681 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39682 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39683 ret_ref = (uint64_t)ret_var.inner;
39684 if (ret_var.is_owned) {
39685         ret_ref |= 1;
39686 }
39687         return ret_ref;
39688 }
39689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39690         LDKExpiryTime arg_conv;
39691         arg_conv.inner = (void*)(arg & (~1));
39692         arg_conv.is_owned = false;
39693         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39694         int64_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
39695         return ret_val;
39696 }
39697
39698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39699         LDKExpiryTime orig_conv;
39700         orig_conv.inner = (void*)(orig & (~1));
39701         orig_conv.is_owned = false;
39702         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39703         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
39704         uint64_t ret_ref = 0;
39705         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39706         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39708         ret_ref = (uint64_t)ret_var.inner;
39709         if (ret_var.is_owned) {
39710                 ret_ref |= 1;
39711         }
39712         return ret_ref;
39713 }
39714
39715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
39716         LDKExpiryTime o_conv;
39717         o_conv.inner = (void*)(o & (~1));
39718         o_conv.is_owned = false;
39719         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39720         int64_t ret_val = ExpiryTime_hash(&o_conv);
39721         return ret_val;
39722 }
39723
39724 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39725         LDKExpiryTime a_conv;
39726         a_conv.inner = (void*)(a & (~1));
39727         a_conv.is_owned = false;
39728         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39729         LDKExpiryTime b_conv;
39730         b_conv.inner = (void*)(b & (~1));
39731         b_conv.is_owned = false;
39732         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39733         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
39734         return ret_val;
39735 }
39736
39737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39738         LDKMinFinalCltvExpiry this_obj_conv;
39739         this_obj_conv.inner = (void*)(this_obj & (~1));
39740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39742         MinFinalCltvExpiry_free(this_obj_conv);
39743 }
39744
39745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
39746         LDKMinFinalCltvExpiry this_ptr_conv;
39747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39748         this_ptr_conv.is_owned = false;
39749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39750         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
39751         return ret_val;
39752 }
39753
39754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39755         LDKMinFinalCltvExpiry this_ptr_conv;
39756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39757         this_ptr_conv.is_owned = false;
39758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39759         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
39760 }
39761
39762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
39763         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
39764         uint64_t ret_ref = 0;
39765         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39766         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39768         ret_ref = (uint64_t)ret_var.inner;
39769         if (ret_var.is_owned) {
39770                 ret_ref |= 1;
39771         }
39772         return ret_ref;
39773 }
39774
39775 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
39776         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
39777 uint64_t ret_ref = 0;
39778 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39779 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39780 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39781 ret_ref = (uint64_t)ret_var.inner;
39782 if (ret_var.is_owned) {
39783         ret_ref |= 1;
39784 }
39785         return ret_ref;
39786 }
39787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39788         LDKMinFinalCltvExpiry arg_conv;
39789         arg_conv.inner = (void*)(arg & (~1));
39790         arg_conv.is_owned = false;
39791         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39792         int64_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
39793         return ret_val;
39794 }
39795
39796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39797         LDKMinFinalCltvExpiry orig_conv;
39798         orig_conv.inner = (void*)(orig & (~1));
39799         orig_conv.is_owned = false;
39800         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39801         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
39802         uint64_t ret_ref = 0;
39803         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39804         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39806         ret_ref = (uint64_t)ret_var.inner;
39807         if (ret_var.is_owned) {
39808                 ret_ref |= 1;
39809         }
39810         return ret_ref;
39811 }
39812
39813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
39814         LDKMinFinalCltvExpiry o_conv;
39815         o_conv.inner = (void*)(o & (~1));
39816         o_conv.is_owned = false;
39817         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39818         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
39819         return ret_val;
39820 }
39821
39822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39823         LDKMinFinalCltvExpiry a_conv;
39824         a_conv.inner = (void*)(a & (~1));
39825         a_conv.is_owned = false;
39826         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39827         LDKMinFinalCltvExpiry b_conv;
39828         b_conv.inner = (void*)(b & (~1));
39829         b_conv.is_owned = false;
39830         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39831         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
39832         return ret_val;
39833 }
39834
39835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39836         if ((this_ptr & 1) != 0) return;
39837         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
39838         CHECK_ACCESS(this_ptr_ptr);
39839         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
39840         FREE((void*)this_ptr);
39841         Fallback_free(this_ptr_conv);
39842 }
39843
39844 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
39845         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39846         *ret_copy = Fallback_clone(arg);
39847 uint64_t ret_ref = (uint64_t)ret_copy;
39848         return ret_ref;
39849 }
39850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39851         LDKFallback* arg_conv = (LDKFallback*)arg;
39852         int64_t ret_val = Fallback_clone_ptr(arg_conv);
39853         return ret_val;
39854 }
39855
39856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39857         LDKFallback* orig_conv = (LDKFallback*)orig;
39858         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39859         *ret_copy = Fallback_clone(orig_conv);
39860         uint64_t ret_ref = (uint64_t)ret_copy;
39861         return ret_ref;
39862 }
39863
39864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
39865         
39866         LDKCVec_u8Z program_ref;
39867         program_ref.datalen = (*env)->GetArrayLength(env, program);
39868         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
39869         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
39870         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39871         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
39872         uint64_t ret_ref = (uint64_t)ret_copy;
39873         return ret_ref;
39874 }
39875
39876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
39877         LDKTwentyBytes a_ref;
39878         CHECK((*env)->GetArrayLength(env, a) == 20);
39879         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
39880         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39881         *ret_copy = Fallback_pub_key_hash(a_ref);
39882         uint64_t ret_ref = (uint64_t)ret_copy;
39883         return ret_ref;
39884 }
39885
39886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
39887         LDKTwentyBytes a_ref;
39888         CHECK((*env)->GetArrayLength(env, a) == 20);
39889         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
39890         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
39891         *ret_copy = Fallback_script_hash(a_ref);
39892         uint64_t ret_ref = (uint64_t)ret_copy;
39893         return ret_ref;
39894 }
39895
39896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
39897         LDKFallback* o_conv = (LDKFallback*)o;
39898         int64_t ret_val = Fallback_hash(o_conv);
39899         return ret_val;
39900 }
39901
39902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39903         LDKFallback* a_conv = (LDKFallback*)a;
39904         LDKFallback* b_conv = (LDKFallback*)b;
39905         jboolean ret_val = Fallback_eq(a_conv, b_conv);
39906         return ret_val;
39907 }
39908
39909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39910         LDKInvoiceSignature this_obj_conv;
39911         this_obj_conv.inner = (void*)(this_obj & (~1));
39912         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39914         InvoiceSignature_free(this_obj_conv);
39915 }
39916
39917 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
39918         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
39919 uint64_t ret_ref = 0;
39920 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39921 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39922 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39923 ret_ref = (uint64_t)ret_var.inner;
39924 if (ret_var.is_owned) {
39925         ret_ref |= 1;
39926 }
39927         return ret_ref;
39928 }
39929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39930         LDKInvoiceSignature arg_conv;
39931         arg_conv.inner = (void*)(arg & (~1));
39932         arg_conv.is_owned = false;
39933         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39934         int64_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
39935         return ret_val;
39936 }
39937
39938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39939         LDKInvoiceSignature orig_conv;
39940         orig_conv.inner = (void*)(orig & (~1));
39941         orig_conv.is_owned = false;
39942         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39943         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
39944         uint64_t ret_ref = 0;
39945         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39946         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39948         ret_ref = (uint64_t)ret_var.inner;
39949         if (ret_var.is_owned) {
39950                 ret_ref |= 1;
39951         }
39952         return ret_ref;
39953 }
39954
39955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39956         LDKInvoiceSignature a_conv;
39957         a_conv.inner = (void*)(a & (~1));
39958         a_conv.is_owned = false;
39959         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39960         LDKInvoiceSignature b_conv;
39961         b_conv.inner = (void*)(b & (~1));
39962         b_conv.is_owned = false;
39963         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39964         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
39965         return ret_val;
39966 }
39967
39968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39969         LDKPrivateRoute this_obj_conv;
39970         this_obj_conv.inner = (void*)(this_obj & (~1));
39971         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39973         PrivateRoute_free(this_obj_conv);
39974 }
39975
39976 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
39977         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
39978 uint64_t ret_ref = 0;
39979 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39980 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39981 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39982 ret_ref = (uint64_t)ret_var.inner;
39983 if (ret_var.is_owned) {
39984         ret_ref |= 1;
39985 }
39986         return ret_ref;
39987 }
39988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39989         LDKPrivateRoute arg_conv;
39990         arg_conv.inner = (void*)(arg & (~1));
39991         arg_conv.is_owned = false;
39992         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39993         int64_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
39994         return ret_val;
39995 }
39996
39997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39998         LDKPrivateRoute orig_conv;
39999         orig_conv.inner = (void*)(orig & (~1));
40000         orig_conv.is_owned = false;
40001         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40002         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
40003         uint64_t ret_ref = 0;
40004         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40005         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40007         ret_ref = (uint64_t)ret_var.inner;
40008         if (ret_var.is_owned) {
40009                 ret_ref |= 1;
40010         }
40011         return ret_ref;
40012 }
40013
40014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
40015         LDKPrivateRoute o_conv;
40016         o_conv.inner = (void*)(o & (~1));
40017         o_conv.is_owned = false;
40018         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40019         int64_t ret_val = PrivateRoute_hash(&o_conv);
40020         return ret_val;
40021 }
40022
40023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40024         LDKPrivateRoute a_conv;
40025         a_conv.inner = (void*)(a & (~1));
40026         a_conv.is_owned = false;
40027         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40028         LDKPrivateRoute b_conv;
40029         b_conv.inner = (void*)(b & (~1));
40030         b_conv.is_owned = false;
40031         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40032         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
40033         return ret_val;
40034 }
40035
40036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
40037         LDKSignedRawInvoice this_arg_conv;
40038         this_arg_conv.inner = (void*)(this_arg & (~1));
40039         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40041         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
40042         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
40043         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
40044         return ((uint64_t)ret_conv);
40045 }
40046
40047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
40048         LDKSignedRawInvoice this_arg_conv;
40049         this_arg_conv.inner = (void*)(this_arg & (~1));
40050         this_arg_conv.is_owned = false;
40051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40052         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
40053         uint64_t ret_ref = 0;
40054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40057         ret_ref = (uint64_t)ret_var.inner;
40058         if (ret_var.is_owned) {
40059                 ret_ref |= 1;
40060         }
40061         return ret_ref;
40062 }
40063
40064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
40065         LDKSignedRawInvoice this_arg_conv;
40066         this_arg_conv.inner = (void*)(this_arg & (~1));
40067         this_arg_conv.is_owned = false;
40068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40069         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40070         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
40071         return ret_arr;
40072 }
40073
40074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
40075         LDKSignedRawInvoice this_arg_conv;
40076         this_arg_conv.inner = (void*)(this_arg & (~1));
40077         this_arg_conv.is_owned = false;
40078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40079         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
40080         uint64_t ret_ref = 0;
40081         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40082         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40084         ret_ref = (uint64_t)ret_var.inner;
40085         if (ret_var.is_owned) {
40086                 ret_ref |= 1;
40087         }
40088         return ret_ref;
40089 }
40090
40091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40092         LDKSignedRawInvoice this_arg_conv;
40093         this_arg_conv.inner = (void*)(this_arg & (~1));
40094         this_arg_conv.is_owned = false;
40095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40096         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
40097         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
40098         return (uint64_t)ret_conv;
40099 }
40100
40101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
40102         LDKSignedRawInvoice this_arg_conv;
40103         this_arg_conv.inner = (void*)(this_arg & (~1));
40104         this_arg_conv.is_owned = false;
40105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40106         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
40107         return ret_val;
40108 }
40109
40110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
40111         LDKRawInvoice this_arg_conv;
40112         this_arg_conv.inner = (void*)(this_arg & (~1));
40113         this_arg_conv.is_owned = false;
40114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40115         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
40117         return ret_arr;
40118 }
40119
40120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
40121         LDKRawInvoice this_arg_conv;
40122         this_arg_conv.inner = (void*)(this_arg & (~1));
40123         this_arg_conv.is_owned = false;
40124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40125         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
40126         uint64_t ret_ref = 0;
40127         if ((uint64_t)ret_var.inner > 4096) {
40128                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40129                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40131                 ret_ref = (uint64_t)ret_var.inner;
40132                 if (ret_var.is_owned) {
40133                         ret_ref |= 1;
40134                 }
40135         }
40136         return ret_ref;
40137 }
40138
40139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
40140         LDKRawInvoice this_arg_conv;
40141         this_arg_conv.inner = (void*)(this_arg & (~1));
40142         this_arg_conv.is_owned = false;
40143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40144         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
40145         uint64_t ret_ref = 0;
40146         if ((uint64_t)ret_var.inner > 4096) {
40147                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40148                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40150                 ret_ref = (uint64_t)ret_var.inner;
40151                 if (ret_var.is_owned) {
40152                         ret_ref |= 1;
40153                 }
40154         }
40155         return ret_ref;
40156 }
40157
40158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40159         LDKRawInvoice this_arg_conv;
40160         this_arg_conv.inner = (void*)(this_arg & (~1));
40161         this_arg_conv.is_owned = false;
40162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40163         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
40164         uint64_t ret_ref = 0;
40165         if ((uint64_t)ret_var.inner > 4096) {
40166                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40167                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40169                 ret_ref = (uint64_t)ret_var.inner;
40170                 if (ret_var.is_owned) {
40171                         ret_ref |= 1;
40172                 }
40173         }
40174         return ret_ref;
40175 }
40176
40177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
40178         LDKRawInvoice this_arg_conv;
40179         this_arg_conv.inner = (void*)(this_arg & (~1));
40180         this_arg_conv.is_owned = false;
40181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40182         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
40183         uint64_t ret_ref = 0;
40184         if ((uint64_t)ret_var.inner > 4096) {
40185                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40186                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40188                 ret_ref = (uint64_t)ret_var.inner;
40189                 if (ret_var.is_owned) {
40190                         ret_ref |= 1;
40191                 }
40192         }
40193         return ret_ref;
40194 }
40195
40196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
40197         LDKRawInvoice this_arg_conv;
40198         this_arg_conv.inner = (void*)(this_arg & (~1));
40199         this_arg_conv.is_owned = false;
40200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40201         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
40202         uint64_t ret_ref = 0;
40203         if ((uint64_t)ret_var.inner > 4096) {
40204                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40205                 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
40208                 if (ret_var.is_owned) {
40209                         ret_ref |= 1;
40210                 }
40211         }
40212         return ret_ref;
40213 }
40214
40215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
40216         LDKRawInvoice this_arg_conv;
40217         this_arg_conv.inner = (void*)(this_arg & (~1));
40218         this_arg_conv.is_owned = false;
40219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40220         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
40221         uint64_t ret_ref = 0;
40222         if ((uint64_t)ret_var.inner > 4096) {
40223                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40224                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40226                 ret_ref = (uint64_t)ret_var.inner;
40227                 if (ret_var.is_owned) {
40228                         ret_ref |= 1;
40229                 }
40230         }
40231         return ret_ref;
40232 }
40233
40234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40235         LDKRawInvoice this_arg_conv;
40236         this_arg_conv.inner = (void*)(this_arg & (~1));
40237         this_arg_conv.is_owned = false;
40238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40239         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40240         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
40241         return ret_arr;
40242 }
40243
40244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
40245         LDKRawInvoice this_arg_conv;
40246         this_arg_conv.inner = (void*)(this_arg & (~1));
40247         this_arg_conv.is_owned = false;
40248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40249         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
40250         uint64_t ret_ref = 0;
40251         if ((uint64_t)ret_var.inner > 4096) {
40252                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40253                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40255                 ret_ref = (uint64_t)ret_var.inner;
40256                 if (ret_var.is_owned) {
40257                         ret_ref |= 1;
40258                 }
40259         }
40260         return ret_ref;
40261 }
40262
40263 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
40264         LDKRawInvoice this_arg_conv;
40265         this_arg_conv.inner = (void*)(this_arg & (~1));
40266         this_arg_conv.is_owned = false;
40267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40268         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
40269         int64_tArray ret_arr = NULL;
40270         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40271         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40272         for (size_t o = 0; o < ret_var.datalen; o++) {
40273                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
40274                 uint64_t ret_conv_14_ref = 0;
40275                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40276                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40277                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
40278                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
40279                 if (ret_conv_14_var.is_owned) {
40280                         ret_conv_14_ref |= 1;
40281                 }
40282                 ret_arr_ptr[o] = ret_conv_14_ref;
40283         }
40284         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40285         FREE(ret_var.data);
40286         return ret_arr;
40287 }
40288
40289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
40290         LDKRawInvoice this_arg_conv;
40291         this_arg_conv.inner = (void*)(this_arg & (~1));
40292         this_arg_conv.is_owned = false;
40293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40294         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40295         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
40296         uint64_t ret_ref = (uint64_t)ret_copy;
40297         return ret_ref;
40298 }
40299
40300 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
40301         LDKRawInvoice this_arg_conv;
40302         this_arg_conv.inner = (void*)(this_arg & (~1));
40303         this_arg_conv.is_owned = false;
40304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40305         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
40306         return ret_conv;
40307 }
40308
40309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
40310         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
40311         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
40312         return (uint64_t)ret_conv;
40313 }
40314
40315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
40316         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
40317         *ret_conv = PositiveTimestamp_from_system_time(time);
40318         return (uint64_t)ret_conv;
40319 }
40320
40321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
40322         LDKPositiveTimestamp this_arg_conv;
40323         this_arg_conv.inner = (void*)(this_arg & (~1));
40324         this_arg_conv.is_owned = false;
40325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40326         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
40327         return ret_val;
40328 }
40329
40330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
40331         LDKPositiveTimestamp this_arg_conv;
40332         this_arg_conv.inner = (void*)(this_arg & (~1));
40333         this_arg_conv.is_owned = false;
40334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40335         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
40336         return ret_val;
40337 }
40338
40339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
40340         LDKInvoice this_arg_conv;
40341         this_arg_conv.inner = (void*)(this_arg & (~1));
40342         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40344         this_arg_conv = Invoice_clone(&this_arg_conv);
40345         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
40346         uint64_t ret_ref = 0;
40347         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40348         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40350         ret_ref = (uint64_t)ret_var.inner;
40351         if (ret_var.is_owned) {
40352                 ret_ref |= 1;
40353         }
40354         return ret_ref;
40355 }
40356
40357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
40358         LDKInvoice this_arg_conv;
40359         this_arg_conv.inner = (void*)(this_arg & (~1));
40360         this_arg_conv.is_owned = false;
40361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40362         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
40363         *ret_conv = Invoice_check_signature(&this_arg_conv);
40364         return (uint64_t)ret_conv;
40365 }
40366
40367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
40368         LDKSignedRawInvoice signed_invoice_conv;
40369         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
40370         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
40371         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
40372         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
40373         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
40374         *ret_conv = Invoice_from_signed(signed_invoice_conv);
40375         return (uint64_t)ret_conv;
40376 }
40377
40378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
40379         LDKInvoice this_arg_conv;
40380         this_arg_conv.inner = (void*)(this_arg & (~1));
40381         this_arg_conv.is_owned = false;
40382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40383         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
40384         return ret_val;
40385 }
40386
40387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
40388         LDKInvoice this_arg_conv;
40389         this_arg_conv.inner = (void*)(this_arg & (~1));
40390         this_arg_conv.is_owned = false;
40391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40392         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40393         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
40394         return ret_arr;
40395 }
40396
40397 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40398         LDKInvoice this_arg_conv;
40399         this_arg_conv.inner = (void*)(this_arg & (~1));
40400         this_arg_conv.is_owned = false;
40401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40402         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40403         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
40404         return ret_arr;
40405 }
40406
40407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40408         LDKInvoice this_arg_conv;
40409         this_arg_conv.inner = (void*)(this_arg & (~1));
40410         this_arg_conv.is_owned = false;
40411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40412         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40413         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
40414         return ret_arr;
40415 }
40416
40417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
40418         LDKInvoice this_arg_conv;
40419         this_arg_conv.inner = (void*)(this_arg & (~1));
40420         this_arg_conv.is_owned = false;
40421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40422         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
40423         uint64_t ret_ref = 0;
40424         if ((uint64_t)ret_var.inner > 4096) {
40425                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40426                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40428                 ret_ref = (uint64_t)ret_var.inner;
40429                 if (ret_var.is_owned) {
40430                         ret_ref |= 1;
40431                 }
40432         }
40433         return ret_ref;
40434 }
40435
40436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40437         LDKInvoice this_arg_conv;
40438         this_arg_conv.inner = (void*)(this_arg & (~1));
40439         this_arg_conv.is_owned = false;
40440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40441         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40442         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
40443         return ret_arr;
40444 }
40445
40446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
40447         LDKInvoice this_arg_conv;
40448         this_arg_conv.inner = (void*)(this_arg & (~1));
40449         this_arg_conv.is_owned = false;
40450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40451         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
40452         return ret_val;
40453 }
40454
40455 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
40456         LDKInvoice this_arg_conv;
40457         this_arg_conv.inner = (void*)(this_arg & (~1));
40458         this_arg_conv.is_owned = false;
40459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40460         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
40461         return ret_val;
40462 }
40463
40464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
40465         LDKInvoice this_arg_conv;
40466         this_arg_conv.inner = (void*)(this_arg & (~1));
40467         this_arg_conv.is_owned = false;
40468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40469         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
40470         return ret_val;
40471 }
40472
40473 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
40474         LDKInvoice this_arg_conv;
40475         this_arg_conv.inner = (void*)(this_arg & (~1));
40476         this_arg_conv.is_owned = false;
40477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40478         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
40479         int64_tArray ret_arr = NULL;
40480         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40481         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40482         for (size_t o = 0; o < ret_var.datalen; o++) {
40483                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
40484                 uint64_t ret_conv_14_ref = 0;
40485                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40486                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40487                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
40488                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
40489                 if (ret_conv_14_var.is_owned) {
40490                         ret_conv_14_ref |= 1;
40491                 }
40492                 ret_arr_ptr[o] = ret_conv_14_ref;
40493         }
40494         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40495         FREE(ret_var.data);
40496         return ret_arr;
40497 }
40498
40499 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
40500         LDKInvoice this_arg_conv;
40501         this_arg_conv.inner = (void*)(this_arg & (~1));
40502         this_arg_conv.is_owned = false;
40503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40504         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
40505         int64_tArray ret_arr = NULL;
40506         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40507         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40508         for (size_t l = 0; l < ret_var.datalen; l++) {
40509                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
40510                 uint64_t ret_conv_11_ref = 0;
40511                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40512                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40513                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
40514                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
40515                 if (ret_conv_11_var.is_owned) {
40516                         ret_conv_11_ref |= 1;
40517                 }
40518                 ret_arr_ptr[l] = ret_conv_11_ref;
40519         }
40520         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40521         FREE(ret_var.data);
40522         return ret_arr;
40523 }
40524
40525 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
40526         LDKInvoice this_arg_conv;
40527         this_arg_conv.inner = (void*)(this_arg & (~1));
40528         this_arg_conv.is_owned = false;
40529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40530         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
40531         return ret_conv;
40532 }
40533
40534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
40535         LDKInvoice this_arg_conv;
40536         this_arg_conv.inner = (void*)(this_arg & (~1));
40537         this_arg_conv.is_owned = false;
40538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40539         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40540         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
40541         uint64_t ret_ref = (uint64_t)ret_copy;
40542         return ret_ref;
40543 }
40544
40545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
40546         LDKStr description_conv = java_to_owned_str(env, description);
40547         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
40548         *ret_conv = Description_new(description_conv);
40549         return (uint64_t)ret_conv;
40550 }
40551
40552 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
40553         LDKDescription this_arg_conv;
40554         this_arg_conv.inner = (void*)(this_arg & (~1));
40555         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40557         this_arg_conv = Description_clone(&this_arg_conv);
40558         LDKStr ret_str = Description_into_inner(this_arg_conv);
40559         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40560         Str_free(ret_str);
40561         return ret_conv;
40562 }
40563
40564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
40565         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
40566         *ret_conv = ExpiryTime_from_seconds(seconds);
40567         return (uint64_t)ret_conv;
40568 }
40569
40570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
40571         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
40572         *ret_conv = ExpiryTime_from_duration(duration);
40573         return (uint64_t)ret_conv;
40574 }
40575
40576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
40577         LDKExpiryTime this_arg_conv;
40578         this_arg_conv.inner = (void*)(this_arg & (~1));
40579         this_arg_conv.is_owned = false;
40580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40581         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
40582         return ret_val;
40583 }
40584
40585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
40586         LDKExpiryTime this_arg_conv;
40587         this_arg_conv.inner = (void*)(this_arg & (~1));
40588         this_arg_conv.is_owned = false;
40589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40590         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
40591         return ret_val;
40592 }
40593
40594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
40595         LDKRouteHint hops_conv;
40596         hops_conv.inner = (void*)(hops & (~1));
40597         hops_conv.is_owned = (hops & 1) || (hops == 0);
40598         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
40599         hops_conv = RouteHint_clone(&hops_conv);
40600         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
40601         *ret_conv = PrivateRoute_new(hops_conv);
40602         return (uint64_t)ret_conv;
40603 }
40604
40605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
40606         LDKPrivateRoute this_arg_conv;
40607         this_arg_conv.inner = (void*)(this_arg & (~1));
40608         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40610         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
40611         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
40612         uint64_t ret_ref = 0;
40613         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40614         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40616         ret_ref = (uint64_t)ret_var.inner;
40617         if (ret_var.is_owned) {
40618                 ret_ref |= 1;
40619         }
40620         return ret_ref;
40621 }
40622
40623 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40624         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
40625         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
40626         return ret_conv;
40627 }
40628
40629 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
40630         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
40631         return ret_conv;
40632 }
40633
40634 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
40635         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
40636         return ret_conv;
40637 }
40638
40639 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
40640         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
40641         return ret_conv;
40642 }
40643
40644 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
40645         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
40646         return ret_conv;
40647 }
40648
40649 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
40650         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
40651         return ret_conv;
40652 }
40653
40654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40655         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
40656         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
40657         jboolean ret_val = CreationError_eq(a_conv, b_conv);
40658         return ret_val;
40659 }
40660
40661 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40662         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
40663         LDKStr ret_str = CreationError_to_str(o_conv);
40664         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40665         Str_free(ret_str);
40666         return ret_conv;
40667 }
40668
40669 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40670         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
40671         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
40672         return ret_conv;
40673 }
40674
40675 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
40676         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
40677         return ret_conv;
40678 }
40679
40680 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
40681         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
40682         return ret_conv;
40683 }
40684
40685 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
40686         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
40687         return ret_conv;
40688 }
40689
40690 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
40691         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
40692         return ret_conv;
40693 }
40694
40695 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
40696         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
40697         return ret_conv;
40698 }
40699
40700 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
40701         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
40702         return ret_conv;
40703 }
40704
40705 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
40706         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
40707         return ret_conv;
40708 }
40709
40710 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
40711         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
40712         return ret_conv;
40713 }
40714
40715 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
40716         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
40717         return ret_conv;
40718 }
40719
40720 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
40721         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
40722         return ret_conv;
40723 }
40724
40725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40726         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
40727         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
40728         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
40729         return ret_val;
40730 }
40731
40732 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40733         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
40734         LDKStr ret_str = SemanticError_to_str(o_conv);
40735         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40736         Str_free(ret_str);
40737         return ret_conv;
40738 }
40739
40740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40741         if ((this_ptr & 1) != 0) return;
40742         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
40743         CHECK_ACCESS(this_ptr_ptr);
40744         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
40745         FREE((void*)this_ptr);
40746         SignOrCreationError_free(this_ptr_conv);
40747 }
40748
40749 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
40750         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40751         *ret_copy = SignOrCreationError_clone(arg);
40752 uint64_t ret_ref = (uint64_t)ret_copy;
40753         return ret_ref;
40754 }
40755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40756         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
40757         int64_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
40758         return ret_val;
40759 }
40760
40761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40762         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
40763         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40764         *ret_copy = SignOrCreationError_clone(orig_conv);
40765         uint64_t ret_ref = (uint64_t)ret_copy;
40766         return ret_ref;
40767 }
40768
40769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
40770         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40771         *ret_copy = SignOrCreationError_sign_error();
40772         uint64_t ret_ref = (uint64_t)ret_copy;
40773         return ret_ref;
40774 }
40775
40776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
40777         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
40778         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
40779         *ret_copy = SignOrCreationError_creation_error(a_conv);
40780         uint64_t ret_ref = (uint64_t)ret_copy;
40781         return ret_ref;
40782 }
40783
40784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40785         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
40786         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
40787         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
40788         return ret_val;
40789 }
40790
40791 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40792         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
40793         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
40794         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40795         Str_free(ret_str);
40796         return ret_conv;
40797 }
40798
40799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40800         LDKInvoicePayer this_obj_conv;
40801         this_obj_conv.inner = (void*)(this_obj & (~1));
40802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40804         InvoicePayer_free(this_obj_conv);
40805 }
40806
40807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40808         if ((this_ptr & 1) != 0) return;
40809         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
40810         CHECK_ACCESS(this_ptr_ptr);
40811         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
40812         FREE((void*)this_ptr);
40813         Payer_free(this_ptr_conv);
40814 }
40815
40816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40817         if ((this_ptr & 1) != 0) return;
40818         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
40819         CHECK_ACCESS(this_ptr_ptr);
40820         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
40821         FREE((void*)this_ptr);
40822         Router_free(this_ptr_conv);
40823 }
40824
40825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40826         LDKRetryAttempts this_obj_conv;
40827         this_obj_conv.inner = (void*)(this_obj & (~1));
40828         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40830         RetryAttempts_free(this_obj_conv);
40831 }
40832
40833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
40834         LDKRetryAttempts this_ptr_conv;
40835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40836         this_ptr_conv.is_owned = false;
40837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40838         int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
40839         return ret_val;
40840 }
40841
40842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40843         LDKRetryAttempts this_ptr_conv;
40844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40845         this_ptr_conv.is_owned = false;
40846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40847         RetryAttempts_set_a(&this_ptr_conv, val);
40848 }
40849
40850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
40851         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
40852         uint64_t ret_ref = 0;
40853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40856         ret_ref = (uint64_t)ret_var.inner;
40857         if (ret_var.is_owned) {
40858                 ret_ref |= 1;
40859         }
40860         return ret_ref;
40861 }
40862
40863 static inline uint64_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
40864         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
40865 uint64_t ret_ref = 0;
40866 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40867 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40868 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40869 ret_ref = (uint64_t)ret_var.inner;
40870 if (ret_var.is_owned) {
40871         ret_ref |= 1;
40872 }
40873         return ret_ref;
40874 }
40875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40876         LDKRetryAttempts arg_conv;
40877         arg_conv.inner = (void*)(arg & (~1));
40878         arg_conv.is_owned = false;
40879         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40880         int64_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
40881         return ret_val;
40882 }
40883
40884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40885         LDKRetryAttempts orig_conv;
40886         orig_conv.inner = (void*)(orig & (~1));
40887         orig_conv.is_owned = false;
40888         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40889         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
40890         uint64_t ret_ref = 0;
40891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40894         ret_ref = (uint64_t)ret_var.inner;
40895         if (ret_var.is_owned) {
40896                 ret_ref |= 1;
40897         }
40898         return ret_ref;
40899 }
40900
40901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40902         LDKRetryAttempts a_conv;
40903         a_conv.inner = (void*)(a & (~1));
40904         a_conv.is_owned = false;
40905         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40906         LDKRetryAttempts b_conv;
40907         b_conv.inner = (void*)(b & (~1));
40908         b_conv.is_owned = false;
40909         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40910         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
40911         return ret_val;
40912 }
40913
40914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
40915         LDKRetryAttempts o_conv;
40916         o_conv.inner = (void*)(o & (~1));
40917         o_conv.is_owned = false;
40918         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40919         int64_t ret_val = RetryAttempts_hash(&o_conv);
40920         return ret_val;
40921 }
40922
40923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40924         if ((this_ptr & 1) != 0) return;
40925         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
40926         CHECK_ACCESS(this_ptr_ptr);
40927         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
40928         FREE((void*)this_ptr);
40929         PaymentError_free(this_ptr_conv);
40930 }
40931
40932 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
40933         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40934         *ret_copy = PaymentError_clone(arg);
40935 uint64_t ret_ref = (uint64_t)ret_copy;
40936         return ret_ref;
40937 }
40938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40939         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
40940         int64_t ret_val = PaymentError_clone_ptr(arg_conv);
40941         return ret_val;
40942 }
40943
40944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40945         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
40946         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40947         *ret_copy = PaymentError_clone(orig_conv);
40948         uint64_t ret_ref = (uint64_t)ret_copy;
40949         return ret_ref;
40950 }
40951
40952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
40953         LDKStr a_conv = java_to_owned_str(env, a);
40954         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40955         *ret_copy = PaymentError_invoice(a_conv);
40956         uint64_t ret_ref = (uint64_t)ret_copy;
40957         return ret_ref;
40958 }
40959
40960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
40961         LDKLightningError a_conv;
40962         a_conv.inner = (void*)(a & (~1));
40963         a_conv.is_owned = (a & 1) || (a == 0);
40964         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40965         a_conv = LightningError_clone(&a_conv);
40966         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40967         *ret_copy = PaymentError_routing(a_conv);
40968         uint64_t ret_ref = (uint64_t)ret_copy;
40969         return ret_ref;
40970 }
40971
40972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
40973         void* a_ptr = (void*)(((uint64_t)a) & ~1);
40974         CHECK_ACCESS(a_ptr);
40975         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
40976         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
40977         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
40978         *ret_copy = PaymentError_sending(a_conv);
40979         uint64_t ret_ref = (uint64_t)ret_copy;
40980         return ret_ref;
40981 }
40982
40983 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) {
40984         void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
40985         CHECK_ACCESS(payer_ptr);
40986         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
40987         if (payer_conv.free == LDKPayer_JCalls_free) {
40988                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40989                 LDKPayer_JCalls_cloned(&payer_conv);
40990         }
40991         void* router_ptr = (void*)(((uint64_t)router) & ~1);
40992         CHECK_ACCESS(router_ptr);
40993         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
40994         if (router_conv.free == LDKRouter_JCalls_free) {
40995                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40996                 LDKRouter_JCalls_cloned(&router_conv);
40997         }
40998         LDKMultiThreadedLockableScore scorer_conv;
40999         scorer_conv.inner = (void*)(scorer & (~1));
41000         scorer_conv.is_owned = false;
41001         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
41002         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
41003         CHECK_ACCESS(logger_ptr);
41004         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41005         if (logger_conv.free == LDKLogger_JCalls_free) {
41006                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41007                 LDKLogger_JCalls_cloned(&logger_conv);
41008         }
41009         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
41010         CHECK_ACCESS(event_handler_ptr);
41011         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
41012         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
41013                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41014                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
41015         }
41016         LDKRetryAttempts retry_attempts_conv;
41017         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
41018         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
41019         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
41020         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
41021         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
41022         uint64_t ret_ref = 0;
41023         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41024         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41026         ret_ref = (uint64_t)ret_var.inner;
41027         if (ret_var.is_owned) {
41028                 ret_ref |= 1;
41029         }
41030         return ret_ref;
41031 }
41032
41033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
41034         LDKInvoicePayer this_arg_conv;
41035         this_arg_conv.inner = (void*)(this_arg & (~1));
41036         this_arg_conv.is_owned = false;
41037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41038         LDKInvoice invoice_conv;
41039         invoice_conv.inner = (void*)(invoice & (~1));
41040         invoice_conv.is_owned = false;
41041         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41042         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41043         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
41044         return (uint64_t)ret_conv;
41045 }
41046
41047 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) {
41048         LDKInvoicePayer this_arg_conv;
41049         this_arg_conv.inner = (void*)(this_arg & (~1));
41050         this_arg_conv.is_owned = false;
41051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41052         LDKInvoice invoice_conv;
41053         invoice_conv.inner = (void*)(invoice & (~1));
41054         invoice_conv.is_owned = false;
41055         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41056         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41057         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
41058         return (uint64_t)ret_conv;
41059 }
41060
41061 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) {
41062         LDKInvoicePayer this_arg_conv;
41063         this_arg_conv.inner = (void*)(this_arg & (~1));
41064         this_arg_conv.is_owned = false;
41065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41066         LDKPublicKey pubkey_ref;
41067         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
41068         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
41069         LDKThirtyTwoBytes payment_preimage_ref;
41070         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
41071         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
41072         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41073         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
41074         return (uint64_t)ret_conv;
41075 }
41076
41077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
41078         LDKInvoicePayer this_arg_conv;
41079         this_arg_conv.inner = (void*)(this_arg & (~1));
41080         this_arg_conv.is_owned = false;
41081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41082         unsigned char payment_hash_arr[32];
41083         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
41084         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
41085         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
41086         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
41087 }
41088
41089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41090         LDKInvoicePayer this_arg_conv;
41091         this_arg_conv.inner = (void*)(this_arg & (~1));
41092         this_arg_conv.is_owned = false;
41093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41094         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
41095         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
41096         return (uint64_t)ret_ret;
41097 }
41098
41099 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) {
41100         LDKChannelManager channelmanager_conv;
41101         channelmanager_conv.inner = (void*)(channelmanager & (~1));
41102         channelmanager_conv.is_owned = false;
41103         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
41104         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
41105         CHECK_ACCESS(keys_manager_ptr);
41106         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
41107         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
41108                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41109                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
41110         }
41111         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
41112         void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
41113         CHECK_ACCESS(amt_msat_ptr);
41114         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
41115         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
41116         LDKStr description_conv = java_to_owned_str(env, description);
41117         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
41118         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
41119         return (uint64_t)ret_conv;
41120 }
41121
41122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41123         LDKDefaultRouter this_obj_conv;
41124         this_obj_conv.inner = (void*)(this_obj & (~1));
41125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41127         DefaultRouter_free(this_obj_conv);
41128 }
41129
41130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
41131         LDKNetworkGraph network_graph_conv;
41132         network_graph_conv.inner = (void*)(network_graph & (~1));
41133         network_graph_conv.is_owned = false;
41134         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41135         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
41136         CHECK_ACCESS(logger_ptr);
41137         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41138         if (logger_conv.free == LDKLogger_JCalls_free) {
41139                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41140                 LDKLogger_JCalls_cloned(&logger_conv);
41141         }
41142         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
41143         uint64_t ret_ref = 0;
41144         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41145         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41147         ret_ref = (uint64_t)ret_var.inner;
41148         if (ret_var.is_owned) {
41149                 ret_ref |= 1;
41150         }
41151         return ret_ref;
41152 }
41153
41154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
41155         LDKDefaultRouter this_arg_conv;
41156         this_arg_conv.inner = (void*)(this_arg & (~1));
41157         this_arg_conv.is_owned = false;
41158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41159         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
41160         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
41161         return (uint64_t)ret_ret;
41162 }
41163
41164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
41165         LDKChannelManager this_arg_conv;
41166         this_arg_conv.inner = (void*)(this_arg & (~1));
41167         this_arg_conv.is_owned = false;
41168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41169         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
41170         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
41171         return (uint64_t)ret_ret;
41172 }
41173
41174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
41175         LDKStr s_conv = java_to_owned_str(env, s);
41176         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
41177         *ret_conv = SiPrefix_from_str(s_conv);
41178         return (uint64_t)ret_conv;
41179 }
41180
41181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
41182         LDKStr s_conv = java_to_owned_str(env, s);
41183         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
41184         *ret_conv = Invoice_from_str(s_conv);
41185         return (uint64_t)ret_conv;
41186 }
41187
41188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
41189         LDKStr s_conv = java_to_owned_str(env, s);
41190         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
41191         *ret_conv = SignedRawInvoice_from_str(s_conv);
41192         return (uint64_t)ret_conv;
41193 }
41194
41195 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
41196         LDKInvoice o_conv;
41197         o_conv.inner = (void*)(o & (~1));
41198         o_conv.is_owned = false;
41199         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41200         LDKStr ret_str = Invoice_to_str(&o_conv);
41201         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
41202         Str_free(ret_str);
41203         return ret_conv;
41204 }
41205
41206 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
41207         LDKSignedRawInvoice o_conv;
41208         o_conv.inner = (void*)(o & (~1));
41209         o_conv.is_owned = false;
41210         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41211         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
41212         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
41213         Str_free(ret_str);
41214         return ret_conv;
41215 }
41216
41217 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
41218         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
41219         LDKStr ret_str = Currency_to_str(o_conv);
41220         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
41221         Str_free(ret_str);
41222         return ret_conv;
41223 }
41224
41225 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
41226         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
41227         LDKStr ret_str = SiPrefix_to_str(o_conv);
41228         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
41229         Str_free(ret_str);
41230         return ret_conv;
41231 }
41232